akhauriyash/Code-Regression huggingface dataset:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	h, w, m = tin()
	#s = input()
	hl=[0]*h
	wl=[0]*w
	is_on=set()
	for _ in range(m):
		hi,wi=tin()
		hl[hi-1]+=1
		wl[wi-1]+=1
		is_on.add(hi*mod+wi)
	max_h=max(hl)
	max_w=max(wl)
	t_return = max(hl)+max(wl)
	max_ids_hl=[i+1 for i,v in enumerate(hl) if v == max_h]
	max_ids_wl=[i+1 for i,v in enumerate(wl) if v == max_w]
	if len(max_ids_hl)*len(max_ids_wl) > len(is_on):
		return t_return
	for hi in max_ids_hl:
		for wi in max_ids_wl:
			if hi*mod + wi not in is_on:
				return t_return
	return t_return-1
	
	
		
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 166216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0 , A = 0;
  cin >> N >> A;
  if ((N % 500) <= A)
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main() {
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<N;i++) cin>>B[i];
    for(int i=0;i<N;i++) cin>>C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    ll ans=0;
    for(int i=0;i<N;i++) {
        ll x=lower_bound(A.begin(),A.end(),B[i])-A.begin();
        ll y=C.end()-upper_bound(C.begin(),C.end(),B[i]);
        ans+=x*y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

//public class Problem0021_Parallelism {
public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			int problemCount = Integer.parseInt(reader.readLine());
			for(int i = 0; i < problemCount; i++) {
				String[] textArray = reader.readLine().split(" ");
				GeometricVector vector1 = new GeometricVector(Double.parseDouble(textArray[0]), Double.parseDouble(textArray[1]), 
																Double.parseDouble(textArray[2]), Double.parseDouble(textArray[3]));
				GeometricVector vector2 = new GeometricVector(Double.parseDouble(textArray[4]), Double.parseDouble(textArray[5]), 
																Double.parseDouble(textArray[6]), Double.parseDouble(textArray[7]));
																
				if(vector1.isParallelTo(vector2)) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


}
class GeometricVector {
	private double xlength;
	private double ylength;
	
	GeometricVector(double x1, double y1, double x2, double y2) {
		xlength = x2 - x1;
		ylength = y2 - y1;
	}
	boolean isParallelTo(GeometricVector otherVector) {
		double otherXlength = otherVector.getXlength();
		double otherYlength = otherVector.getYlength();
		
		if(getXlength() * otherYlength - getYlength() * otherXlength == 0) {
			return true;
		} else {
			return false;
		}
	}
	double getXlength() {
		return xlength;
	}
	double getYlength() {
		return ylength;
	}
}

Measured memory_bytes: 9796
import fractions
N = int(input())
A = [int(i) for i in input().split()]

GCD_l = [A[0]]
for i in range(1, N-1):
    GCD_l.append(fractions.gcd(GCD_l[-1], A[i]))

A = A[::-1]
GCD_r = [A[0]]
for i in range(1, N-1):
    GCD_r.append(fractions.gcd(GCD_r[-1], A[i]))
GCD_r = GCD_r[::-1]

# print(GCD_l, GCD_r)

ans = 1
for i in range(N):
    if i == 0:
        ans = max(ans, GCD_r[0])
    elif i == N-1:
        ans = max(ans, GCD_l[N-2])
    else:
        ans = max(ans, fractions.gcd(GCD_l[i-1], GCD_r[i]))
print(ans)


Measured memory_bytes: 16124
n = int(input())
ans = {}
for i in range(n):
	s = input()
	if(ans.get(s)):
		ans[s] +=1
	else:
		ans[s] = 1

m = max(ans.items(), key = lambda x:x[1])[1]
a = []
for t in ans.items():
	if(t[1]==m):
		a.append(t[0])

a.sort()
for t in a:
	print(t)

Measured memory_bytes: 32096
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int M = sc.nextInt();
    PriorityQueue<Integer> que = new PriorityQueue<>((x,y) -> y-x);
    for(int i=0; i<N; i++){
      int A = sc.nextInt();
      que.add(A);
    }
    for(int i=0; i<M; i++){
      int a = que.poll();
      a /= 2;
      que.add(a);
    }
    long ans = 0;
    for(int i=0; i<N; i++){
      int k = que.poll();
      ans += k;
    }
    out.println(ans);
  }
  
}

Measured memory_bytes: 30780
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	h := make(IntHeap, n)
	heap.Init(&h)
	heap.Push(&h, a[0])
	var ans int64
	for i := 1; i < n; i++ {
		v := heap.Pop(&h).(int)
		ans += int64(v)
		heap.Push(&h, a[i])
		heap.Push(&h, a[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 16728
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(i64);
    let mut ps = scan!(usize;;);
    let mut ans = 0;
    for i in 0..ps.len() {
        if ps[i] == i + 1 {
            if i + 1 < ps.len() {
                ps.swap(i, i + 1)
            }
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define H_max 200
#define W_max 200


int main(){
    int H,W;
    cin >> H >>W;
    int wall[10]={};
    int cost[10][10];
    REP(i,10){
        REP(j,10){
            scanf("%d",&cost[i][j]);
        }
    }

    REP(i,10){
        REP(j,10){
            REP(k,10) if(cost[j][i] + cost[i][k] < cost[j][k]) cost[j][k]=cost[j][i] + cost[i][k];
        }
    }
    int tmp;
    REP(i,W){
        REP(j,H){
            scanf("%d",&tmp);
            if(tmp!=-1)  wall[tmp]+=1;
        }
    }
    llong ans=0;
    REP(i,10){
        ans+=wall[i] * cost[i][1];
    }

    cout << ans << endl;


}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 4010
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
const ll mod=1e9+7;

int main() {
#ifdef ONLINE_JUDGE
#else
    //FREI;
    // FREO;
#endif
    //FAST;
    int n,m,k;
    cin>>n>>m>>k;
    int a=n;
    int b=m;
    bool flag=0;
    for(int i=0;i<=m;i++)
        for(int j=0;j<=n;j++)
    {
        ll tmp=(ll)a*i+(ll)b*j-2*i*j-k;
        if(tmp==0)
            flag=1;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int AB = A + B;
	rep(i, N) {
		if (S.at(i) == 'a') {
			
			if(AB>0){
				
				cout << "Yes" << endl;
				AB--;
			}
			else {
				cout << "No" << endl;
			}
			
		}
		else if (S.at(i) == 'b') {
			if (AB > 0 && B > 0) {
				cout << "Yes" << endl;
				AB--;
				B--;
			}
			else {
				cout << "No" << endl;
			}
			
		}
		else {
			cout << "No" << endl;
		}
	}

}

Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int fac[200010], facinv[200010];
PII a[3010];
int f[3010][2];
int h, w, n;

inline int quickmul(int x, int y) {
    int ret = 1, mul = x;
    while (y) {
        if (y & 1) {
            ret = (LL)ret * mul % mod;
        }
        mul = (LL)mul * mul % mod;
        y >>= 1;
    }
    return ret;
}

inline int C(int x, int y) {
    return (LL)fac[x] * facinv[y] % mod * facinv[x - y] % mod;
}

inline void work() {
    cin >> h >> w >> n;
    fac[0] = facinv[0] = 1;
    for (int i = 1; i <= h + w; ++i) {
        fac[i] = (LL)fac[i - 1] * i % mod;
        facinv[i] = quickmul(fac[i], mod - 2);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + n + 1);
    int ans = C(h + w - 2, h - 1);
    for (int i = 1; i <= n; ++i) {
        int x = a[i].first;
        int y = a[i].second;
        f[i][0] = (LL)C(x - 1 + y - 1, x - 1) % mod;
        for (int j = 1; j < i; ++j) {
            if (x >= a[j].first && y >= a[j].second) {
                int coef = C(x - a[j].first + y - a[j].second, x - a[j].first);
                f[i][0] = (f[i][0] + (LL)f[j][1] * coef % mod) % mod;
                f[i][1] = (f[i][1] + (LL)f[j][0] * coef % mod) % mod;
            }
        }
        int tail = C(h - x + w - y, h - x);
        ans = (ans - (LL)f[i][0] * tail % mod + mod) % mod;
        ans = (ans + (LL)f[i][1] * tail % mod) % mod;
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int n,cnt[15],x[15][15],y[15][15],ans=0;
void check(int w)
{
	int num=0;
	REP(i,n)
		if(w>>i&1)
		{
			++num;
			REP(j,cnt[i])
				if((w>>x[i][j]&1)!=y[i][j])return;
		}
	ans=max(ans,num);
}
int main()
{
	cin>>n;
	REP(i,n)
	{
		cin>>cnt[i];
		REP(j,cnt[i])cin>>x[i][j]>>y[i][j],--x[i][j];
	}
	for(int i=1;i<1<<n;++i)check(i);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// Problem : F - Select Half
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n;
int a[200005];

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    vi pre(n+1), dp(n+1);
    pre[1] = a[1];
    for(int i=3;i<=n;i+=2) pre[i] = pre[i-2]+a[i];
    for(int i=2;i<=n;i++){
        if(i%2) dp[i] = max(dp[i-1],dp[i-2]+a[i]);
        else {
            dp[i] = a[i]+dp[i-2];
            dp[i] = max(dp[i],pre[i-1]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 7960
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=1;
    string s;
    cin>>n>>s;
    map<char,ll> m;
    for(auto ch : s){
        if(m.count(ch)) m[ch]++;
        else m[ch]=1;
    }
    for(auto q : m){
        ans=(ans*(q.second+1))%MOD;
    }
    ans--;
    cout<<(MOD+ans)%MOD<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}


const int SZ = 2123456;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
mint choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  ll res = fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
  return mint(res);
}



int main2() {
  int K = nextLong();
  string S; cin >> S;
  const int N = S.size();

  mint ans = mint(26).pow(N+K);
  for (int a = 0; a < N; a++) {
    ans -= choose(N+K, a) * mint(25).pow(N+K-a);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 55156
#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > g;

void solve(deque<int>& path) {
	vector<bool> used(g.size(), false);
	for (int x : path) used[x] = true;
	bool flag1 = false, flag2 = false;
	while (true) {
		bool flag = true;
		for (int x : g[path.front()]) {
			if (!used[x]) {
				used[x] = true;
				path.push_front(x);
				flag = false;
				break;
			}
		}
		if (flag) break;
	}
	while (true) {
		bool flag = true;
		for (int x : g[path.back()]) {
			if (!used[x]) {
				used[x] = true;
				path.push_back(x);
				flag = false;
				break;
			}
		}
		if (flag) break;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	srand((unsigned int)time(NULL));
	int n, m;
	cin >> n >> m;
	g.resize(n);
	deque<int> path(2);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (i == 0) {
			path[0] = a;
			path[1] = b;
		}
		g[a].push_back(b);
		g[b].push_back(a);
	}
	solve(path);
	cout << path.size() << endl;
	cout << path[0] + 1;
	for (int i = 1; i < path.size(); i++) {
		cout << " " << path[i] + 1;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(-1111);
    rep(i, n)
    {
        int t;
        cin >> t;
        a.push_back(t);
    }
    vector<int> b(n + 1, 0);
    b[0] = -1111;
    int m = 0;
    for (int i = n; i >= 1; i--)
    {
        int j = 1, tmp = 0;
        while (i * j <= n)
        {
            tmp += b[i * j];
            j++;
        }
        tmp += a[i];
        tmp %= 2;
        b[i] = tmp;
        m += tmp;
    }
    cout << m << endl;
    if (m == 0)
    {
        return 0;
    }
    rep(i, n + 1)
    {
        if (b[i] == 1)
        {
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
using namespace std;
int main(void){
    int a,b,m=0;
    cin>>a>>b;
    for(int i=0;i<2;i++){
        m=m+max(a,b);
        if(a<=b){
            b=b-1;
        }else{
            a=a-1;
        }
    }
    std::cout << m << std::endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L;
  cin >> N >> L;
  if (L > 0) {
    cout << (2 *L + N -1) * N / 2 - L << endl;
  }
  else if (N + L - 1 < 0) {
    cout << (2 *L + N -1) * N / 2 - (N + L - 1) << endl;
  }
  else {
    cout << (2 *L + N -1) * N / 2 << endl;
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        p: u32,
    }
    println!("{}", (a * 3 + p) / 2);
}


Measured memory_bytes: 4352
#include <iostream>

bool judge(int x) {
    for (int i = 2; i < x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int A, B;
    std::cin >> A >> B;
    if (A > B * 2) {
        std::cout << A - (B * 2) << '\n';
    } else {
        std::cout << 0 << '\n';
    }
}

Measured memory_bytes: 256
while True:
	dict = {}
	n = input()
	if n == 0:break
	for x in xrange(n):
		a, b = raw_input().split()
		dict[a.strip()] = b.strip()
	res = ""
	for x in xrange(input()):
		a = raw_input().strip()
		if a in dict:
			res += dict[a]
		else:
			res += a
	print res

Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int sum=0;
  
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    
    if(x < K-x)
      sum +=x;
    
    else
      sum +=(K-x);
  }
  cout << sum*2 << endl;
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A*C <= B) {
        print(C);
    } else {
        print(floor((double)B / A));
    }
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll x;
  cin >> x;
  ll a,b;
  for(int i = -1000; i <= 1000; i++){
    a = pow(i,5);
    for(int j = -1000; j <= 1000; j++){
      b = pow(j,5);
      if(a-b == x){
        printf("%d %d\n",i,j );
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4160
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue> 
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define pb push_back
#define ff first
#define ss second

using namespace std;

int n,k;
int v[51];
int dp[51][51][101];

int ans = 0;

int fun(int l,int r,int c){
    if(c<=0){
        return 0;
    }
    if(l>r){
        return 0;
    }
    if(dp[l][r][c]!=-1){
        return dp[l][r][c];
    }
    int x = 0;
    x = max(max(x,max(fun(l+1,r,c-2),fun(l,r-1,c-2))),max(fun(l+1,r,c-1)+v[l],fun(l,r-1,c-1)+v[r]));
    return dp[l][r][c] = x;
}

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<fun(0,n-1,k)<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
string s;
int n,arr[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l,r,d;
    cin>>l>>r>>d;
    int num=0;
    for (int i=l;i<=r;i++){
        if (i%d==0) num++;
    }
    cout<<num;
    /*
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    */
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7,N=2e6+5;
int x,y,xx,yy,fac[N],inv[N],n;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int calc(int n,int m){
	int tot=0;
	for(int i=1;i<=m;i++) tot=(tot+C(n+i+1,i+1))%mod;
	return ((tot-m)%mod+mod)%mod;
}

signed main(){
	read(x);read(y);read(xx);read(yy);
	n=max(xx,yy)*2+1;
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	write(((calc(xx,yy)-calc(x-1,yy)-calc(xx,y-1)+calc(x-1,y-1))%mod+mod)%mod);
}

Measured memory_bytes: 31488
#include <stdio.h>
#include <stdlib.h>

int partition(int *,int ,int );

int main(){
  int n, i, *A, key;

  scanf("%d",&n);
  if(n<1 || n>100000) exit(1);

  A = malloc( n*sizeof(int) );
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(A[i]<0 || A[i]>100000) exit(2);
  }
  
  key = partition(A, 0, n-1);

  for(i=0; i<n; i++){
    if(i == key){
      printf("[%d]", A[i]);
      if(i<n-1) printf(" ");
      continue;
    }
    printf("%d", A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
    
  return 0;
}

int partition(int *A, int p, int r){
  int i, j, x, tmp, omp;

  x = A[r];
  i = p-1;
  for(j=p; j<=r-1; j++){
    if(A[j] <= x){
      i++;
      tmp =A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  omp = A[i+1];
  A[i+1] = A[r];
  A[r] = omp;

  return i+1;
}



Measured memory_bytes: 2132
#include <iostream>
#include <random>
using namespace std;

int main(){
  int A,B,s=0;
  cin >> A >> B;

  if(A>B){
    s = A--;
  }else{
    s = B--;
  }

  if(A>B){
    s = s + A;
  }else{
    s = s + B;
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N[1000000],G[20];
    int x,j=0;
    int a,t,c,d,h=1,cnt=0;
    
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%d",&N[i]);
    }
	
	c=x;
	while(c>0){
		G[j]=h;
		h=h*3+1;
		j++;
		d=c%3;
		c=c/3;
		if(h>=d+c*3){break;}
	}
	
	printf("%d\n",j);
	printf("%d",G[j-1]);
	for(int i=j-2;i>=0;i--){
		printf(" %d",G[i]);
	}
	printf("\n");
	
	for(h=G[j-1];h>0;h/=3){
	    for(int i=h;i<x;i++){
	        a=N[i];
	        t=i-h;
	        while(t>=0 && N[t]>a){
	            N[t+h]=N[t];
	            t-=h;
	        	cnt++;
	        }
	        N[t+h]=a;
	    }
	}
	
	printf("%d\n",cnt);
	
	for(int i=0;i<x;i++){
		printf("%d\n",N[i]);
	}
	
    return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>

#define pb push_back
#define s second 
#define f first

typedef long long ll;
using namespace std;

ll MOD=1e9+7;

int main(){
	ll n, k, arr[3000];
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>arr[i];
	ll ans=0;
	for(int i=1; i<=n; i++){
		ll tmp=0;
		for(int j=i+1; j<=n; j++){
			if(arr[i]>arr[j])
				tmp+=1;
		}
		ans+=tmp*k;
		ll tmp2=0;
		for(int j=1; j<=n; j++){
			if(arr[i]>arr[j]){
				tmp2+=1;
			}
		}
		ans += (((((k)*(k-1))/2)%MOD)*tmp2);
		ans %=MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int pasta[3], juice[2], min = 4000;
	
	scanf("%d%d%d%d%d", &pasta[0], &pasta[1], &pasta[2], &juice[0], &juice[1]);
	
	int p, j;
	for(p = 0; p < 3; p ++) {
		for(j = 0; j < 2; j ++) {
			if(pasta[p] + juice[j] - 50 < min) {
				min = pasta[p] + juice[j] - 50;
			}
		}
	}
	
	printf("%d\n", min);
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

ll sum[MAXN], ps[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    ll S;
    cin >> S;
    
    sum[0] = sum[1] = sum[2] = 0;
    for (int i = 3; i <= S; i++) {
        sum[i] = 1;
        if (i-3 >= 0) sum[i] = (sum[i] + ps[i-3])%MOD;
        ps[i] = (ps[i-1] + sum[i])%MOD;
    }
    cout << sum[S] << "\n";
}


Measured memory_bytes: 3600
import numpy as np

N, W = map(int, input().split())
wv = []
#i番目までを詰めたときの最大の価値を記録
dp = np.zeros(W+1)
for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[:-w]+v, dp[w:])

print(int(dp[-1]))

Measured memory_bytes: 15484
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        for(int i=0; i<m; i++){
            n -= sc.nextInt();
        }
        
        System.out.println(n>=0?n:-1);
    }
}

Measured memory_bytes: 46384
#include <iostream>
#include <vector>

constexpr bool divisible(const std::size_t n, const std::size_t m)
{
	return (0 == n % m);
}

constexpr bool help_prime(const std::size_t n, const std::size_t m)
{
	return (m * m <= n) ?
        !divisible(n, m) && help_prime(n, m + 1) :
        true;
}

constexpr bool prime(const std::size_t n)
{
	return (n <= 1) ?
        false :
        help_prime(n, 2);
}

std::pair<std::size_t, std::size_t> find_twin_prime(const std::size_t limit, const bool next_skip = false)
{
    return prime(limit) ?
        prime(limit - 2) ?
        std::make_pair(limit - 2, limit) :
        find_twin_prime(limit - (next_skip ? 3 : 1), true) :
        find_twin_prime(limit - (next_skip ? 2 : 1), false);
}

int main()
{
    std::vector<std::size_t> ns;
    std::size_t n;
    
    while(std::cin >> n, n != 0)
    {
        ns.push_back(n);
    }

    for(const auto a : ns)
    {
        const auto&& t = find_twin_prime(a);
        std::cout << t.first << " " << t.second << std::endl;
    }
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    int one,two;
    one=max(a[0],a[1]);
    two=min(a[0],a[1]);
    for(int i = 2;i<n;i++){
        if(a[i]>one){
            two=one;
            one=a[i];
        }
        else if(a[i]>two){
            two=a[i];
        }
    }
    rep(i,n){
        if(a[i]!=one){
            cout << one << endl;
        }
        else{
            cout << two << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 300005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if (a < b)
        swap(a, b);
    if ((a - b) % 2 == 0)
        cout << (a - b) / 2 << endl;
    else
    {
        ll ans = min(a - 1, n - b);
        ll A = a, B = b;
        ll st = b;
        A -= st;
        B = 1;
        st += (A - B) / 2;
        ans = min(ans, st);

        st = n - a + 1;
        a = n;
        b += st;
        st += (a - b) / 2;
        ans = min(ans, st);

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())

a=list(map(int,input().split()))

kp=0
asum=0
flag=-1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            kp=kp+asum+1
            asum=-1
    else:
        if asum<=0:
            kp=kp+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",kp)            
km=0
asum=0
flag=1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            km=km+asum+1
            asum=-1
    else:
        if asum<=0:
            km=km+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",km)            

print(min(kp,km))
        

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 1e18;
const int nax = 200005;
int a[nax];
int n,k;
int check(double len)
 {
	 int cnt = 0;
	 loop(i,0,n)
	  cnt += floor(a[i]/len);
	 //cerr<<fixed<<setprecision(10);
	 //cerr<<len<<" "<<cnt<<END;
	 return cnt;
 }
void solve()
 {
  cin>>n>>k;
  int mx = 0;
  loop(i,0,n)
  {
   cin>>a[i];
   mx = max(a[i],mx);
 }
  double lo = 0,hi = mx;
  loop(i,0,150)
   {
		 double mid = 1.0*(lo+hi)/2.0;
		 int cuts = check(mid);
		 if(cuts<=k)
		  hi = mid;
		 else
		  lo = mid;
	 }
	lo = ceil(lo);
	int ans = lo;
	cout<<ans;  
 }  
signed main()
 {   
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0); 
   /*int t;
   cin>>t;
   loop(i,1,t+1)*/
      solve();
      
  //cerr<<END<<1.0*clock();
  return 0;
} 


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace  std;
#define ll long long
int main(){
	ll int n,a[1000000],res[1000000];
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int t=n;
	if(n%2) t=n-1; 
	for(int i=1;i<=t/2;i++){
		res[i]=a[t-2*(i-1)];
		res[t/2+i]=a[2*i-1];
	}
	if(n%2==0){
		for(int i=1;i<=n;i++)
			cout<<res[i]<<" ";
	}
	else{
		cout<<a[n]<<" ";
		for(int i=n-1;i>=1;i--)
			cout<<res[i]<<" ";
	}
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
const int INF = 1000000000;

int A[12][12];

int main(){
  int n, m, x;
  vector<int> C(n);

  cin >> n >> m >> x;
  rep(i, n){
    cin >> C[i];
    rep(j, m){
      cin >> A[i][j];
    }
  }

  int ans = INF;

  rep(s,1 << n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if (s>>i&1) {
        cost += C[i];
        rep(j,m) d[j] += A[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }

  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3696
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 And W == 0)break;
		rep(i, H) {
			rep(j, W) {
				if ((i + j) % 2 == 0)cout << "#";
				else cout << ".";
			}
			Lb;
		}
		Lb;
	}
}

Measured memory_bytes: 1156
import sys
dataset = sys.stdin.readlines()


def gcd(a, b):
    if b > a: return gcd(b, a)
    if a % b == 0: return b
    return gcd(b, a % b)

def lcd(a, b):
    return a * b // gcd(a, b)

for item in dataset:
    a, b = list(map(int, item.split()))
    print(gcd(a, b), lcd(a,b))

Measured memory_bytes: 7684
n=int(input())
h=list(map(int,input().split()))
ans=0
i=0

while i <n-1:
    a=0
    for j in range(i+1,n):
        if h[j-1]>=h[j] and j<n-1:
            a+=1
        elif h[j-1]>=h[j] and j==n-1:
            a+=1
            ans=max(a,ans)
            i=j
            break
        else:
            ans=max(a,ans)
            i=j
            break
        
print(ans)


Measured memory_bytes: 14224
import math
a,b,h,m = [int(x) for x in input().split()]
p = math.pi
arg_h = 2 * p * h / 12 + m * p / 360
arg_m = 2 * p * m / 60
arg = abs(arg_h - arg_m)
c_2 = a**2 + b**2 - 2 * a * b *math.cos(arg)
c = math.sqrt(c_2)
print(c)

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<int(1e9 + 7)>;
  int N;
  cin >> N;
  long long A[N];
  int cnt[60];
  fill(cnt, cnt + 60, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < 60; j++) cnt[j] += (A[i] >> j) & 1;
  }
  Mint ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 60; j++) {
      Mint tmp = (A[i] >> j & 1) ? N - cnt[j] : cnt[j];
      ans += tmp * Mint(2).pow(j);
    }
  }
  ans /= Mint(2);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5916
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int n;
   cin >> n;
   
   int total = 0;
   map<string, int> mp;
   
   for(int i = 0; i < n; i++){
       string s;
       int t;
       cin >> s >> t;
       
       total += t;
       mp[s] = total;
   }
   
   string s2;
   cin >> s2;
   
   int ans = total - mp[s2];
   cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char b, L;
    cin >> b;
    if(b == 'A')
    L = 'T';
    if(b == 'T')
    L = 'A';
if(b == 'C')
L = 'G';
if(b == 'G')
L = 'C';
cout << L << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
const int MAXV=1e5+5;
const int N=105;
const long long INF=1e15+5;
long long dp[MAXV];
int wi[N];
int vi[N];
int n,w;
int V;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>w;
  for(int i=0;i<n;i++){
    cin>>wi[i]>>vi[i];
    V+=vi[i];
  }
  for(int i=0;i<=V;i++){
    dp[i]=INF;
  }
  dp[0]=0;
   int current_v,current_w;
  for(int i=0;i<n;i++){
      current_v=vi[i];
      current_w=wi[i];

      for(int j=V;j>=current_v;j--){
        dp[j]=min(dp[j],dp[j-current_v]+current_w); //dp[j]is the minimum weight needed to construct the sum of values j
        //with the condition j-current_v we fetch for a precomputed dp of the difference
        //of values(es.: for dp[11] and current_value=7 we search for dp[4] 
      }

  }
  
  for(int i=V;i>=0;i--){
    if(dp[i]<=w){
      cout<<i<<endl;
      break;
    }
  }
  

  


     
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int64_t N; cin >> N;
    int H = 0, W = 0;
    for(int i = 1; i * i <= 1000000; ++i) {
        if(i * (i + 1) / 2 == N) {
            W = i;
            H = i + 1;
            break;
        }
    }
    if(H == 0) {
        cout << "No" << '\n';
        return 0;
    }
    vector<vector<int>> ans(H, vector<int>(W));
    for(int i = 0; i < H - 1; ++i) {
        ans[i][i] = ans[i + 1][i] = i + 1;
    }
    int n = H;
    for(int i = 2; i < H; ++i) {
        int cur = i;
        while(cur < H) {
            ans[cur][cur - i] = n;
            cur++, n++;
        }
    }
    n = H;
    for(int i = 1; i < W; ++i) {
        int cur = i;
        while(cur < W) {
            ans[cur - i][cur] = n;
            cur++, n++;
        }
    }
    cout << "Yes" << '\n';
    cout << H << '\n';
    rep(i, H) {
        cout << W << " ";
        rep(j, W) cout << ans[i][j] << " ";
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



# N = intinput()
S = input()
# A, B, C, D, E, F = mulinputs()
# datas = list(mulinputs())
# datas = lineinputs(input)
print(chr(ord(S)+1))




Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=0,sum=0;
	rep(i,n){
		if(a.at(i)) sum+=a.at(i);
		else{
			ans+=sum/2;
			sum=0;
		}
	}
	ans+=sum/2;
	cout << ans << endl;
}

Measured memory_bytes: 640
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long, long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    r(i,0,m)
    {
    	ll x;
    	cin>>x;
    	sum+=x;
    }
    if(n-sum<0)
    cout<<-1;
    else
    cout<<n-sum;
  
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll x[n];
    rep(i, n) { cin >> x[i]; }

    ll diff[n - 1];
    rep(i, n - 1) { diff[i] = x[i + 1] - x[i]; }

    ll ans = 0;
    rep(i, n - 1) {
        if (diff[i] * a > b) {
            ans += b;
        } else {
            ans += diff[i] * a;
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;

        ++mp[s];
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    

    return 0;
}

Measured memory_bytes: 3668