akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g)
{
    for (int i = g; i < n; i++)
    {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v)
        {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    for (int h = 1;;)
    {
        if (h > n)
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--)
    {
        insertionSort(A, n, G[i]);
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--)
    {
        printf("%d", G[i]);
        if (i)
            printf(" ");
    }
    printf("\n");
    printf("%lld\n", cnt);
    for (int i = 0; i < n; i++)
        printf("%d\n", A[i]);

    return 0;
}


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

typedef long long LL;

const double PI = acos(-1.0);

int a, b;

int work() {

    scanf("%d%d", &a, &b);

    if ((a+b) % 2 == 1) printf("IMPOSSIBLE");
    else printf("%d\n", (a+b)/2);
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    while(true) {
        val (n, x) = readLine()!!.split(' ').map { it.toInt() }
        if (n == 0 && x == 0) break
        var ans = 0
        for (i in 1..x-3) {
            for (j in i+1..x-2) {
                if (x - (i+j) in (j+1)..n) ans++
                if (i+j > x) break
            }
        }
        println(ans)
    }
}



Measured memory_bytes: 31972
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int d[110];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];
  
  set<int> values;
  for (int i = 0; i < N; i++) {
    values.insert(d[i]);
  }

  cout << values.size() << endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int read(){
	int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
    return f*x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	int n=read();
	if(n<3||log2(n)==int(log2(n))){
		puts("No");
		return 0;
	}
	if(n%2!=0){
		puts("Yes");
		for(int i=2;i<=n;i+=2)
			printf("%d %d\n%d %d\n%d %d\n%d %d\n",1,i+n,1,i+1,i+n,i+1+n,i,i+1);
		printf("%d %d\n",2,n+1);
	}
	else{
		puts("Yes");
		for(int i=2;i<n;i+=2)
			printf("%d %d\n%d %d\n%d %d\n%d %d\n",1,i+n,1,i+1,i+n,i+1+n,i,i+1);
		printf("%d %d\n",2,n+1);
		int a=(n&-n),b=2*n-a;a++;
		printf("%d %d\n%d %d\n",n,a,2*n,b);
	}
    return 0;
}


Measured memory_bytes: 2304
//
// Created on 2020/04/12.
//


#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }
    return gcd(b,a %b);
}

int main() {
    ll ans = 0;
    ll k;
    cin>>k;
    for (ll i = 1; i <= k; ++i) {
        for (ll j = 1; j <= k; ++j) {
            for (ll l = 1; l <= k; ++l) {
                ans += gcd(i,gcd(j,l));
            }
        }
    }

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


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

int main(){
  ll x, k, d;
  cin >> x >> k >> d;  
  ll ans;

  if(x<0)x = -x;
  if(x/k>=d){
    ans = x-k*d;
  }else{
    ll tmp = x/d;
    if((k-tmp)%2==0){
      ans = x%d;
    }else{
      ans = d-x%d;
    }
  }
  
  if(ans<0)ans = -ans;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(){
	int a,b;
	char t;
	for(;;){
		scanf("%d %c %d",&a,&t,&b);
		if(t=='?') break;
		if(t=='+') a+=b;
		if(t=='-') a-=b;
		if(t=='*') a*=b;
		if(t=='/') a/=b;
		printf("%d\n",a);
	}
	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	char* S = (char*)calloc(4,sizeof(char));;
	cin >> S;
	
	int flg = 0;
	int count = 0;
	
	rep(i, 3){
		if(S[i] == 'R'){
			if(flg) count++;
			else{
				flg = 1;
				count = 1;
			}
		}
		else flg = 0;
	}

	cout << count << endl;
	
}

Measured memory_bytes: 3584
import numpy as np

N,M = map(int,input().split())
data = []
for i in range(N):
    b = list(map(int,input().split())) # data = [[cost,max_num],...]
    data.append(b)
# print(data)

# N=2 
# M=5
# data = [[4, 9], [2, 4]]
# data.sort()
# npsorted = np.sort(np.array(data),axis=0)
data.sort()

num_drink=0
cost=0
shop_index=0
while (shop_index < N and num_drink < M):
    num_drink += data[shop_index][1]
    cost += data[shop_index][0]*data[shop_index][1]
    shop_index += 1

# num_drink >= M by buying data[shop_index-1][0]yen drink from shop_index
excess = num_drink - M
ans = cost - data[shop_index-1][0] * excess
print(ans)
# print(data)


Measured memory_bytes: 36828
#include <stdio.h>
#include <string.h>

#define M 100000

typedef struct{
  int value;
  char word[5];
  int mem;
}data;

int partition(data *,int,int);
void quickSort(data *,int,int);
int hantei(data *,data *,int);

int main(){
  data seq_ori[M],seq_qui[M];
  int len;
  int i;

  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf(" %s %d",seq_ori[i].word,&seq_ori[i].value);
    seq_ori[i].mem=i;
    seq_qui[i]=seq_ori[i];
  }
  
  quickSort(seq_qui,0,len-1);
  
  if(hantei(seq_qui,seq_ori,len)) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<len;i++) printf("%s %d\n",seq_qui[i].word,seq_qui[i].value);
  
  return 0;
}

int partition(data *A,int p,int r){
  int x;
  int i,j;
  data temp;
  
  x=A[r].value;
  i=p-1;
  for(j=p;j<r;j++){
    if (A[j].value <= x){
      i = i+1;
      //A[i] と A[j] を交換
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  //A[i+1] と A[r] を交換
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  
  return i+1;
}

void quickSort(data *seq_qui,int p ,int r){
  int q;
  if( p < r){
    q = partition(seq_qui, p, r);
    quickSort(seq_qui, p, q-1);
    quickSort(seq_qui, q+1, r);
  }
}

int hantei(data seq[],data seqo[],int len){
  int i,cnt=0;
  for(i=0;i<len;i++){
    if((seq[i].value == seq[i+1].value)
       && (seq[i].mem > seq[i+1].mem)) return 0;
    }
  //seq[i].word!=seqo[i].word ok
  return 1;
}




Measured memory_bytes: 4868
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int N;
    int Apre, Apost;
    long long ans = 0;


    cin >> N;
    cin >> Apre;
    for (int i = 1; i < N; i++) {
        cin >> Apost;
        if (Apre > Apost) {
            ans += Apre - Apost;
            Apre = Apre;
        }
        else {
            Apre = Apost;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

int gcd(int a, int b){ // 最大公約数　ユークリッドの互除法　a > b
	if(b == 0)
		return a;
	else
		return gcd(b, a%b);
}
 
int main(void){
	
	int N, ans = 1000000000;
	
	cin >> N;
	
	rep(i, N){
		int a;
		cin >> a;
		if(i == 0)
			ans = a;
		else
			ans = gcd(max(a, ans), min(a, ans));
	}
	
	cout << ans;
	
	return 0;
}

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

long long int loop(long long int h) {
    if (h != 1) {
        return 2*loop(h/2)+1;
    } else {
        return 1;
    }
}

int main(void) {
    long long int h;
    scanf("%lld", &h);

    printf("%lld\n", loop(h));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct E{int to,co,ti;};
struct P{int tim,idx,res;};
bool operator <(const P &a,const P &b){return a.tim>b.tim;}
int ans[50][5001],c[50],d[50],fans[50],n,m,s;
vector<E> edge[50];
priority_queue<P> que;

signed main(){
  memset(ans,-1,sizeof(ans));
  memset(fans,-1,sizeof(fans));
  cin>>n>>m>>s;
  while(m--){
    int u,v,a,b;cin>>u>>v>>a>>b;u--;v--;
    edge[u].push_back({v,a,b});
    edge[v].push_back({u,a,b});
  }
  for(int i=0;i<n;i++)cin>>c[i]>>d[i];
  que.push({0,0,min(5000LL,s)});
  while(que.size()){
    P p=que.top();que.pop();
    if(~ans[p.idx][p.res])continue;
    ans[p.idx][p.res]=p.tim;
    if(!~fans[p.idx])fans[p.idx]=p.tim;
    for(E q:edge[p.idx])
      if(p.res>=q.co&&!~ans[q.to][p.res-q.co])
        que.push({p.tim+q.ti,q.to,p.res-q.co});
    if(p.res+c[p.idx]<=5000)que.push({p.tim+d[p.idx],p.idx,p.res+c[p.idx]});
  }
  for(int i=1;i<n;i++)cout<<fans[i]<<endl;
}


Measured memory_bytes: 17468
def getIntList(strList):
  return list(map(lambda x: int(x), strList))

N, M, K = getIntList(input().split(" "))
A = getIntList(input().split(" "))
B = getIntList(input().split(" "))

ta = 0
tb = 0
TA = [0]
TB = [0]

for i in range(len(A)):
  ta += A[i]
  if ta <= K:
    TA.append(ta)
  else:
    break
for j in range(len(B)):
  tb += B[j]
  if tb <= K:
    TB.append(tb)
  else:
    break

Cij = [0]

j = len(TB) - 1
for i in range(len(TA)):
  while TA[i] + TB[j] > K:
    j += -1
  else:
    if j >= 0:
      Cij.append(i + j)
  if j == -1:
    break


print(max(Cij))


Measured memory_bytes: 49964
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 25
using namespace std;
int n,a[M],b[M],c[M],ra[M];
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n) {
            scanf("%d", &a[i]);
            ra[a[i]] = i;
        }
        REP(i,1,n) {
            scanf("%d", &b[i]);
        }
        REP(i,1,n-1) scanf("%d", &c[i]);

        int ans = 0;
        REP(i,1,n) {
            int ifr = -1;
            if (i>1) ifr = a[i-1];
            int id = a[i];
            ans += b[id];

            if (ifr==id-1) ans += c[ifr];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, m;
    cin >> n >> m;

    bool isac[100100] = {0};

    int wacnt[100100] = {0};

    for(int i = 0; i < m; i++){
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "WA"){
            if(!isac[p])wacnt[p]++;
        } else {
            isac[p] = 1;
        }
    }
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < n; i++){
        if(isac[i]){
            ans1++;
            ans2 += wacnt[i];
        }
    }

    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

ll n,k;
vector<ll> A;
ll ans;
vector<ll> bun(int l, int r, bool isL){
	vector<ll> ret;
	if(r-l == 1){
		if(A[l] >= 0) ans++;
		ret.push_back(A[l]);
		return ret;
	}

	vector<ll> left,right;
	left = bun(l, (l+r)/2, true);
	right = bun((l+r)/2, r, false);
	sort(all(left));sort(all(right));reverse(all(left));
	int li=0, ri=0;
	while(li < left.size()){
		while(ri < right.size() && left[li] + right[ri] < 0) ri++;
		ans += right.size() - ri;
		li++;
	}

	if(isL){
		for(int i=r-1; i>=l; i--){
			if(i==r-1){
				ret.push_back(A[i]);
			}else{
				ret.push_back(A[i] + ret.back());
			}
		}
	}else{
		for(int i=l; i<r; i++){
			if(i==l){
				ret.push_back(A[i]);
			}else{
				ret.push_back(A[i] + ret.back());
			}
		}
	}
	return ret;
}


int main(void){
	ans = 0;
	cin>>n>>k;
	
	rep(i,n){
		ll a;cin>>a;
		A.push_back(a-k);
	}
	bun(0, n, true);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int a,b;
  cin>>a>>b;
  int sum=6;
  cout<<sum-a-b<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double dp[3000][3000],p[3000];

double probablity(int j, int h)
{
	if(j==0)
	{
		if(h==1)
			return p[0];
		else if(h==0)
			return (1-p[0]);
		else
			return 0;
	}
	if(dp[j][h]==-1)
	{
		if(h==0)
			dp[j][h] = (1-p[j])*probablity(j-1,h);
		else
			dp[j][h] = (1-p[j])*probablity(j-1,h) + p[j]*probablity(j-1,h-1);
	}
	return dp[j][h];
}
int main()
{
	double n;
	cin>>n;

	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
	}
	for (int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= n ;j++)
		{
			dp[i][j] = -1;
		}
	}
	double ans = 0;
	for (int i = n/2+1; i <= n; ++i)
	{
		ans += probablity(n-1,i);
	}
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70784
S=input()
l=len(S)
ans=int(S[-1])*2**(l-1)
for i in range(1,l):
    a=int(S[-i-1])
    for j in range(i+1):
        ans+=a*10**j*2**(l-min(j,i-1)-2)
print(ans)

Measured memory_bytes: 9128
s = input()

if s[0] != "A":
    print("WA")
elif s[1] == "C" or s[-1] == "C":
    print("WA")
elif "C" not in s:
    print("WA")
elif s.count("C") > 1:
    print("WA")
elif s.replace('A', 'a').replace("C", "c") != s.lower():
    print("WA")
else:
    print("AC")

Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; ll s[SZ];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",s+i),s[i]+=s[i-1];
	map<ll,ll> m;
	for(int i=0;i<=n;++i) ++m[s[i]];
	ll ans=0;
	for(auto t:m)
		ans+=t.se*(t.se-1)/2;
	cout<<ans<<"\n";
}

Measured memory_bytes: 14336
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(ai);
            var answer = ai[ai.Length - 1] - ai[0];
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
N=int(input())
H=['']*N
W=['']*N
x=[]
for i in range(N):
    H[i]=list(map(int,input().split()))
for j in range(N):
    W[j]=list(map(int,input().split()))
for k in range(1,1024):
    t=[]
    for ii in range(10):
        if k&(1<<ii):
            t+=[1]
        else:
            t+=[0]
    ans=0
    for jj in range(N):
        s=0
        for kk in range(10):
            s+=H[jj][kk]*t[kk]
        ans+=W[jj][s]
    x.append(ans)
print(max(x))    

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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


	multiset<int> x, y;
	int n;
	cin >> n;
	rep(i,n) {
		int a;
		cin >> a;
		if (a >= 0) {
			x.insert(a);
		}
		else {
			y.insert(a);
		}
	}

	vector<pair<int, int>> ans;
	int val = -1;

	if (x.empty()) {
		int ma = *y.rbegin();
		y.erase(--y.rbegin().base());
 		while (y.size() > 0) {
			int a = *y.begin();
			y.erase(y.begin());
			ans.emplace_back(ma, a);
			ma -= a;
		}
		val = ma;
	}
	else if (y.empty()) {
		int mi = *x.begin();
		x.erase(x.begin());

		while (x.size() > 1) {
			int a = *x.begin();
			x.erase(x.begin());
			ans.emplace_back(mi, a);
			mi -= a;
		}
		ans.emplace_back(*x.begin(), mi);
		val = *x.begin() - mi;
	}
	else {
		int minus = *y.begin();
		y.erase(y.begin());
		while (x.size() > 1) {
			int a = *x.begin();
			x.erase(x.begin());
			ans.emplace_back(minus, a);
			minus -= a;
		}
		y.insert(minus);

		int plus = *x.begin();
		while (y.size() > 0) {
			int a = *y.begin();
			y.erase(y.begin());
			ans.emplace_back(plus, a);
			plus -= a;
		}
		val = plus;
	}


	cout << val << endl;
	for (auto p : ans) {
		cout << p.first << ' ' << p.second << endl;
	}


	return 0;
}

Measured memory_bytes: 7416
#include <stdio.h>

int main(){


  int i,j,n,a,b,x,A[101][101];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){

      A[i][j]=0;

    }
  }

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

    scanf("%d%d",&a,&x);

    while(x!=0){
      scanf("%d",&b);

      A[i][b-1]=1;

      x--;

    }

  }
    for(i=0;i<n;i++){
      for(j=0;j<n-1;j++){

	printf("%d ",A[i][j]);

      }
      printf("%d\n",A[i][n-1]);

    }

    return 0;

}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;




int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);

    ll ans=0;
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ll a;
        cin>>a;
        if(a&1)
        {
            if(i&1) ans++;
        }
    }
    cout<<ans<<nn;




}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678;

long a, b, c;

int main(){
	scanf("%ld %ld %ld", &a, &b, &c);
	if(a == b && b == c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


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


int c(int x)
{
    int m = 0, t = 0, ret = 0;
    while(m <= x)
    {
        ret++;
        t++;
        m+=t;
    }
    return ret-1;
}

void solve()
{
    ll n;
    cin >> n;
    ll ogn = n;
    ll cnt = 0, twos = 0;

    while(n%2==0)
    {
        twos++;
        n/=2;
    }
    cnt += c(twos);

    for(ll i = 3; i<1000010; i+=2)
    {
        twos = 0;
        while(n%i==0)
        {
            twos++;
            n/=i;
        }
        cnt += c(twos);
    }
    if(n>1)
        cnt++;
    cout << cnt << endl;
}


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


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	int n,k;
	cin>>n>>k;
	int sum=0;
	while(k--){
		int a;
		cin>>a;
		sum+=a;
	}
	if(sum<n) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong p[200005];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    llong minv = 1ll << 60ll;
    llong ans = 0;

    for (int i = 0; i < n; i++) {
        if (minv >= p[i]) ans++;
        minv = min(minv, p[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)

typedef unsigned long long ull;

int main(){
	int n; cin>>n;
	FOR(i,n){
		int x,y;
		scanf("%d:%d",&x,&y);
		double h = (x * 60 + y) / (60.0 * 12) * 360.0;
		double m = y * 6.0;
		double df = abs(h-m);
		df = min(df,360-df);
		if(df < 30) puts("alert");
		else if(df >= 90) puts("safe");
		else puts("warning");
	}

	return 0;
}

Measured memory_bytes: 1200
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum= 0;
        //int len = 4000000;
        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        BitSet bs = new BitSet(sum+1);
        bs.set(sum);
        for(int i=0;i<n;i++){
            BitSet cur = bs.get(a[i],sum+1);
            bs.or(cur);
        }
        int ini = sum%2==0?sum/2:(sum+1)/2;
        for(int i=ini;i<=sum;i++){
            if(bs.get(i)){
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 271452
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n)
  vpll A(n);
  
  FOR(i,0,n){
    ci(A[i].fi);
    A[i].se=n/(i+1);
  }
  
  vll B(n);
  ll now=0;
  
  for(ll i=n-1;i>=0;i--){
      ll sum=0;
    
      FOR(j,1,1+A[i].se){
        sum+=B[(i+1)*j-1];
      }
      
      if(sum%2!=A[i].fi){
        B[i]++;
        now++;
      }
      
    }
  
  co(now)
    
    FOR(i,0,n){
    if(B[i]!=0){
    cout<<i+1<<" ";
    }
  }
  cout<<" "<<endl;
}

Measured memory_bytes: 5504
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int INF = 1e9;
const int N = 20;

string field[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust\n";
    else cout << "win\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
//#include "toollib.h"
#pragma warning (disable:4018)
using namespace std;

void swap_element(vector<int>* ary, int i, int j) {
	int pass;
	pass = (*ary)[i];
	(*ary)[i] = (*ary)[j];
	(*ary)[j] = pass;
}

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	cout << a[0];
	for (int k = 1; k < N; k++) cout << " " << a[k];
	cout << endl;

	for (int i = 1; i < N; i++) {
		for (int j = i; j > 0; j--) {
			if (a[j - 1] > a[j]) swap_element(&a, j - 1, j);
			else break;
		}
		cout << a[0];
		for (int k = 1; k < N; k++) cout << " " << a[k];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int x;
    REP(i, 5){
        cin >> x;
        if (x == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const int OO = 1e9 + 7;
using namespace std;
ll n, a[N], k;
ll dp[N];

ll solve(int i) {
    if (i == n - 1) re 0;
    if (i > n - 1) re OO;
    ll &res = dp[i];
    if (~res) re res;
    res = abs(a[i + 1] - a[i]) + solve(i + 1);
    if (i < n - 2) {
        forr(j, 2, k) {
            res = min(res, abs(a[i + j] - a[i]) + solve(i + j));
        }
    }
    re res;
}

int main() {
    IO;
    cin >> n >> k;
    rep(i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);


}



Measured memory_bytes: 39296
#include<iostream>
    #include<string>
    using namespace std;
    int main()
     
    {
      string N;
      cin>>N;
      if((N[0]==N[1] && N[1]==N[2]) ||(N[1]==N[2] && N[2]==N[3]))
        {
          cout<<"Yes"<<endl;
        }else{
        cout<<"No"<<endl;
      }
      return 0;
    }

Measured memory_bytes: 256
from collections import deque


def main():
    from sys import stdin
    readline = stdin.readline

    from builtins import max, min, range

    INF = 10 ** 6

    H, W = map(int, readline().split())
    Ch, Cw = map(lambda x: int(x) - 1, readline().split())
    Dh, Dw = map(lambda x: int(x) - 1, readline().split())
    S = [readline()[:-1] for _ in range(H)]

    t = [[INF] * W for _ in range(H)]
    for h in range(H):
        th = t[h]
        Sh = S[h]
        for w in range(W):
            if Sh[w] == '#':
                th[w] = -1

    t[Ch][Cw] = 0
    q = deque([(Ch, Cw)])
    a = 0
    warpq = []
    while q:
        while q:
            h, w = q.popleft()
            warpq.append((h, w))
            if h - 1 >= 0 and t[h - 1][w] > a:
                q.append((h - 1, w))
                t[h - 1][w] = a
            if h + 1 < H and t[h + 1][w] > a:
                q.append((h + 1, w))
                t[h + 1][w] = a
            if w - 1 >= 0 and t[h][w - 1] > a:
                q.append((h, w - 1))
                t[h][w - 1] = a
            if w + 1 < W and t[h][w + 1] > a:
                q.append((h, w + 1))
                t[h][w + 1] = a

        if t[Dh][Dw] != INF:
            break

        a += 1
        for h, w in warpq:
            for i in range(max(0, h - 2), min(H, h + 3)):
                ti = t[i]
                for j in range(max(0, w - 2), min(W, w + 3)):
                    if ti[j] > a:
                        ti[j] = a
                        q.append((i, j))
        warpq.clear()

    if t[Dh][Dw] == INF:
        print(-1)
    else:
        print(t[Dh][Dw])


main()


Measured memory_bytes: 23284
def solve(n, m):
    h = [0]
    for i in range(n):
        h.append(int(input()) + h[-1])
    w = [0]
    for j in range(m):
        w.append(int(input()) + w[-1])
    D = {}
    for i in range(n + 1):
        for j in range(m + 1):
            s = h[i] + w[j]
            if s in D:
                D[s] += 1
            else:
                D[s] = 1
    ans = 0
    for key, value in D.items():
        ans += value * (value - 1) / 2
    return print(int(ans))
while True:
    n, m = map(int,input().split())
    if (n, m) == (0, 0):
        break
    solve(n,m)



Measured memory_bytes: 64364
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
char s[100005];
int main(){
	scanf("%s",s);
	puts(strstr(s,"AC")?"Yes":"No");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  int n,m,l,s,A[100][100],c[100],a,i,j;
  a=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++){
  for(j=0;j<m;j++){
    scanf("%d",&l);
    A[i][j]=l;
  }
 }
for(j=0;j<m;j++){
  scanf("%d",&s);
  c[j]=s;
 }
for(i=0;i<n;i++){
  for(j=0;j<m;j++){
    a += A[i][j]*c[j];
  }
  printf("%d\n",a);
  a=0;
 }
return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M, N, l, i=0;
  double sum;
  cin >> N >> M;
  int  A[N];
  
  while(cin>>l){
    A[i] = l;
    i++;
  }
  sort(A, A+N, greater<>());
 // for(i=0;i<N;i++)	cout << "A" << i << "=" << A[i] <<endl;
  
  sum = accumulate(A, A+N, 0.0);
    
  if(A[M-1] >= (sum/4/M))	cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int m,f,r,i;
    for(i=0;i < 50;i++){
        scanf("%d %d %d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1)break;
        if(m == -1 || f == -1){
            printf("F\n");
        }else if(m + f >= 80){
            printf("A\n");
        }else if(m + f >=65 && m + f < 80){
            printf("B\n");
        }else if(m + f>=50&&m + f<65){
            printf("C\n");
        }else if(m + f>=30&&m + f <50 && r >= 50){
            printf("C\n");
        }else if(m + f>=30&&m + f <50 && r < 50){
            printf("D\n");
        }else if(m + f <30){
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2068
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  string s;cin>>s;
  char mi='{';
  rep(i,0,n)chmin(mi,s[i]);
  if(k>=60){
    cout<<string(n,mi)<<endl;
    return 0;
  }
  string s2=s+string(ALLR(s));
  string ret="{";
  rep(i,0,n+1){
    string p=s2.substr(i,n);
    if(k==1){
      chmin(ret,p);
      continue;
    }
    if(p.back()!=mi)continue;
    ll cnt=0;
    rrep(i,0,n){
      if(p[i]==mi)cnt++;
      else break;
    }
    p=p.substr(0,n-cnt);
    reverse(ALL(p));
    rep(_,0,k-1)cnt=min(cnt*2,n);
    chmin(ret,string(cnt,mi)+p.substr(0,n-cnt));
  }
  cout<<ret<<endl;
  return 0;
}

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

int main()
{
	int n, i, x, y, h , w, s, fee;
	while (cin>>n, n) {
		fee = 0;
		for (i = 0; i < n; i++) {
			cin>>x>>y>>h>>w;
			s = x+y+h;
			if (s<=60&&w<=2) fee += 600;
			else if (s<=80&&w<=5) fee += 800;
			else if (s<=100&&w<=10) fee += 1000;
			else if (s<=120&&w<=15) fee += 1200;
			else if (s<=140&&w<=20) fee += 1400;
			else if (s<=160&&w<=25) fee += 1600;
		}
		cout<<fee<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
  int n,m,a,b,i,j,s=0,max=0,d[50][100010]={};
int main(){
  scanf("%d %d",&n,&m);
  while(n--){
    scanf("%d %d %d",&a,&i,&j);
    d[j-1][a-1]++;
    d[j-1][i]--;
  }
  for(i=0;i<100005;i++){
    for(j=s=0;j<m;j++){
      d[j][i+1]+=d[j][i];
      s+=d[j][i]?1:0;
    }
    if(max<s)max=s;
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 12416
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
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 T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct edge{
  int to, rev;
  int64_t cap;
  edge(int t=0, int64_t c=0, int r=0):to(t), cap(c), rev(r) {}
};

struct max_flow {
  vector<vector<edge> > G;
  vector<int> level, iter;
  int n;
  max_flow(int n=0):n(n), G(n), level(n), iter(n) {}
  inline void add(int from, int to, int64_t cap) {
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size()-1);
  }
  void bfs(int s) {
    for(int i = 0; i < n; i++) level[i] = -1;
    queue<int> que;
    level[s] = 0;
    que.emplace(s);
    while(!que.empty()) {
      int now = que.front();
      que.pop();
      for(edge &e:G[now]) {
        if(e.cap > 0 and level[e.to] < 0) {
          level[e.to] = level[now] + 1;
          que.emplace(e.to);
        }
      }
    }
  }
  int64_t dfs(int v, int t, int64_t f) {
    if(v == t) return f;
    for(int &i = iter[v]; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if(e.cap > 0 and level[v] < level[e.to]) {
        int64_t d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int64_t Dinic(int s, int t) {
    int64_t flow = 0;
    while(true) {
      bfs(s);
      if(level[t] < 0) return flow;
      for(int i = 0; i < n; i++) iter[i] = 0;
      int64_t f;
      while((f = dfs(s, t, INT64_MAX)) > 0) flow += f;
    }
  }
};


//head

int n;
ll sum;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  max_flow mfl(n+2);
  const int s = n, t = n+1;
  rep(i, n) {
    int a;
    cin >> a;
    sum += max(a, 0);
    if(a > 0) {
      mfl.add(s, i, a);
    }
    if(a < 0) {
      mfl.add(i, t, -a);
    }
  }
  rep(i, n/2) {
    for(int j = i*2+1; j < n; j += i+1) {
      mfl.add(j, i, LINF);
    }
  }
  cout << sum - mfl.Dinic(s, t) << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   if(n&1)
   {
       cout<<"No";
       return 0;
   }
   
   string s1 = s.substr(0,n/2);
   s1+=s1;
   if(s1 == s)
        cout<<"Yes";
   else cout<<"No";        
   
   return 0;
}  
   

Measured memory_bytes: 256
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);

	static class D{
		public D(int a,int b){
			this.a=a;
			this.b=b;
		}
		int a,b;
	}
	public static void main(String[] $){
		int n=s.nextInt();
		
		ArrayList<D>l=new ArrayList<>();
		for(int i=0;i<n;++i)
			l.add(new D(s.nextInt(),s.nextInt()));
		
		l.sort(Comparator.<D>comparingInt(o->-o.a-o.b));
		
		long t=0,a=0;
		for(int i=0;i<n;++i) {
			if(i%2==0)
				t+=l.get(i).a;
			else
				a+=l.get(i).b;
		}
		System.out.println(t-a);
	}
}

Measured memory_bytes: 65344