akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back



ll gcd(ll a , ll b){
    ll bigger=max(a,b);
    ll smaller=min(a,b);
    if (bigger%smaller==0){
        return smaller;
    }
    else {
        return gcd(smaller, bigger%smaller);
    }

}






int main(){

     ll n,m,k;
     cin>>n>>m>>k;

     vector<ll> asum(n);

     vector<ll> bsum(m);

     ll tmpa=0;

     rep(i,n){
         ll tmp;
         cin>>tmp;
         tmpa+=tmp;
         asum.at(i)=tmpa;

     }

     ll tmpb=0;

     rep(i,m){
         ll tmp;
         cin>>tmp;
         tmpb+=tmp;
         bsum.at(i)=tmpb;
     }


     ll answer=0;

     rep(i,n){
         ll check=k-asum.at(i);
       
       if (check<0){
         break;
       }
       
       

         ll x=distance(bsum.begin(),upper_bound(ALL(bsum),check));

         if (answer<x+i+1){
             answer=x+i+1;
         }



     }
  
  
  	if (distance(bsum.begin(),upper_bound(ALL(bsum),k))>answer){
      answer=distance(bsum.begin(),upper_bound(ALL(bsum),k));
    }
  

     cout<<answer<<endl;
     








}

Measured memory_bytes: 6368
def solve():
  N = int(input())
  T = list(map(int, input().split()))
  M = int(input())
  ans = [sum(T)]*M
  for i in range(M):
    x,y = map(int, input().split())
    ans[i] += y-T[x-1]
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 9196
n, a, b = map(int, input().split())
ns = list(map(int, input().split()))
dis = [ns[i + 1] - ns[i] for i in range(n - 1)]
ttl = 0
for i in range(0, n-1):
    ttl += min(dis[i] * a, b)
print(ttl)

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int n;
  cin >> n;
  forn ( i, n+1){
    int c = i*1.08 ;
    if ( c == n ){
      cout << i << endl;
      return 0 ;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3636
def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in a:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                print('DENIED')
                exit()
    print('APPROVED')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x,y,i,j,sum=0,n=0;
  cin>>x>>y;
  int a[x];
  for(i=0;i<x;i++)cin>>a[i];
  for(i=0;i<x;i++)
  {
      sum=sum+a[i];
      if(sum<=y)n++;

  }
  cout<<n+1<<endl;

}


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

int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int ans=0;
    for(int i=0;i*i*i<=n;i++)
      for(int j=0;j*(j+1)*(j+2)/6<=n;j++){
	if(i*i*i+j*(j+1)*(j+2)/6>n)break;
	ans=max(ans,i*i*i+j*(j+1)*(j+2)/6);
      }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    int ans = max({b - (a + w), a - (b + w), 0});

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


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;

signed main(){
    int L,R;
    cin>>L>>R;
    constexpr int mod=2019;
    int ans=mod-1;
    for(int i=L;i<=min(R,L+743);++i){
        for(int j=i+1;j<=min(R,L+743);++j) ans=min(ans,(i%mod)*(j%mod)%mod);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
    int a,b,temp=0;
    cin >> a >> b ;
    if(b==1){cout << "0" << endl; return 0;}
    while(b>a)
    {
        b-=(a-1);
        temp++;
    }
    temp++;
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdlib>
#define rep(i,o,u) for(int i = o;i < u; i++)
using namespace std;
int n,q;
int a[1000000+1];
int search(int key){
	int left = 0;int right = n;
	while(left < right){
		int mid = (left + right)/2;
		if(a[mid] == key)
			return mid;
		else if(a[mid] > key)
			right = mid;
		else if(a[mid] < key)
			left = mid + 1;
	}
	return -1;
}
int main(){
	cin >> n;
	rep(i,0,n) cin >> a[i];
	sort(a,a+n);
	int key;
	int ans = 0;
	cin >> q;
	while(q--){
		cin >> key;
		if(search(key)!= -1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	long n,m,i,j,k,ans,cur,res,x;
	cin >> n >> m >> x;
	vector<vector<long>> a(n,vector<long>(m));
	vector<long> p(m),c(n);
	for(i=0; i<n; i++){
		cin >> c[i];
		for(j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	
	long b;
	ans=10000000;
	for(b=0; b<(1<<n); b++){
		for(j=0; j<m; j++){
			p[j]=0;
		}
		cur=0;
		for(i=0; i<n; i++){
			if(b&(1<<i)){
				for(j=0; j<m; j++){
					p[j]+=a[i][j];
				}
				cur+=c[i];
			}
		}
		for(j=0; j<m; j++){
			if(p[j]<x){
				cur=-1;
			}
		}
		if(cur>0){
			ans=min(ans,cur);
		}
	}
	
	if(ans==10000000){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ps = readln.split.to!(int[]);
    int c;
    foreach (i; 1..N-1) {
        auto x = ps[i-1];
        auto y = ps[i];
        auto z = ps[i+1];
        if (x < y && y < z || z < y && y < x) ++c;
    }
    writeln(c);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }

//CODE

void solve(void)
{
  int H;
  cin>>H;
  int N;

  cin>>N;
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    SUM += A;
  }
  if( SUM >= H)
  cout<<"Yes"<<endl;
  else
  {
    cout<<"No"<<endl;
  }
  

  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;


alias Tuple!(int, "i", long, "n") Mt;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = new Mt[](N);
    foreach (i, a; enumerate(A)) {
        B[i] = Mt(i.to!int, a);
    }
    B.sort!"a.n == b.n ? a.i > b.i : a.n > b.n"();
    auto ans = new long[](N);
    fill(ans, 0);

    auto s = int.max;
    foreach (i; 0..N-1) {
        s = min(s, B[i].i);
        if (s == 0) break;
        if (B[i].n == B[i+1].n)
            continue;
        ans[s] += (B[i].n - B[i+1].n) * (i+1);
    }

    ans[0] = A.sum - ans.sum;
    ans.each!(writeln);
}


Measured memory_bytes: 8636
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  L=list(map(int,input().split()))
  s=[l*b for (l,b) in zip(L,B)]
  if sum(s)>-C:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    string str; cin >> str;
    
    int ret = INT_MAX;
    
    for(int i = 0; i < (int)str.size() - 2; i++)
    {
        int number = stoi(str.substr(i, 3));
        ret = min(ret, abs(753 - number));
    }
    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    int X, A;
    
    cin >> X >> A;
    
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = sc.nextIntArray(n);
		
		int[] dp = new int[n+2];
		
		dp[1] = l[0];
		
		for(int i = 2; i <= n; i++) {
			dp[i] = dp[i-1] + l[i-1];
		}
		
		int cnt = 0;
		
		for(int i = 0; i <= n; i++) {
			if(dp[i] <= x) cnt++;
		}
		
		out.println(cnt);
		
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23252
def main():
    N, M = map(int, input().split())
    
    left = 0
    right = float('inf')
    
    for i in range(M):
        L, R = map(int, input().split())
        left = max(left, L)
        right = min(right, R)
    
    if left <= right:
        print(right - left + 1)
    else:
        print(0)

main()

Measured memory_bytes: 46352
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,h;
    cin>>n>>h;
    vector<long> a(n),b(n);
    for(int i = 0; i< n; i++){
        cin>>a[i];
        cin>>b[i];
    }
    sort(b.begin(),b.end(),greater<long>());
    long a_max = *max_element(begin(a),end(a));
    long sum=0;
    for(auto x:b){
        if(x<a_max)
            break;
        h-=x;
        sum++;
        if(h<=0){
            cout<<sum;
            return 0;
        }
    }
    sum+=h/a_max;
    if(h-a_max*(h/a_max)>0)
        sum++;
    cout<<sum;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    // Your code here!
    int n,counta=0,countk=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i%2==1){
            countk++;
        }
        counta++;
    }
    double d=((double)countk)/counta;
    printf("%lf",d);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define rev(a,n) rep(qwqrev,1,(n)/2) swap(a[qwqrev],a[(n)-qwqrev+1])
#define INF (INT_MAX/10-10)
#define lint long long
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=6010;char str[N];int a[N],b[N],L[N],R[N],suf[N];
inline int all_zero(int *a,int n) { rep(i,1,n) if(a[i]) return 0;return 1; }
inline int solve(int *a,int *b,int n)
{
	rep(i,1,n) b[i+n]=b[i+n+n]=b[i];
	rep(i,1,n)
	{
		for(int j=i+n;j<=3*n;j++) if(b[j]) { R[i]=j-(i+n);break; }
		for(int j=i+n;j>=1;j--) if(b[j]) { L[i]=i+n-j;break; }
	}
	int res=INF;
	rep(t,0,n-1)
	{
		int ans=INF,s=0;rep(i,1,n+1) suf[i]=0;
		rep(i,1,n) if(a[i]!=b[i-t+n])
		{
			s++;if(!a[i]||L[i]<=t) continue;
			suf[R[i]]=max(suf[R[i]],L[i]);
//			debug(i)sp,debug(L[i])sp,debug(R[i])ln;
		}
		for(int i=n;i;i--) suf[i]=max(suf[i],suf[i+1]);
//		rep(i,1,n) debug(i)sp,debug(suf[i])ln;
		rep(i,0,n-1)
		{
			int l=suf[i+1];//debug(i)sp,debug(l)sp;
			if(l>t) ans=min(ans,s+i+i+l+l-t);//,debug(s+i+i+l+l-1)sp;
			else ans=min(ans,s+i+i+t);//,debug(s+i+i+t)sp;
			//debug(ans)ln;
		}
		res=min(res,ans);
	}
	return res;
}
int main()
{
//	freopen("data.in","r",stdin),freopen("std.out","w",stdout);
	scanf("%s",str+1);int n=(int)strlen(str+1);
	rep(i,1,n) a[i]=str[i]-'0';
	scanf("%s",str+1);rep(i,1,n) b[i]=str[i]-'0';
	if(all_zero(b,n)) return !printf(all_zero(a,n)?"0\n":"-1\n");
	int ans=solve(a,b,n);rev(a,n);rev(b,n);ans=min(ans,solve(a,b,n));
	return /*debug(ans)ln,*/!printf("%d\n",ans);
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const long long MOD=1e9+7;
signed main(){
	int n,m;
	cin>>n>>m;
	pair<bool,int> p[110000]={};
	rep(i,m){
		int a;
		string b;
		cin>>a>>b;
		if(b=="AC")p[a-1].first=true;
		else if(p[a-1].first==false)p[a-1].second++;
	}
	int c=0,d=0;
	rep(i,n){
		if(p[i].first){
			c++;
			d+=p[i].second;
		}
	}
	cout<<c<<" "<<d<<endl;
}


Measured memory_bytes: 1920
from collections import deque
while True:
    S = input()
    if S == ".":
        break
    que = deque()
    flag = True
    for s in S:
        if s == "(":
            que.append(1)
        elif s == "[":
            que.append(-1)
        elif s == ")" or s == "]":
            if len(que) <= 0:
                flag = False
                break
            temp1 = -1 if s == ")"else 1
            temp2 = que.pop()
            if temp1 + temp2 != 0:
                flag = False
                break
    if len(que) != 0:
        flag = False

    if flag:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5952
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  
  cin>>n;
  
  if(n<2){
      cout<<"0\n";
      return;
  }
  
  ll ans=pow_mod(10,n);
  
  ans+=pow_mod(8,n);
  
  ans%=mod;
  
  ans-=pow_mod(9,n);
  
  ans+=mod;
  
  ans%=mod;
  
   ans-=pow_mod(9,n);
  
  ans+=mod;
  
  ans%=mod;
  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc *bufio.Scanner

func main() {
	sc = bufio.NewScanner(os.Stdin)

	ans := make([]int, 26)
	for sc.Scan() {
		a := strings.ToLower(sc.Text())
		if a == "" {
			fmt.Printf(a)
			break
		}

		for _, s := range a {
			if 'a' <= s && s <= 'z' {
				ans[s-'a']++
			}
		}
	}
	for i := 0; i < len(ans); i++ {
		fmt.Printf("%s : %d\n", string(i+'a'), ans[i])
	}
}



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

typedef long long int lli;
#define rep(i, a, b) for(lli i  = (lli)(a); i < (lli)(b);i++)
#define rip(i, a ,b) for(lli i  = (lli)(a); i >= (lli)(b);i--)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define trace(x) cerr << #x << ": " << x << endl;

typedef pair<lli, lli> ii;
typedef pair<ii, lli> iii;
typedef vector<lli> vi;
typedef vector<ii> vii;

int main(){
	int n; cin>>n;
	vi v;
	rep(i,0,n){
		 int num; cin>>num;
		 v.pb(num);
	}

	sort(all(v));
	reverse(all(v));
	int sum=v[0]/2;
	rep(i,1,sz(v)){
		sum+=v[i];
	}

	cout<<sum;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;

// ---
const int Nlim = POW_10_5;
int N;
Pair AB[Nlim];

int Ans() {
  sort(AB, AB+N, [](auto &left, auto &right) {
    return left.first + left.second > right.first + right.second;
  });
  int ans = 0;
  REP(i, N) {
    if (i%2 == 0) {
      ans += AB[i].first;
    } else {
      ans -= AB[i].second;
    }
  }
  return ans;
}

signed main() {
  cin >> N;
  REP(i, N) { cin >> AB[i].first >> AB[i].second; }

  auto ans = Ans();

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;
#define b first
#define a second

int N, H;
vector<pair<ll, ll>> K;
vector<ll> s;
ll a_max;

ll check(int n) {
  if (s[n] >= H) {
    return n;
  } else {
    ll rest = H - s[n];
    return n + (rest + a_max - 1) / a_max;
  }
}

void abc085d() {
  sort(K.rbegin(), K.rend());
  s[0] = 0;
  for (int i = 0; i < N; i++) {
    s[i + 1] = s[i] + K[i].b;
  }
  ll res = INF;
  for (int i = 0; i <= N; i++) {
    res = min(res, check(i));
  }

  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> H;
  K.resize(N);
  s.resize(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> K[i].a >> K[i].b;
  }
  a_max = 0;
  for (int i = 0; i < N; i++) {
    a_max = max(a_max, K[i].a);
  }
  abc085d();
  return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 ll r,d,x;
	 cin>>r>>d>>x;

	 for (int i = 0; i < 10; ++i)
	 {
	 	ll t = r*x - d;
	 	cout<<t<<"\n";
	 	x = t;
	 }
	return 0;
}

Measured memory_bytes: 256
h,w,g[10][10],sx,sy,gx,gy;P[11][10][7][7],*a;Q[999][999],N[1000];E(p,x,y,u,s,e){p+=g[x][y]*(7-u);a=P[x][y][u]+s;p<*a?*a=p,Q[p][N[p]++]=x+y*10|u<<8|s<<16|e<<24:0;}main(x,y,p,t,u,s,e){for(;scanf("%d%d",&h,&w)*h;printf("%d\n",p)){for(y=0;y<h;y++)for(x=0;x<w;x++)scanf("%d",g[x]+y);scanf("%d%d%d%d",&sy,&sx,&gy,&gx);memset(P,1,2e4);memset(N,0,4e3);for(*Q[P[sx][sy][*N=1][2]=p=0]=0x3020100+sx+sy*10;;){if(N[p]){t=Q[p][--N[p]];x=t&255,y=x/10,x%=10;if(x==gx&&y==gy)break;u=t>>8&255;s=t>>16&255;e=t>>24&255;x>0&&E(p,x-1,y,e,s,7-u);x<w-1&&E(p,x+1,y,7-e,s,u);y>0&&E(p,x,y-1,s,7-u,e);y<h-1&&E(p,x,y+1,7-s,u,e);}else p++;}}}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node{
  int x;
  struct Node *prev;
  struct Node *next;
};

void insert(int);
void delete(int);
void deleteFirst();
void deleteLast();
void display();
void release();

struct Node head;

int main(void){
  int n;
  char input[20];
  int inputx;

  head.prev = &head;
  head.next = &head;

  scanf("%d", &n);

  while((scanf("%s", input)) != EOF){
    if(strcmp(input, "insert") == 0){
      scanf("%d", &inputx);
      insert(inputx);
    }else if(strcmp(input, "delete") == 0){
      scanf("%d", &inputx);
      delete(inputx);
    }else if(strcmp(input, "deleteFirst") == 0){
      deleteFirst();
    }else if(strcmp(input, "deleteLast") == 0){
      deleteLast();
    }else if(strcmp(input, "display") == 0){
      display();
    }
  }
  release();
  return 0;
}

void insert(int input){
  struct Node *p, *prev, *next;

  p = (struct Node *)malloc(sizeof(struct Node));

  prev = &head;
  next = head.next;
  p->x = input;
  p->prev = prev;
  p->next = next;
  next->prev = p;
  prev->next = p;

  //printf("insert %d\n", input);
}

void delete(int input){
  struct Node *p, *prev;

  prev = &head;

  if(head.next != &head){
    for(p = head.next; p != &head; p = p->next){
      if(p->x == input){
        if(p->next != &head){
          prev->next = p->next;
          p->next->prev = prev;

          //printf("delete %d\n", input);
          free(p);
          return;
        }

        prev->next = &head;
        head.prev = prev;
        //printf("delete %d\n", input);
        free(p);
        return;
      }

      prev = p;
    }
  }
}

void deleteFirst(){
  struct Node *p, *prev;

  prev = &head;
  p = head.next;
  prev->next = p->next;
  p->next->prev = prev;

  //printf("deleteFirst\n");
  free(p);
  return;
}

void deleteLast(){
  struct Node *p, *prev;

  if(head.next == &head){
    return;
  }

  p = head.prev;
  prev = p->prev;
  prev->next = &head;
  head.prev = prev;

  //printf("deleteLast\n");
  free(p);
  return;
}

void display(){
  struct Node *p;

  if(head.next == &head) return;

  for(p = head.next; p->next != &head; p=p->next){
    printf("%d ", p->x);
  }
  printf("%d", p->x);
  printf("\n");
}

void release(){
  struct Node *next, *del;

  next = head.next;

  display();
  while(next != &head){
    del = next;
    next = next->next;

    free(del);
  }
}

Measured memory_bytes: 31788
using System;

public class Test
{
	public static void Main( )
	{
		int n = int.Parse( Console.ReadLine() );
		int tscore = 0;
		int hscore = 0;
		for( var i=0; i<n; i++ ) {
			string[] th = Console.ReadLine().Split( ' ' );
			var res = string.Compare( th[0], th[1] );
			if( res < 0 ) {
				hscore += 3;
			} else if( 0 < res ) {
				tscore += 3;
			} else {
				tscore++;
				hscore++;
			}
		}
		Console.WriteLine( tscore+" "+hscore );
	}
}

Measured memory_bytes: 9960
n = input()
a26 = [0 for _ in range(26)]

for i in range(n):
	s = raw_input()
	b26 = [0 for _ in range(26)]
	for j in range(len(s)):
		b26[ord(s[j]) - 97] += 1
	
	if i == 0:
		a26 = b26
	else:
		for j in range(26):
			a26[j] = min(a26[j], b26[j])

s = ""
for i in range(26):
	for _ in range(a26[i]):
		s += chr(97 + i)

print s

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"

using namespace std;

int main()
{
	
	std::ios_base::sync_with_stdio(false);

	ll n;
	cin>>n;
	ll ma=10000000000000;
	//cout<<n<<endl;
	for(ll i=1;(i*i)<=n;i++)
	{
		if(n%i==0)
		{
			//cout<<i+(n/i)-2<<endl;
			ma=min(ma,i+(n/i)-2);
		}
	}
	cout<<ma;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main(void) {
	int a, b;
	char s[100];
	top = 0;
	while(scanf("%s", s) != EOF) {
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		} else if(s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if(s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}

Measured memory_bytes: 548
def main():
    NT = list(map(int, input().split()))
    N, T = NT[0], NT[1]
    arr = []
    cost = []
    for i in range(N):
        ct = list(map(int, input().split()))
        arr.append(ct)
    for j in range(N):
        if arr[j][1] <= T:
            cost.append(arr[j][0])
    if len(cost) != 0:
        print(min(cost))
    else:
        print("TLE")
main()

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    int x=0;
    int m=0;
    for (auto i:s){
        if (i=='I'){
            x++;
        }else if (i=='D'){
            x--;
        }m=max(m,x);
    }cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <queue>

int main() {
	int sx, sy, tx, ty;
	std::cin >> sx >> sy >> tx >> ty;
	
	std::string ans;

	ans += std::string(tx - sx, 'R');
	ans += std::string(ty - sy, 'U');

	ans += 'U';
	ans += std::string(tx - sx + 1, 'L');
	ans += std::string(ty - sy + 1, 'D');
	ans += 'R';

	ans += std::string(ty - sy, 'U');
	ans += std::string(tx - sx, 'R');

	ans += 'R';
	ans += std::string(ty - sy + 1, 'D');
	ans += std::string(tx - sx + 1, 'L');
	ans += 'U';

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
   int n,av;
   cin>>n>>av;
   int arr[n];
   int i,j,k;
   for(i=0;i<n;i++) cin>>arr[i];
   unsigned long long int dp[n][n+1][n*av+1];
   for(i=0;i<n;i++)
        for(j=0;j<=n;j++)
            for(k=0;k<=n*av;k++)
                dp[i][j][k]=0;

    dp[0][1][arr[0]]=1;
    dp[0][0][0]=1;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=n;j++)
            for(k=1;k<=n*av;k++)
                dp[i][j][k]=dp[i-1][j][k];
        dp[i][0][0]=1;
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n*av;k++)
                if(k>=arr[i])
                    dp[i][j][k]+=dp[i-1][j-1][k-arr[i]];
        }
    }
    unsigned long long int count=0;
    for(i=1;i<=n;i++)
    {
        count+=dp[n-1][i][i*av];
    }
    cout<<count<<endl;
}


Measured memory_bytes: 50048
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll n;
string C;
vector<pll> E;

int main() {
    cin >> C;
    n = sz(C);
    C = '#' + C;
    if (C[1] != '1' || C[n] != '0') return !printf("-1\n");
    for (ll i = 1; i <= n - 1; i++) {
        if (C[i] != C[n - i]) return !printf("-1\n");
    } 
    for (ll i = 1; i <= n - 2; i++) {
        ll ind = i + 1;
        while (C[ind] != '1' && ind < n) ind++;
        for (ll j = i + 1; j < ind; j++) E.push_back({j, ind});
        E.push_back({i, ind});
        i = ind - 1;
    }
    E.push_back({n - 1, n});
    for (auto i : E) cout << i.F << ' ' << i.S << endl;
    return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int H, W;
string s[100];

const int INF = 10000;

int dp[100][100][2]; //! [r][c][0: not flipping, 1: flipping]

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    cin >> H >> W;
    rep(i, H) cin >> s[i];

    rep(r, H) rep(c, W) {
        bool onWhite = (s[r][c] == '.');
        int best = INF;
        if (r) {
            if (c) {
                if (onWhite) {
                    best = min(min(dp[r-1][c][0], dp[r-1][c][1]), min(dp[r][c-1][0], dp[r][c-1][1]));
                } else {
                    best = min(min(dp[r-1][c][0]+1, dp[r-1][c][1]), min(dp[r][c-1][0]+1, dp[r][c-1][1]));
                }
            } else {
                if (onWhite) {
                    best = min(dp[r-1][c][0], dp[r-1][c][1]);
                } else {
                    best = min(dp[r-1][c][0]+1, dp[r-1][c][1]);
                }
            }
        } else {
            if (c) {
                if (onWhite) {
                    best = min(dp[r][c-1][0], dp[r][c-1][1]);
                } else {
                    best = min(dp[r][c-1][0]+1, dp[r][c-1][1]);
                }
            } else {
                best = onWhite ? 0 : 1;
            }
        }
        if (onWhite) {
            dp[r][c][0] = best; 
            dp[r][c][1] = INF; 
        } else {
            dp[r][c][0] = INF; 
            dp[r][c][1] = best; 
        }

        // cout << "dp[" << r << "][" << c << "][0] = " << dp[r][c][0] << ", dp[" << r << "][" << c << "][1] = " << dp[r][c][1] << endl;
    }

    cout << min(dp[H-1][W-1][0], dp[H-1][W-1][1]) << endl;

    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
INF = 1000000007
keta = len(bin(max(A))) - 2
ans = 0
shift = 0
for _ in range(keta):
    num_1 = 0
    for a in A:
        if a>>shift&1:
            num_1 += 1
    ans += num_1 * (N-num_1) * 2 ** shift
    shift += 1
print(ans % INF)

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

int main() {
	int p, q, mi, ans, temp;

	cin >> p >> q;

	mi = (p ,q);

	while (p%q == 0) {
		if (q == 1) break;
		p /= q;
		q /= q;
	}

	for (int i = 2; i * i<= mi; i++) {
		while (p%i == 0 && q%i == 0) {
			p /= i;
			q /= i;
		}
		while (q%(mi/i) == 0 && p%(mi/i) == 0) {
			p /= (mi/i);
			q /= (mi/i);
		}

	}

	ans = 1;


	for (int i = 2; i * i <= q; i++) {
		if (q%i != 0) continue;
		int k = 1;
		if (i != 2){
			for (int j = 3; j * j<= i; j++) {
				if (i%j == 0) {
					k = 0;
					break;
				}
			}
		}
		if (k == 1) ans *= i;
		while (q%i == 0) {
			q /= i;
		}
	}
	ans *= q;

	cout << ans << endl;

	return 0;
}


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

using namespace std;
 
typedef long long ll;

const int INF = 0x3f3f3f3f;


int main()
{

    ll n;
    cin>>n;
    ll arr[n][3];
    for(ll i=0 ; i<n ; i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    ll dp[n+1][3];
    memset(dp,0,sizeof(dp));
    for(ll i=1 ; i<n+1 ; i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i-1][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i-1][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i-1][2];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <fstream>
using namespace std;

int main()
{
	int N,Q;
	string S;
	cin>>N>>Q>>S;

	vector<int> count(N);
	count[0] = 0;
	for(int i=1; i<N; i++)
	{
		count[i] = count[i-1];
		if(S[i-1] =='A' && S[i]=='C')
		{
			count[i]++;
		}
		
	}

	for(int i=0; i<Q; i++)
	{
		int l,r;
		cin>>l>>r;
		cout<<count[r-1]-count[l-1]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1408
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
//#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int N;
	
	cin >> N;
	
	for(int i = 0; i<N;i++){
		int a, b, c;
		cin >> a >> b >> c;
		if(a > b) swap(a, b);
		if(a > c) swap(a, c);
		if(b > c) swap(b, c);
		
		if(a * a + b * b == c * c) cout << "YES" <<endl;
		else cout << "NO" << endl;
		
	}

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int sum=0;
  
  for(int i=0;i<N;i++){
    int l,r,n;
    cin>>l>>r;
    n=r-l+1;
    sum+=n;
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
 
const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;
 
int a[N],n;
 
il bool calc(){
	int tot=0,num;
	rep(i,1,n){
		tot+=(~a[i]&1);
		if(a[i]&1) num=a[i];
	}
	if(tot!=n-1){
		return tot&1;
	}else{
		if(num==1) return tot&1;
		if(~n&1) return true;
		rep(i,1,n) a[i]/=2;
		int g=a[1];
		rep(i,2,n) g=__gcd(a[i],g);
		rep(i,1,n) a[i]/=g;
		return calc()^1;
	}
}
 
int main(){
	scanf("%d",&n);
	int tot=0;
	rep(i,1,n) scanf("%d",a+i),tot+=(~a[i]&1);
	puts(calc()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 100000000
using namespace std;
struct state { int dir, y, x, s; };

int H, W, S[30][30], C[4], dp[30][30][4];
int dd[5] = { 0, 1, 0, -1, 0 };

class Compare {
public:
  bool operator() (struct state a, struct state b) {
    return a.s > b.s;
  }
};

bool isin(int y, int x) {
  return 0 <= y && y < H && 0 <= x && x < W;
}

int main(void) {
  while(cin >> W >> H, H) {
    REP(i, 0, H) REP(j, 0, W) cin >> S[i][j];
    REP(i, 0, 4) cin >> C[i];

    REP(i, 0, H) REP(j, 0, W) REP(k, 0, 4) dp[i][j][k] = INF;

    priority_queue<struct state, vector<struct state>, Compare> q;
    struct state first = { 0, 0, 0, 0 };
    q.push(first);

    while(!q.empty()) {
      struct state c = q.top();
      q.pop();

      dp[c.y][c.x][c.dir] = min(dp[c.y][c.x][c.dir], c.s);
      if(c.y == H - 1 && c.x == W - 1) break;

      REP(i, 0, 4) {
        int dir = (c.dir + i) % 4;
        int w = i == S[c.y][c.x] ? 0 : C[i];
        struct state n = { dir, c.y + dd[dir], c.x + dd[dir + 1], c.s + w };
        if(isin(n.y, n.x) && n.s < dp[n.y][n.x][n.dir]) q.push(n);
      }
    }

    int ans = INF;
    REP(i, 0, 4) ans = min(ans, dp[H - 1][W - 1][i]);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool hai=false,cha=false,mido=false,mizu=false,ao=false,ki=false,tou=false,aka=false;
    int freee=0;

    rep(i,n){
        if(1<=a[i]&&a[i]<=399) hai=true;
        else if(400<=a[i]&&a[i]<=799) cha=true;
        else if(800<=a[i]&&a[i]<=1199) mido=true;
        else if(1200<=a[i]&&a[i]<=1599) mizu=true;
        else if(1600<=a[i]&&a[i]<=1999) ao=true;
        else if(2000<=a[i]&&a[i]<=2399) ki=true;
        else if(2400<=a[i]&&a[i]<=2799) tou=true;
        else if(2800<=a[i]&&a[i]<=3199) aka=true;
        else if(3200<=a[i]) freee++;
    }
    int MIN = 0;
    if(hai) MIN++;
    if(cha) MIN++;
    if(mido) MIN++;
    if(mizu) MIN++;
    if(ao) MIN++;
    if(ki) MIN++;
    if(tou) MIN++;
    if(aka) MIN++;
    if(MIN==0){
        cout << 1 << " " << freee << endl;
        return 0;
    }

    cout << MIN << " " << MIN+freee << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    string s;
    cin>>s;
    ll i,n=s.length();
    ll ans=0;
    for(i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
CP = 4
DP = 7

N = gets.strip.to_i

is_exist = false
((N / CP) + 1).times do |i|
  rem = N - (i * CP)
  if rem >= 0
    if (rem % DP) == 0
      is_exist = true
      break
    end
  else
    break
  end
end
puts is_exist ? 'Yes' : 'No'


Measured memory_bytes: 1788
import java.io.*;
import java.util.*;
import java.math.*;

public class Main implements Runnable {
	private static BufferedReader in;
	private static PrintWriter out;
	private static StringTokenizer st;
	private static Random rnd;

	private void solve() throws IOException {
		final int maxBottle = 8;
		long[] costs = new long[maxBottle + 1];
		Arrays.fill(costs, Long.MAX_VALUE / 2);
		costs[0] = 0;
		costs[1] = nextLong();
		costs[2] = nextLong();
		costs[4] = nextLong();
		costs[8] = nextLong();
		boolean updated = true;
		while (updated) {
			updated = false;
			for (int a = 1; a <= maxBottle; a++) {
				for (int b = 1; a + b <= maxBottle; b++) {
					long candidate = costs[a] + costs[b];
					if (candidate < costs[a + b]) {
						updated = true;
						costs[a + b] = candidate;
					}
				}
			}
		}
		//out.println(Arrays.toString(costs));
		long weight = nextLong() * 4;
		long result = (weight / maxBottle) * costs[maxBottle] + costs[(int) (weight % maxBottle)];
		out.println(result);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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

X,Y=map(int,input().split())
mod=10**9+7

if (X+Y)%3!=0:
    print(0)
    sys.exit()

k=(X+Y)//3
X-=k
Y-=k

if X<0 or Y<0:
    print(0)
    sys.exit()

FACT=[1]
for i in range(1,2*10**6+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

print(Combi(X+Y,X))


Measured memory_bytes: 128000