akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
const int maxn = 200001;
vector<int>edge[maxn];
ll up[maxn];
int q, n;
ll res[maxn];
void dfs(int now, int last){
	res[now] = up[now];
	for(int &o : edge[now])if(o != last){
		up[o] += up[now];
		dfs(o, now);
	}
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q;
	for(int i = 1, a, b;i < n;++i){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for(int i = 0, x, p;i < q;++i){
		cin >> p >> x;
		up[p] += x;
	}
	dfs(1, -1);
	for(int i = 1;i <= n;++i)cout << res[i] << " \n"[i==n];
}

Measured memory_bytes: 22784
#include<bits/stdc++.h>
using namespace std;	
int main(){
	string a; cin>>a;
	int n = a.size();
	int ans = 0;
	for(int i =1; i<n; i++){
		if(a[i] == a[i-1]){
			ans++;
			if(a[i] =='0') a[i] = '1'; else a[i] = '0';
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
}

Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
inline int read()
{
    int s=0,f=1; char ch=getchar();
    while(!isdigit(ch) && ch!='-')ch=getchar();
    if(ch=='-')ch=getchar(),f=-1;
    while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
    return ~f?s:-s;
}


struct Complex {
	double a,b;
	Complex(double x=0,double y=0) {
		a=x;
		b=y;
	}
};

inline Complex operator +(Complex x,Complex y) {
	return Complex(x.a+y.a,x.b+y.b);
}
inline Complex operator -(Complex x,Complex y) {
	return Complex(x.a-y.a,x.b-y.b);
}
inline Complex operator *(Complex x,Complex y) {
	return Complex(x.a*y.a-x.b*y.b,x.a*y.b+y.a*x.b);
}
inline Complex operator /(Complex x,int y) {
	return Complex(x.a/y,x.b/y);
}

const int maxn=3e6+20;

int rev[maxn];
Complex a[maxn],b[maxn];
Complex st[maxn];
int top;

const double Pi=acos(-1);

inline void FFT(Complex *p,int n,int op) {
	int l=0;
	while((1<<l)<n)l++;
	REP(i,1,n-1)rev[i]=(rev[i>>1]>>1) | ((i&1)<<l-1);
	REP(i,1,n-1)if(i<rev[i])swap(p[i],p[rev[i]]);
	for(int i=1; i<n; i<<=1) {
		Complex w=Complex(cos(Pi/i),sin(Pi/i)*op);
		st[0]=Complex(1,0);
		REP(j,1,i-1)st[j]=st[j-1]*w;
		for(int j=0; j<n; j+=i<<1)
			for(int k=0; k<i; k++) {
				Complex x=p[j+k],y=p[i+j+k]*st[k];
				p[j+k]=x+y;
				p[i+j+k]=x-y;
			}
	}
	if(op==-1) {
		REP(i,0,n-1)p[i]=p[i]/n;
	}
}

const int g=2; 
const int mod=200003;

int id[maxn];
int fan[maxn];

int f[maxn];
int A[maxn];
ll num[maxn];

int main()
{
    int n=read();
    id[0]=1; fan[1]=0;
    REP(i,1,mod-2)id[i]=(id[i-1]*2)%mod,fan[id[i]]=i;
    fan[0]=0;
    REP(i,1,n)
    {
	int x=read(); A[i]=x;
	if(x)f[fan[x]]++;
    }
    REP(i,0,mod-1)a[i].a=f[i],b[i].a=f[i];
    int N=1; while(N<=mod*2-2)N<<=1;
    FFT(a,N,1); FFT(b,N,1);
    REP(i,0,N-1)a[i]=a[i]*b[i];
    FFT(a,N,-1);
    REP(i,0,N-1)
    {
	num[i]=(ll)floor(a[i].a+0.5);
    }
    REP(i,mod-1,N-1)num[i%(mod-1)]+=num[i];
    ll ans=0;
    REP(i,0,mod-2)ans+=num[i]*id[i];
    REP(i,1,n)ans-=(ll)A[i]*A[i]%mod;
    ans/=2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 154000
S = [c for c in input()]
T = [c for c in input()]

def main():
    z = zip(S, T)
    s = set(z)
    unpacked = list(zip(*s))
    
    ans = [len(set(t)) == len(t) for t in unpacked]
    print('Yes' if all(ans) else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 7076
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(Int i = 0; i < (Int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    map<Int, Int> mp;
    Int sum = 0;
    for(Int i = 0; i < n; i++)
    {
        Int x; cin >> x;
        mp[x]++;
        sum += x;
    }
    Int q; cin >> q;
    for(Int i = 0; i < q; i++)
    {
        Int b, c; cin >> b >> c;
        Int cnt = mp[b];
        sum -= cnt * b;
        mp[b] = 0;
        mp[c] += cnt;
        sum += cnt * c;
        cout << sum << "\n";
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int A[100],B[100],C[100];
int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int k;cin >> k;
        A[i] = k-1;
    }
    for(int i=0;i<N;i++){
        cin >> B[i] ;
    }
    for(int i=0;i<N-1;i++){
        cin >> C[i] ;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        ans += B[A[i]];
        if(A[i+1]==A[i]+1){
            ans += C[A[i]];
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   int n;
   cin >> n;

   int ans=0;
   for(int i=1; i<=n; i+=2){
       int count=0;
       for(int j=1; j<=n; j++){
           if(i%j==0) count++;
       }
       if(count==8) ans++;
   }
   cout << ans << endl;

}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];
  int64_t beat = 0;
  int i = 0;
  
  while (i < N) {
    if (B[i] - A[i] - A[i+1] > 0){
      beat += A[i] + A[i+1];
      B[i] -= A[i] + A[i+1];
      A[i] = 0;
      A[i+1] = 0;
      i++;
    } else {
      if (B[i] - A[i] > 0){
        beat += B[i];
        A[i+1] -= B[i] - A[i];
        A[i] = 0;
        B[i] = 0;
      } else {
        beat += B[i];
        A[i] -= B[i];
        B[i] = 0;
      }
      i++;
    }
  }
  
  cout << beat << endl;
  
}


Measured memory_bytes: 1024
import java.util.*;

class Main {

    static char bingo (char[] line, int a1, int a2, int a3) {

        if (line[a1] == line[a2] && line[a2] == line[a3]) {
            return line[a1];
        }

        return '?';

    }

    static char solve (char[] line) {
        char res = 'd';
        for(int i = 0; i < 3; i++) {
            res = bingo(line, 3 * i, 3 * i + 1, 3 * i + 2);
            if (res == 'o' || res == 'x') {
                return res;
            }
            res = bingo(line, i, 3 + i, 6 + i);
            if (res == 'o' || res == 'x') {
                return res;
            }
        }

        res = bingo(line, 0, 4, 8);
        if (res == 'o' || res == 'x') {
            return res;
        }
        res = bingo(line, 2, 4, 6);
        if (res == 'o' || res == 'x') {
            return res;
        }
        
        return 'd';

    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            char res = solve(sc.nextLine().toCharArray());
            System.out.println(res);
        }

    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i = 0, n = 0, x = 0, d = 0, a = 0, z = 1;
    cin >> n >> x >> d;
    for(i = 1; i <= n; i++)
    {
        cin >> a;
        while(x >= z)
        {
            d++;
            z += a;
        }
        z = 1;
    }
    cout << d;




return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	vector<int> d(n);
	rep(i,n)cin >> d[i];
	int m; cin >> m;
	vector<int> t(m);
	rep(i,m)cin >> t[i];
	sort(ALL(d));
	sort(ALL(t));
	
	int now=0;
	for(int i = 0;i<n;i++)
	{
		//cout<<t[now]<<':'<<d[i]<<endl;
		if(t[now]==d[i])
		{
			now++;
		}
		if(now==m)break;
	}
	if(now==m)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    long modd = 1000000007;
    int n = readI()-1;
    long zn = 0,z=1, b=8;
    for(int i=1;i<=n;i++){
      zn = (zn*10+z*2)%modd;
      z = (z*9+b)%modd;
      b= (b*8)%modd;
    }
    pl(zn+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

signed main() {

    string s;
    cin >> s;
    for ( int i = 0; i < 3; i++ ) {
        if ( s[i] == s[i+1] ) {
            puts("Bad");
            return 0;
        }
    }
    puts("Good");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;
 
int main(){

  int n,m;
  
cin >>n>>m;
  cout <<(n-1)*(m-1)<<endl;
  
  return 0;

}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b) = in.readLine.split(" ").map(_.toInt)
  def rec(acc:Int, n:Int):Int = {
    if(n == 0) acc
    else rec(acc+n, n-1)
  }
  val ans =  rec(0,b-a) - b
  println(ans)
}

Measured memory_bytes: 27344
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		long n = in.nextLong();
		long m = 0;
//		for (int i = 1; i <= n; i++) {
//			if (i != n) {
//				m += i % (i + 1);
//			} else {
//				m += i % 1;
//			}
//		}
		m = n * (n-1) / 2 ;
		
		System.out.println(m);
		
		
		
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<cmath>
using namespace std;

int main() {
	int n;
	int a[100];
	cin >> n;
	int pp = 0;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] % 2 == 0)pp++;
	}
	int ans = 3;
	for (int i = 1;i < n;i++)ans *= 3;
	cout << ans - pow(2,pp) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e17;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, q;
V<ll> s, t;
ll x, _;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  scanf("%d %d %d", &a, &b, &q);
  s.pb(-LINF);
  FOR(i, 0, a){
    scanf("%lld", &_);
    s.pb(_);
  }
  s.pb(LINF);

  t.pb(-LINF);
  FOR(i, 0, b){
    scanf("%lld", &_);
    t.pb(_);
  }
  t.pb(LINF);
  FOR(i, 0, q){
    scanf("%lld", &x);
    ll ls = x - *--upper_bound(all(s), x), rs = *lower_bound(all(s), x) - x,
       lt = x - *--upper_bound(all(t), x), rt = *lower_bound(all(t), x) - x,
       ans = LINF;
    mins(
      ans,
      min(
        min(max(ls, lt), max(rs, rt)),
        min(ls + rt + min(ls, rt), lt + rs + min(lt, rs))
      )
    );
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
import numpy as np


def solve(A: int, B: int):
    ans = np.array([1,2,3])
    ans[A-1]=0
    ans[B-1]=0
    print(ans.sum())

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<int> x;
    vector<int> memo;
    for(int i=0; i<n; i++){
        int tmp=0;
        cin >> tmp;
        x.push_back(tmp);
        memo.push_back(tmp);
    }
    int left = 0, right = 0;
    sort(x.begin(), x.end());
    left = x[n/2-1];
    right = x[n/2];
    for(int i=0; i<n; i++){
        if(memo[i]<= left)
            cout << right << endl;
        else if(memo[i]>=right)
            cout << left << endl;
    }
    return 0;

}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
struct edge{
    int u,v,id;
};
int n,m,u,v,deg[maxn],root;
vector<pair<int,int>> a[maxn];
vector<int> nt[maxn];
pair<int,int> b[maxn];
bool ban[maxn],vis[maxn];
void dfs(int nod){
    vis[nod]=true;
    for(auto i:a[nod]){
        if(!vis[i.first]){
            root=nod;
            ban[i.second]=true;
            nt[nod].push_back(i.first);
            nt[i.first].push_back(nod);
            dfs(i.first);
        }
    }
    return;
}
void _dfs(int nod,int pa){
    for(auto i:nt[nod]){
        if(i!=pa){
            _dfs(i,nod);
            if(deg[i]%2){
                printf("%d %d\n",i,nod);
                deg[i]++;
            }
            else{
                printf("%d %d\n",nod,i);
                deg[nod]++;
            }
        }
    }
    return;
}

int main(){
    scanf("%d%d",&n,&m);
    if(m&1)return !printf("-1\n");
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        a[u].push_back({v,i});
        a[v].push_back({u,i});
        b[i]={u,v};
    }
    dfs(1);
    for(int i=1;i<=m;i++){
        if(!ban[i]){
            printf("%d %d\n",b[i].first,b[i].second);
            deg[b[i].first]++;
        }
    }
    _dfs(root,0);

}


Measured memory_bytes: 31744
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

vector<int> read();
double think(vector<int>);
void write(double);

double radian(double);
double degree(double);
double calcVolume(int, int, double);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(input);
  write(output);

  return 0;
}

vector<int> read() {
  int a, b, x;

  cin >> a >> b >> x;
  return vector<int> {a, b, x};
}

double think(vector<int> input) {
  auto a = input.at(0);
  auto b = input.at(1);
  double x = (double) input.at(2);
  double eps = 1e-9;

  double degreeFloor = 0.0;
  double degreeCeil = 90.0;

  double radianFloor = radian(degreeFloor);
  double radianCeil = radian(degreeCeil);

  while (true) {
    double radianMid = (radianFloor + radianCeil) / 2.0;
    auto volume = calcVolume(a, b, radianMid);
    if (abs(volume - x) < eps) {
      return degree(radianMid);
    }

    if (volume > x) {
      radianFloor = radianMid;
    } else {
      radianCeil = radianMid;
    }
  }

  return x;
}

void write(double output) {
  cout << setprecision(20) << output << endl;
}

double radian(double degree) {
  return degree / 180.0 * M_PI;
}

double degree(double radian) {
  return radian / M_PI * 180.0;
}

double calcVolume(int a, int b, double theta) {
  double thetaThreshold = atan(static_cast<double>(b) / static_cast<double>(a));

  if (theta >= thetaThreshold) {
    double aDash = b * cos(theta) / sin(theta);
    return a * aDash * b / 2.0;
  } else {
    double hDash = a * tan(theta);
    double hDashDash = b - hDash;
    double volume1 = a * a * hDash / 2.0;
    double volume2 = a * a * hDashDash;
    return volume1 + volume2;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    //B - YYMM or MMYY
    int s;
    std::cin >> s;
    int a= s/100;
    int b=s%100;
    if(a<13 && a>0){
        if(b<13 && b >0){
            std::cout << "AMBIGUOUS" << std::endl;
            return 0;
        }else{
            std::cout << "MMYY" << std::endl;
            return 0;
        }
    }else if(b<13 && b>0){
        if(a<13 && a >0){
            std::cout << "AMBIGUOUS" << std::endl;
            return 0;
        }else{
            std::cout << "YYMM" << std::endl;
            return 0;
        }
        
    }else{
        std::cout << "NA" << std::endl;
        return 0;
    }
    
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    class ARC061_C //適宜名前を変える
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            long len = S.Length;
            Console.WriteLine(
                S.Select(i => long.Parse(i.ToString())).Select((i, index) =>
                {
                    long result = 0;
                    for (int j = 0; j < len - index - 1; j++)
                    {
                        result += (long)(i * Math.Pow(10, j) * Math.Pow(2, len - 2 - j));
                    }
                    result += (long)(i * Math.Pow(10, len - index - 1) * Math.Pow(2, index));
                    return result;
                }
                ).Sum());
        }
    }
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    int mx = 10000001;
    vector<ll> cnt(mx, 0);
    rep(i, 1, mx) {
        for (int j = i; j <= mx; j += i) {
            cnt[j]++;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += i * cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81360
def check(x,s,move,out)
  pos = x
  move.each do |a|
    t,d = a
    if t == s[pos]
      pos += d
    end
    break if pos == out
  end
  return pos
end 

N,Q = gets.split.map(&:to_i)
s = gets.chomp
move = []
Q.times do 
  t,d = gets.split
  move << [t,d=="L" ? -1 : 1]
end

l = ((0..N-1).bsearch{|x| check(x,s,move,-1) >= 0 } || N)
r = ((0..N-1).bsearch{|x| check(x,s,move,N) >= N } || N)
#p [l,r]
p r <= l ? 0 : r-l


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

int main(){
  vector<vector<int>> Grid(3,vector<int>(3));
  for (int i=0;i<3;i++){
    for (int j=0;j<3;j++){
      cin>>Grid.at(i).at(j);
    }
  }
  for (int i=0;i<2;i++){
    for (int j=0;j<2;j++){
      if (Grid.at(i).at(j)-Grid.at(i).at(j+1)!=Grid.at(i+1).at(j)-Grid.at(i+1).at(j+1)||Grid.at(i).at(j)-Grid.at(i+1).at(j)!=Grid.at(i).at(j+1)-Grid.at(i+1).at(j+1)){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
/**
*    created: 12.07.2020 10:47:58
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    int x; cin >> x;
    vector<int> a(n); 
    rep(i,n) cin >> a[i];
    int ans = 0;
    if (a[0] > x) {ans += a[0] - x; a[0] = x;}
    rep2(i,1,n) {
        if (a[i] + a[i-1] > x) {
            int dif = a[i] + a[i-1] - x;
            ans += dif;
            a[i] -= dif;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * 入力された文字列を反転して出力する。
	 *
	 * @param args
	 */
	public static void main(String[] args) throws IOException {

		// 入力値を受け取る
		String input = readInput();

		// 反転する
		byte[] inputBytes = input.getBytes();
		byte[] reversed = new byte[inputBytes.length];
		for (int i = 0; i < reversed.length; i++) {
			reversed[i] = inputBytes[inputBytes.length - i - 1];
		}

		// 文字列に変換して出力する
		System.out.println(new String(reversed));
	}

	/**
	 * 標準入力から1行読み込んで返す。
	 *
	 * @return 入力された文字列
	 */
	protected static String readInput() throws IOException {

		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		String line = reader.readLine();

		if (reader != null) {
			reader.close();
		}

		return line;
	}

}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int n , k ;
    cin >> n >> k;
    int h, ret = 0;
    rep(i, n) {
        cin >> h;
        if (h >=k) ret++;
    }
    cout << ret;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n, m;
	std::cin >> n >> m;
	
	int l, r;
	int max_l=0, min_r=100000;
    
	for (int i = 0; i < m; i++) {
	    std::cin >> l >> r;
	    max_l = max(l, max_l);
	    min_r = min(r, min_r);
	    
	    //std::cout << max_l << " " << min_r << std::endl;
	}
	min_r = min(n, min_r);
	
	if(min_r < max_l){
	    std::cout << 0 << std::endl;
	}else{
	    std::cout << (min_r - max_l + 1) << std::endl;
	}
	
	return 0;
}

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;

int d,c[30],s[370][30];
int cost[30];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>d;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    memcpy(cost,c,sizeof(cost));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
    for(int cur=1;cur<=d;cur++){
        //int sum=0;
        //for(int i=1;i<=26;i++)sum+=cost[i];
        //int con=rng()%sum+1;
        //for(int i=1;i<=26;i++){
        //    if(con<=cost[i]){
        //        for(int j=1;j<=26;j++){
        //            if(i==j)cost[j]=c[j];
        //            else cost[j]+=c[j];
        //        }
        //        cout<<i<<endl;
        //        break;
        //    }
        //    con-=cost[i];
        //}
        cout<<cur%26+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define PB push_back
#define FI first
#define SE second
#define MP make_pair
#define int long long
using namespace std;
static const int inf = 1ll<<60;
static const int MAX_N = 16777216;
typedef pair<int,int> P;

int N,D;
int X[40],Y[40];
int ans=0;
int dat[MAX_N*2];

class Segment{
    public :
        int n;
        void inti(int n_){
            n=1;
            while(n<n_)n*=2;
            for(int i=0;i<2*n-1;++i)dat[i]=-INT_MAX;
        }

        void update(int k,int a){
            k+=n-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                dat[k]=max(dat[k*2+1],dat[k*2+2]);
            }
        }

        int query(int a,int b,int k,int l,int r){
            if(a<=l&&r<=b)return dat[k];
            if(r<=a||b<=l)return -INT_MAX;
            else {
                int vl=query(a,b,k*2+1,l,(l+r)/2);
                int vr=query(a,b,k*2+2,(l+r)/2,r);
                return max(vl,vr);
            }
        }
};

void half(int n,int last,int x,int y,vector<P> &res) {
    if (n==last) {
        res.PB(P(x,y));
        return;
    }
    half(n-1,last,x+X[n],y+Y[n],res);
    half(n-1,last,x-X[n],y-Y[n],res);
    half(n-1,last,x,y,res);
}

signed main(){
    cin>>N>>D;
    Segment seg;
    int n2=N/2;
    for(int i=1;i<=N;++i){
        cin>>X[i]>>Y[i];
    }
    vector<P> p1;
    vector<P> p2;
    p1.reserve(MAX_N);
    half(n2,0,0,0,p1);
    p2.reserve(MAX_N);
    half(N,n2,0,0,p2);
    sort(p2.begin(),p2.end());
    seg.inti(p2.size());
    for(int i=0;i<p2.size();++i)seg.update(i,p2[i].SE);
    for(int i=0;i<p1.size();++i){
        int x=max(-D-p1[i].FI,D-p1[i].FI);
        int y=min(-D-p1[i].FI,D-p1[i].FI);
        int r=lower_bound(p2.begin(),p2.end(),MP(y,-inf))-p2.begin();
        int l=upper_bound(p2.begin(),p2.end(),MP(x,inf))-p2.begin();
        if(r==p2.size())continue;
        if(r>=l)continue;
        ans=max(ans,abs(seg.query(r,l,0,0,seg.n)+p1[i].SE));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 713196
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

int main() {
  int n, x; cin >> n >> x;
  int a, min_m = 1001;
  int m[n];
  for(int i = 0; i < n; ++i) {
    cin >> m[i];
    x -= m[i];
    min_m = min(min_m, m[i]);
  }
  cout << n + x / min_m << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str="ABC";
    int n;
    while(cin>>n){
        cout<<str<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
long power(long a,long b){return b?power(a*a%inf,b/2)*(b%2?a:1)%inf:1;}

int main() {
    int N, M, K; cin >> N >> M >> K;
    if (N > M) swap(N, M);
    int sum = 0;
    rep(i, M + 1) rep(j, N + 1) {
        sum = i * N + j * M;
        sum -= 2 * i * j;
        //if (i == 3 && j == 1) cout << sum << endl;
        if (sum == K) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int check(vector<int> ju){
 cont:
  int color = ju[0],cnt = 1,tc = 0,place;
  for(int i=1;i<ju.size();i++){
    if(color != ju[i]){
      color = ju[i]; tc = cnt; cnt = 1;
    }
    else if(color == ju[i]){
      if(cnt == 1) place = i-1; 
      cnt++;
    }
    if(tc >= 4){
      ju.erase(ju.begin() + place,ju.begin() + place + tc);
      goto cont;
    }
  }
  if(cnt >= 4) ju.erase(ju.begin() + place,ju.begin() + place + cnt);
  return ju.size();
}

int main(){
  int n;
  while(cin >> n,n){
    vector <int> v;
    for(int i=0;i<n;i++){
      int t; cin >> t; v.push_back(t);
    }
    int ans = (1 << 25),tmp;
    for(int i=0;i<n;i++){
      for(int j=1;j<=3;j++){
	if(j != v[i]){
	  tmp = v[i]; v[i] = j;
	  ans = min(check(v),ans);
	  v[i] = tmp;
	}
      }
    }
    cout << ans << endl;
    v.resize(0);
  }
}

Measured memory_bytes: 1328
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll dp[110][110][4];
  while(1){
    for(int i=0; i<110; i++){
      for(int j=0; j<110; j++){
        for(int k=0; k<4; k++){
          dp[i][j][k] = 0;
        }
      }
    }
    ll H,W;
    cin >> H >> W;
    if(H==0 || W==0) break;
    // dp 0=下下 1=右下 2=下右 3=右右
    dp[0][0][0] = 1;
    dp[0][1][3] = 1;
    dp[1][0][0] = 1;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(!i && !j) continue;
        // 右移動
        {
          // 下下=>下右
          dp[i][j+1][2] += dp[i][j][0];
          dp[i][j+1][2] %= 100000;
          // 下右->右右
          dp[i][j+1][3] += dp[i][j][2];
          // 右右->右右
          dp[i][j+1][3] += dp[i][j][3];
          dp[i][j+1][3] %= 100000;
        }
        // 下移動
        {
          // 下下->下下
          dp[i+1][j][0] += dp[i][j][0];
          // 右下->下下
          dp[i+1][j][0] += dp[i][j][1];
          dp[i+1][j][0] %= 100000;
          // 右右->右下
          dp[i+1][j][1] += dp[i][j][3];
          dp[i+1][j][1] %= 100000;
        }
      }
    }
    ll ans = 0;
    for(int i=0; i<4; i++){
      ans += dp[H-1][W-1][i];
      ans %= 100000;
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define int long long
#define mod 1000000007

bool ran(char a) {
	if ('a' <= a&&a <= 'z')return true;
	if ('A' <= a&&a <= 'Z')return true;
	return false;
}
signed main() {
	int n;
	cin >> n;
	string a[2];
	cin >> a[0] >> a[1];

	int ans = 3;
	for (int i = 0; i < n; i++) {
		if (a[0][i] == a[1][i]) {
			if (i == 0)ans *= 1;
			else if (a[0][i - 1] != a[1][i - 1])ans *= 1;
			else ans *= 2;
		}
		else {
			if (i == 0)ans *= 2;
			else if (a[0][i - 1] == a[1][i - 1])ans *= 2;
			else {
				ans *= 3;
			}

			i++;
		}
		ans %= mod;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, m;

	cin>>n>>m;

	vll x(m), d(m-1);

	rep(i, m) cin>>x[i];

	sort(all(x));

	if(n>=m){
		cout<<0<<endl;
	} else{
		rep(i, m-1) d[i]=abs(x[i+1]-x[i]);

		sort(all(d));

		ll ans=0;
		rep(i, m-n) ans+=d[i];
		cout<<ans<<endl;
	}
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;

}

Measured memory_bytes: 256
INT_MAX=10**18+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
n,m=INPUT()
A=INPUT()
sum=0
for ele in A:
    sum+=ele
if n>=sum:
    print(n-sum)
else:
    print(-1)


Measured memory_bytes: 68192
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>

using namespace std;

int main(){

	string s,p;
	int index = 0;

	getline(cin, s);
	getline(cin, p);

	for (int i = 0; i < s.size(); i++){
		index = i;
		if (s[i] == p[0]){
			for (int j = 0; j < p.size(); j++){
				index = (i + j) % s.size();
				if (s[index] != p[j]) break;
				if (j == p.size() - 1) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1180
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map全探索　for (auto i = p.begin(); i != p.end();i++){}
//mapの要素 keyはp->first valueはp->second  
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 


int main() {
	double L; cin >> L;
	cout << setprecision(20) << pow(L, 3) / 27 << endl;
}

Measured memory_bytes: 640
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$M) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
$H = array_map('intval',explode(" ",trim(fgets(STDIN))));

$con=array();
for($i=0;$i<$M;$i++) {
  list($A,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
  $con[$A-1][]=$B-1;
  $con[$B-1][]=$A-1;
}
$ans=0;
for($i=0;$i<$N;$i++) {
  if (isGood($i)) {
    $ans++;
  }
}
printf("%d\n",$ans);

function isGood($n)
{
  global $con;
  global $H;
  $isgood = true;
  $cnt=0;
  if (isset($con[$n])) {
  foreach($con[$n] as $v) {
    //たどり展望台
    if ($H[$n] <= $H[$v]) {
      $isgood = false;
      break;
    }
    $cnt++;
  }
  }
  return $isgood;
}


Measured memory_bytes: 58336
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;
  vl X(M);
  rep(i, M) cin >> X[i];

  if(N >= M){
    cout << 0 << "\n";
    return 0;
  }

  stable_sort(X.begin(), X.end());

  vl Y(M - 1);
  ll ans = 0;
  rep(i, M - 1){
    Y[i] = X[i + 1] - X[i];
    ans += Y[i];
  }

  stable_sort(Y.begin(), Y.end(), greater<ll>());

  rep(i, N - 1) ans -= Y[i];

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    vector<int> v,g;
    int a[n],b[n];
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i]>>b[i];
    	v.emplace_back(a[i]);
    	g.emplace_back(b[i]);
    }
    sort(v.begin(), v.end());
    sort(g.begin(), g.end());
    int ans = 0;
    if(n%2){
    	ans = g[n/2] - v[n/2] + 1;
    }
    else{
    	ans = (g[n/2] + g[n/2-1]) - (v[n/2] + v[n/2-1]) +1;
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 9816
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [a*-1 for a in A]
heapq.heapify(A)

for i in range(M):
    x = heapq.heappop(A)
    x = (x+1)//2
    heapq.heappush(A,x)
ans = sum(A)*-1
print(ans)

Measured memory_bytes: 14180
import sys
input = sys.stdin.readline

N = int(input())
prime = []
d = [v for v in range(2, N + 1)]
while len(d) > 0:
    p = d[0]
    prime.append(p)

    d = [v for v in d if v % p != 0]
    
def f(n):
    c = 0
    mm = {}
    while n != 1:
        t = prime[c]
        if n % t == 0:
            if mm.get(t) == None:
                mm[t] = 0
            mm[t] += 1
            n = n // t
        else:
            c += 1
    return mm

m = {}
for i in range(2, N + 1):
    t = f(i)
    for k, v in t.items():
        if m.get(k) == None:
            m[k] = 0
        m[k] += v

ans = 1
for v in m.values():
    ans = ans * (v + 1) % (10 ** 9 + 7)
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>

using namespace std;

int reversePoland(string s)
{
	stack<int> st;
	
	stringstream ss(s);
	string str;
	while (ss >> str)
	{
		int temp[2];
		if (str == "+")
		{
			for (auto i = 0; i < 2; ++i)
			{
				temp[i] = st.top();
				st.pop();
			}
			st.push(temp[0] + temp[1]);
		}
		else if (str == "-")
		{
			for (auto i = 0; i < 2; ++i)
			{
				temp[i] = st.top();
				st.pop();
			}
			st.push(temp[1] - temp[0]);
		}
		else if (str == "*")
		{
			for (auto i = 0; i < 2; ++i)
			{
				temp[i] = st.top();
				st.pop();
			}
			st.push(temp[0] * temp[1]);
		}
		else
		{
			st.push(stoi(str));
		}
	}

	return st.top();
}

int main()
{
	string s;
	getline(cin, s);

	cout << reversePoland(s) << endl;

	return 0;
}

Measured memory_bytes: 3200
X, K, D = map(int, input().split())
if X == 0:
    if K % 2 == 0:
        ans = 0
    else:
        ans = D
else:
    tmp1 = X % D
    tmp2 = tmp1 - D
    if abs(tmp1) <= abs(tmp2):
        goal = tmp1
    else:
        goal = tmp2
    cnt = abs(X - goal) // D
    if K < cnt:
        if X > 0:
            ans = X - K * D
        else:
            ans = X + K * D
    elif K == cnt:
        ans = goal
    elif K > cnt:
        if (K - cnt) % 2 == 0:
            ans = goal
        else:
            if goal >= 0:
                ans = goal - D
            else:
                ans = goal + D

print(abs(ans))


Measured memory_bytes: 61880
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))

Amax = max(A)
dp = [True] * Amax
seen = set()

for a in A:
    if a in seen:
        dp[a-1] = False
    i = 2
    while i * a <= Amax:
        dp[i*a-1] = False
        i += 1
    seen.add(a)


B = [dp[a-1] for a in A]
print(sum(B))




Measured memory_bytes: 38540