akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n,k;
    string s;
    cin >> n >> k >> s;
    ll sum = 0;
    rep(i,n-1){
        if(s[i] == s[i+1]) sum++;
    }
    ll ans = sum + k*2;
    if(ans >= n) ans = n-1;
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	int n;
	while(scanf("%d",&n) != EOF){
		int a=0,b=0,c=0,d=0;
		int sum=0,count=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						sum=a+b+c+d;
						if(sum == n)
							count++;
				}
			}
		}
	}
	printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, m;

int main() {
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int INF = (int)1e9;
const int N = 15;
const int M = (1 << N) + 5;
int g[N][N];
int n;
int a[N][M];
int dp[2][M][N];

void read()
{
    int m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int v, u, w;
        scanf("%d%d%d", &v, &u, &w);
        v--;u--;
        g[v][u] = g[u][v] = w;
    }
}

void precalc()
{
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int v = 0; v < n; v++) {
            if ((mask >> v) & 1) {
                a[v][mask] = INF;
                continue;
            }
            a[v][mask] = 0;
            for (int u = 0; u < n; u++) {
                if (((mask >> u) & 1) == 0) continue;
                a[v][mask] += g[v][u];
            }
        }
    }
}

void brute(int v, int our, int cost, int mask, int V) {
    if (v == n) {
        dp[0][mask | our][V] = min(dp[0][mask | our][V], cost);
        return;
    }
    brute(v + 1, our, cost, mask, V);
    if ((mask >> v) & 1) return;
    if (v == V) return;
    brute(v + 1, our | (1 << v), cost + a[v][mask], mask, V);
    return;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    read();
    precalc();

    for (int mask = 0; mask < (1 << n); mask++)
        for (int v = 0; v < n; v++)
            dp[0][mask][v] = dp[1][mask][v] = INF;
    dp[1][0][0] = 0;

    for (int mask = 0; mask < (1 << n); mask++) {
        
        for (int v = 0; v < n; v++) {
            if (dp[0][mask][v] == INF) continue;
            for (int u = 0; u < n; u++) {
                if ((mask >> u) & 1) continue;
                if (g[v][u] == 0) continue;
                dp[1][mask][u] = min(dp[1][mask][u], dp[0][mask][v] + a[u][mask] - g[v][u]);
            }
        }

        for (int v = 0; v < n; v++) {
            if (dp[1][mask][v] == INF) continue;
            brute(0, 1 << v, dp[1][mask][v], mask, v);
        }

    }

    printf("%d\n", dp[0][(1 << n) - 1][n - 1]);

    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
using namespace std;
const int N=55,p=1e9+7;
int n,x;
char s[N],t[N];
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	int ans=3;
	for (int i=1;i<=n;++i) if (s[i]!=t[i]){
		ans=1ll*ans*(s[i-1]==t[i-1]?2:3)%p,++i;
	}else{
		if (i>1&&s[i-1]==t[i-1]) ans=ans*2%p;
	}
	printf("%d",ans);
	return 0;
}

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

#define ll long long
int main() {
  
  ll N;
  cin >> N;
  
  vector<ll> A(2 * N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[N+i] = A[i];
  }
  
  ll odd= 0, even = 0;
  for (int i = 0; i < N/2; i++) {
    odd += A[2 * i + 1];
    even += A[2 * i];    
  }
  
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
  }
  sum /= 2;
  
  cout << 2 * (sum - odd) << " "; // x1のみ
  
  for (int i = 2; i <= N; i++) {
    if (i % 2) {
      odd -= A[i-2];
      odd += A[i+(N/2 - 1)* 2];
      cout << 2 * (sum - odd) << " ";
    } else {
      even -= A[i-2];
      even += A[i+(N/2 - 1) * 2];
      cout << 2 * (sum - even) << " ";
    }
    
  }
  
}

Measured memory_bytes: 2816
package main

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

func main() {

	alpha_counter := make(map[rune]int)
	in_string := ""
	scanner := bufio.NewScanner(os.Stdin)

	for {
		if scanner.Scan() == false {
			break
		}
		in_string += scanner.Text()
	}

	for _, r := range in_string {

		if ('A' <= r) && (r <= 'Z') {
			r += 'a' - 'A'
		}

		if ('a' <= r) && (r <= 'z') {
			alpha_counter[r] += 1
		}
	}

	for i := 'a'; i <= 'z'; i++ {
		v, _ := alpha_counter[i]
		fmt.Printf("%c : %d\n", i, v)
	}
}



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

int main()
{
    int N, K, R, S, P; string T;
    cin >> N >> K >> R >> S >> P >> T;

    long sum = 0;
    bool isLose[100010] = { false };
    for (int i = 1; i <= N; i++) {
        if (isLose[i]) continue;

        int next = i + K;
        if (next <= N && T[i-1] == T[next-1]) isLose[next] = true;

        if (T[i-1] == 'r') sum += P;
        else if (T[i-1] == 's') sum += R;
        else sum += S;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll are=1000000007;

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<ll>> a(8,vector<ll>(0));
    ll y,t,u;
    rep(i,n){
        cin >> y >> t >> u;
        rep(j,8){
            ll yy,tt,uu;
            if (j>=4) yy=y;
            else yy=y*(-1);
            if (j%4==0 || j%4==1) tt=t;
            else tt=t*(-1);
            if (j%2==0) uu=u;
            else uu=u*(-1);
            a.at(j).push_back(yy+tt+uu);
        }
    }
    rep(i,8){
        sort(a.at(i).begin(),a.at(i).end());
        reverse(a.at(i).begin(),a.at(i).end());
    }
    ll ans=0;
    rep(i,8){
        ll o=0;
        rep(j,m){
            o+=a.at(i).at(j);
        }
        ans=max(o,ans);
    }
    cout << ans << endl;
}


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

typedef long long           ll;
typedef vector < int >      vi;
typedef vector < ll >       vll;
typedef pair < int, int >   pii;
typedef pair < ll, ll >     pll;
typedef set<int>            sset;
typedef multiset<ll>        mset;

#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            a/gcd(a,b)*b
#define pb                  push_back
#define mp                  make_pair
#define endl                "\n"
#define optimize            ios::sync_with_stdio(0); cin.tie(0)

void solve()
{
  int n;cin>>n;
  cout<<n+n*n+n*n*n<<endl;
}

int main() {
  //int t;cin>>t;while(t--)
    solve();

    return 0;
}




Measured memory_bytes: 3608
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

int n,a[100000];
ll ans;

int main(){
	cin >> n;
	lp(n)
		cin >> a[i];
	sort(a, a + n);
	lp(n / 2 - 1) {
		if (n % 2 == 0) {
			if (a[i * 2] != a[i * 2 + 1] || a[i * 2 + 2] - a[i * 2] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			if (a[i * 2 + 1] != a[i * 2 + 2] || a[i * 2 + 3] - a[i * 2 + 1] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	if (a[n - 2] != a[n - 1]) {
		cout << 0 << endl;
		return 0;
	}
	ans = 1;
	lp(n / 2) {
		ans = (ans << 1) % mod;
	}
	cout << ans << endl;

	return 0;
}

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

using ll = long long;
using pll = pair<ll, ll>;
 
constexpr ll M = 1e9+7;

pll expression(string const& s, int& p);
pll term(string const& s, int& p);
pll factor(string const& s, int& p);
void variable(string const& s, int& p);
 
pll expression(string const& s, int& p) {
    pll res = term(s, p);
    while(p < s.size() && s[p] == '|') {
        auto v2 = term(s, ++p);
        ll t1 = res.first, t2 = res.second;
        res.first = t1 * (v2.first + v2.second) + v2.first * (t1 + t2) - t1 * v2.first;
        res.second = t2 * v2.second;
        res.first %= M;
        res.second %= M;
    }
    return res;
}
 
pll term(string const& s, int& p) {
    pll res = factor(s, p);
    while(p < s.size() && s[p] == '&') {
        pll v2 = factor(s, ++p);
        ll t1 = res.first, t2 = res.second;
        res.first = t1 * v2.first;
        res.second = t2 * (v2.first + v2.second) + v2.second * (t1 + t2) - t2 * v2.second;
        res.first %= M;
        res.second %= M;
    }
    return res;
}
 
pll factor(string const& s, int& p) {
    if(s[p] == '~') {
        pll res = factor(s, ++p);
        swap(res.first, res.second);
        return res;
    }
    if(s[p] == '(') {
        auto res = expression(s, ++p);
        p++;
        return res;
    }
    if(s[p] == 'x') {
        variable(s, p);
        return make_pair(1, 1);
    }
    assert("factor error" && false);
}
 
void variable(string const& s, int& p) {
    ++p;
    while(isdigit(s[p])) {
        ++p;
    }
}
 
ll eord, enew;
 
int main() {
    const int SIZE = 128 * 1024 * 1024;
    void* p = malloc(SIZE);
    enew = (ll)p + SIZE - 1;
    __asm__("mov %rsp, eord");
    __asm__("mov enew, %rsp");
    string s;
    cin >> s;
    int pos = 0;
    cout << expression(s, pos).first << endl;
    __asm__("mov eord, %rsp");
}

Measured memory_bytes: 58912
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    int n; cin >> n;
    int x[n]; rep(i,n) cin >> x[i];
    int ans=1001001;
    for(int i=1;i<=100;i++){
        int res=0;
        rep(j,n){
            res+=(i-x[j])*(i-x[j]);
        }
        chmin(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
import math


N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

check = list(itertools.permutations(range(1,N+1)))
N_fac = math.factorial(N)

n1 = 0
n2 = 0
countP = 0
countQ = 0
for i in range(0,N_fac):
  for j in range(0,N):
    if(check[i][j] == P[j]):
      countP += 1
      if(countP == N):
        n1 = i
    if(check[i][j] == Q[j]):
      countQ += 1
      if(countQ == N):
        n2 = i
  countP = 0
  countQ = 0
        
num = n1-n2
print(abs(num))

Measured memory_bytes: 7996
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int c[800][800];
int sumc[800][800],sumr[800][800];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;cin>>H>>W;
  repeat(i,H){
    string s;cin>>s;
    repeat(j,W){
      if(s[j]=='#'){
        c[i+j+1][300+j-i]=1;
      }
    }
  }
  /*
  repeat(i,10){
    for(int j=300-10;j<300+10;j++){
      cerr << c[i][j];
    }
    cerr<<endl;
  }
  */
  repeat(i,780){
    repeat(j,780){
      sumc[i][j+1]=sumc[i][j]+c[i][j+1];
      sumr[i+1][j]=sumr[i][j]+c[i+1][j];
    }
  }
  /*
  cerr<<endl;
  repeat(i,10){
    for(int j=300-10;j<300+10;j++){
      cerr << sumc[i][j];
    }
    cerr<<endl;
  }
  repeat(i,10){
    for(int j=300-10;j<300+10;j++){
      cerr << sumr[i][j];
    }
    cerr<<endl;
  }
  */
  ll ans = 0;
  repeat(i,780){
    repeat(j,780)if(c[i][j+1]){
      repeat(k,j)if(c[i][k+1]){
        int l=i-(j-k);
        if(0<=l)ans += sumc[l][j+1]-sumc[l][k];
        int r=i+(j-k);
        if(r<=780)ans += sumc[r][j+1]-sumc[r][k];
      }
    }
  }
  repeat(j,780){
    repeat(i,780)if(c[i+1][j]){
      repeat(k,i)if(c[k+1][j]){
        int l=j-(i-k);
        if(0<=l)ans += sumr[i][l]-sumr[k+1][l];
        int r=j+(i-k);
        if(r<=780)ans += sumr[i][r]-sumr[k+1][r];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7168
#include<iostream>

using namespace std;

int main()
{
	int i, j;
	int a, b;

	while (true)
	{
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		for (i = 0; i < a; i++)
		{
			for (j = 0; j < b; j++)
			{
				if (i == 0 || i == a - 1 || j == 0 || j == b - 1)
					cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long LL;
struct Edge{
	int next,to;
}edge[N*2];
int c[N],c1[N],fi[N],se,Size[N],Size1[N],n,Sizec[N];
LL ans[N];
inline void add_edge(int u,int v){edge[++se].next=fi[u],fi[u]=se,edge[se].to=v;}
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
void dfs(int x,int fa){
	int w=(c[x]!=c[fa]?c[fa]:0),fa1=c1[w];
	c1[w]=x;Size[x]=1;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa)continue;
		dfs(v,x);Size[x]+=Size[v];
	}
	if(c[x]==c[fa])return;
	ans[w]-=1ll*(Size[x]-Size1[x])*(Size[x]-Size1[x]+1)/2;
	if(c1[c[x]])Size1[c1[c[x]]]+=Size[x];
	else Sizec[c[x]]+=Size[x];
	c1[w]=fa1;
}
int main(){
	int u,v;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",c+i);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),add(u,v);
	dfs(1,0);
	for(int i=1;i<=n;i++)Sizec[i]=n-Sizec[i],ans[i]+=1ll*n*(n+1)/2-1ll*Sizec[i]*(Sizec[i]+1)/2,printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 28712
//Approach for the code is that we are declaring state i as the longest directed path starting from i
//here dp[node] = max(dp[node],1+max(dp[children1],dp[children2],dp[children3]....))
#include <bits/stdc++.h>

using namespace std;

//Recursive dfs function to be intialized

void dfs(int node,vector<int> adj[],int dp[],bool visited[])
{
    visited[node] = true;

    for (int i = 0; i < adj[node].size(); i++) { 
  
        // If not visited 
        if (!visited[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, visited); 
  
        // Store the max of the paths 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    }
}

void addEdge(vector<int> adj[],int u,int w)
{
    adj[u].push_back(w);
}

//Main function that start the chain
int findLongestpath(vector <int> adj[],int n)
{
    //Intializations 
    int dp[n+1];
    memset(dp,0,sizeof(dp));

    bool visited[n+1];
    memset(visited,false,sizeof(visited));
    int i;

    //Calling for dps for every unvisited vertex
    for(i=1;i<=n;i++)
    {
        if(!visited[i]) dfs(i,adj,dp,visited);
    }

    int ans = 0;
    for(i=1;i<=n;i++)
    {
        ans = max(ans,dp[i]);
        //cout<<"i: "<<i<<" dp[i]: "<<dp[i]<<endl;
    } 

    return ans;

}

int main()
{
    int n,m,i,temp1,temp2;
    cin>>n>>m; 
    vector<int> adj[n + 1]; 
    for(i=0;i<m;i++)
    {
        cin>>temp1>>temp2;
        addEdge(adj,temp1,temp2);
    }
  
    cout << findLongestpath(adj, n); 
    return 0;
}

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

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 200020
#define M 1e18
#define F -1e6
#define E 1e6

using namespace std;

int main() {
 	int n, k;
	cin >> n >> k;
	if( n<10 ) {
		k += 100*(10-n);
	}
	pfd(k);
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
long long k;
int a[200010];
int nextA[200010];

//struct Loop {
//	int size;
//	std::vector<int> loop;
//};

std::vector<int> loop;
std::map<int, int> posMap;

int main()
{
	scanf("%d%lld", &n, &k);
	
	for (int i = 1 ; i <= n ; i++) {
		scanf("%d", &(a[i]));
	}
	
	loop.clear();
	posMap.clear();	
	int pos = 0;
	int p = 1;
	while (posMap.find(p) == posMap.end()) {
		loop.push_back(p);
		posMap[p] = pos;
		pos++;
		p = a[p];
	}
	
	int loopLength = pos - posMap[p];
	int headLength = posMap[p];
	
	int ans = 0;
	if (k < headLength) {
		ans = loop[k];
	} else {
		k = k - headLength;
		k = k % loopLength;
		ans = loop[headLength + k];
	}
	
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 13516
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    ans = 0

    for i in range(1, len(a)+1):
        v = a[i-1]

        if i % 2 == 1 and v % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];
    sort(n.begin(), n.end());
    reverse(n.begin(), n.end());
    int ans = n[0] * 10 + n[1] + n[2];
    cout << ans << endl;
}

Measured memory_bytes: 256
strs='A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ')
num=int(input())
alphas=list(input())
new_alphas=[]
new_num=0
for a in alphas:
    new_num=(num+strs.index(a))%26 
    new_alphas.append(strs[new_num])
print(''.join(new_alphas))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll mx = LLONG_MIN;
    mx = max(mx, a * c);
    mx = max(mx, b * d);
    mx = max(mx, a * d);
    mx = max(mx, b * c);
    cout << mx << "\n";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 998244353
#define MAX 100005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

ll prime[MAX];
void sieve()
{
	prime[1] = 1;
	for(ll i=2;i<MAX;i++)
	if(prime[i]==0)
	for(ll j=i;j<MAX;j+=i)
	prime[j]=i;
}

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

//sieve();


ll t=1;
//cin>>t;

loop(k,0,t)
{
	ll n;
	cin>>n;
	if(n==2)
	{
		cout<<"1\n";
		return 0;
	}
	ll ans=1;
	loop(i,2,(ll)sqrt(n)+1)
	{
		ll temp = n;
		if(temp%i==0)
		{
			while(temp%i==0)
			{
				temp /= i;
			}
			if(temp%i==1)
			ans++;
		}
	}
	ll temp = n-1;
	ans++;
	loop(i,2,(ll)sqrt(temp)+1)
	{
		if(temp%i==0)
		{
			ans++;
			if(temp/i != i)
			ans++;
		}
	}
	cout<<ans<<"\n";
}



return 0;
}


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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    string s,t,u;
    cin >> s>>t >>u;
    char dif = 'A' -'a';
    char S = s[0]+ dif;
    char T = t[0]+ dif;
    char U = u[0]+ dif;
    cout << S << T << U  <<endl;
        }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	
	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()

string S;
int32_t main() {
	cin >> S;
	if (S[2] == S[3] and S[4] == S[5]) cout << "Yes";
	else cout << "No";
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool sword_comparator(vector<long long> a, vector<long long> b) {
  return a[0] > b[0];
}

int main() {
  long long n, h;
  cin >> n >> h;
  long long a[n];
  long long b[n];

  int normal_slash = 1;
  int final_slash = 0;

  vector<vector<long long>> swords;

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cin >> b[i];
    vector<long long> ai = {a[i], normal_slash};
    swords.push_back(ai);
    vector<long long> bi = {b[i], final_slash};
    swords.push_back(bi);
  }

  sort(swords.begin(), swords.end(), sword_comparator);

  long long best_normal = -1;

  vector<long long> final_slashes_better_than_best_normal;

  for (int j = 0; j < swords.size(); ++j) {
    if (swords[j][1] == normal_slash) {
      best_normal = swords[j][0];
      break;
    } else {
      final_slashes_better_than_best_normal.push_back(swords[j][0]);
    }
  }

  int counter = 0;
  for (auto fs: final_slashes_better_than_best_normal) {
    h -= fs;
    counter++;
    if (h <= 0) {
      cout << counter << endl;
      return 0;
    }
  }

  long long normal_slash_counter = (h / best_normal) + (h % best_normal == 0 ? 0 : 1);
  cout << counter + normal_slash_counter << endl;

  return 0;
}

Measured memory_bytes: 15788
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS
//https://atcoder.jp/contests/abc155/tasks/abc155_a

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


Measured memory_bytes: 128
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

type Time struct {
	S int
	T int
}

type Times []Time

func (ts Times) Len() int { return len(ts) }
func (ts Times) Swap(i,j int) { ts[i], ts[j] = ts[j], ts[i] }
func (ts Times) Less(i,j int) bool { return ts[i].T < ts[j].T }

func main() {
	var n int
	fmt.Scan(&n)
	var times Times = make([]Time, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		times[i].S, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		times[i].T, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(times)

	t, num := 0, 0
	for i := 0; i < n; i++ {
		if t >= times[i].S {
			continue
		}
		t = times[i].T
		num += 1
	}
	fmt.Println(num)
}


Measured memory_bytes: 5688
#include <iostream>
#define MAX 100000
using namespace std;

int partition(int A[], int p, int r) {
    int temp;
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    temp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = temp;
    return i + 1;
}

int main() {
    int n, A[MAX], q;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    q = partition(A, 0, n - 1);

    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << endl;

    return 0;
}



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

struct hoge {
    ll h0; int num; ll l0;
};

bool comp(hoge &a, hoge &b){
    if(a.h0!=b.h0) return a.h0 > b.h0;
    if(a.l0!=b.l0) return a.l0 < b.l0;
    return a.num < b.num;
}

int N; ll X;
ll b[100100], l[100100], u[100100];
hoge h[100100];
ll sum[100100];
ll st;

bool ok(ll s){
    ll q = s/X;
    ll r = s%X;
    
    for(int i=0; i<N; i++){
        int j=h[i].num;
        ll smax;
        if(b[j] <r ){
            smax=b[j]*l[j]+ (r-b[j])*u[j] ;
        }
        else{
            smax=r*l[j];
        }
        ll now=st+smax;
        if(i<q){
            now += sum[q+1] - h[i].h0;
        }
        else{
            now += sum[q];
        }
        if(now >=0) return true;
    }
    return false;
    

/*
    ll now=st;

    while(s >= X){
        now += h[n].h0;
        s -=X;
        n++;
    }
    //s増えた時のmaxを求める
    ll smax=0LL;
    for(int i=n; i<N; i++){
        int j=h[i].num;
        if(b[j] <s ){
            if( b[j]*l[j]+ (s-b[j])*u[j]  > smax ) smax=b[j]*l[j]+ (s-b[j])*u[j] ;
        }
        else{
            if(smax < s*l[j] ) smax=s*l[j];
        }
    }
    if(now+smax >=0LL) return true;
    return false;
*/
}

int main(){
    cin  >> N >> X;
    for(int i=0; i<N; i++){
        cin >> b[i] >> l[i] >> u[i];
        h[i].h0=  b[i]*l[i]+(X-b[i])*u[i];
        h[i].num=i;
        h[i].l0=l[i];
        st -= b[i]*l[i];
    }
    sort(h,h+N,comp);
    for(int i=0; i<N; i++){
        sum[i+1]=sum[i]+h[i].h0;
    }


    ll lb=-1LL, ub= (ll) N*X;
    while(ub-lb >1LL){
        ll mid=(lb+ub)/2LL;
        if(ok(mid)){
            ub=mid;
        }
        else{
            lb=mid;
        }
    }
    cout << ub << endl;
}



Measured memory_bytes: 5760
#if 0
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2642
17:05-

#endif

#include <iostream>
#include <algorithm>
#include <limits.h>
#include <stdint.h>
using namespace std;

//pair<int, int> c[500010];
long long c[500010];

#define REP(var, start, count) for(long long var=start; var<count; var++)

int main(void) {
	
	int n, p, q;
	
	
	
	cin >> n >> p >> q;
	
	long long zisui = (long long)p * q;
	long long ztotal = 0;
	
	REP(i, 0, n) {
		int ccc;
		cin >> ccc;
		c[i] = ccc-zisui; //????????????????????¨??§????????????????????????
		
		ztotal += zisui;
		zisui -= p;
		//if ( i%100 == 0 ) { cerr << "i " << i << " c[i] " << c[i] << " ztotal " << ztotal << endl; }
	}
	//cerr << "ztotal " << ztotal << endl;
	
	sort(c, c+n);
	reverse(c, c+n);
	
	long long max = LLONG_MIN;
	
	long long sum = 0;
	
	for(long long day=0; day<=n; day++) { //?????\????£???????????????????
		
		if ( day != 0 ) {
			sum += c[day-1];
		}
		
		long long zisuiday = n-day;
		long long bonus = p * (zisuiday)*(zisuiday-1);
		if (zisuiday <= 1) { bonus = 0; }
		
		long long ret = sum + bonus + ztotal;
		//if(zisuiday<10 || day<10 ||day%100==0) { cerr << "day " << day << " bonus " << bonus << " sum " << sum << " ret " << ret << endl; }
		
		if ( ret > max ) { max = ret; }
	}
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<pair<int, int>>p(n);
	REPC(&i, p)
	{
		int x = in(), y = in();
		i = make_pair(x, y);
	}
	sort(ALL(p));
	REPC(i, p)
	{
		cout << i.first << ' ' << i.second << endl;
	}
}


Measured memory_bytes: 3628
n = int(input())
a = [int(input()) for i in range(n)]

a.sort(reverse = True)


keisuu = [0]*n
for i in range(n-1):
    if i % 2 == 0:
        keisuu[i] += 1
        keisuu[i+1] -= 1
    else:
        keisuu[i] -= 1
        keisuu[i+1] += 1
ans = 0
keisuu.sort(reverse = True)
for i in range(n):
    ans += a[i] * keisuu[i]


keisuu = [0]*n
for i in range(n-1):
    if i % 2 == 1:
        keisuu[i] += 1
        keisuu[i+1] -= 1
    else:
        keisuu[i] -= 1
        keisuu[i+1] += 1
keisuu.sort(reverse = True)
ans1 = 0
for i in range(n):
    ans1 += a[i] * keisuu[i]

print(max(ans, ans1))


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


string s;

signed main(){
    cin>>s;
    rep(i,0,s.size()){
        if(i==5||i==13)cout<<" ";
        else cout<<s[i];
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<math.h>

using namespace std;

const long MIN = -1234567890;

long gcd(long n, long m) {
    if (n < m)swap(n, m);
    if (n == m || m == 0)return n;
    return gcd(m, n % m);
}

long pri(){
    long ans = 0;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int m;
        bool flag = false;
        cin >> m;
        for(int j = 2; j <= sqrt(m); j++){
            if(m % j == 0) {
                flag = true;
                break;
            }
        }
        if(!flag) ans++;
    }
    return ans;
}

long max_gap(){
    long n,m, ans = MIN, min;
    cin >> n;
    cin >> m;
    min = m;
    for(int i = 1; i < n; i++){
        cin >> m;
        if(ans < (m - min)) ans = (m - min);
        if(min > m)min = m;
    }
    return ans;
}

void selection_sort(){
    long n,a[101],scou = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        long min = i;
        for(int j = i+1; j < n; j++){
            if(a[min] > a[j]) min = j;
        }
        if(min != i) {
            scou++;
            swap(a[min], a[i]);
        }
        cout << a[i];
        if(i == (n - 1))cout << endl;
        else cout << " ";
    }
    cout << scou << endl;
}

int main() {
    selection_sort();
}


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

int main()
{
    int n; cin>>n;
    int res=1, t=1;
    vector<int> a(n);
    for(int& e: a) {
        cin>>e;
        res*=3;
        if (e%2==0) t*=2;
    }
    cout<<res-t<<endl;
}


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

using namespace std;

const int MAX = 60;

char m[MAX][MAX];
int dir[5] = {1, 0, -1, 0, 1};

int main(){
  ios_base:: sync_with_stdio(false); cin.tie(0);
  
  int l, c;
  cin >> l >> c;
  
  for(int i = 1; i <= l; i++)
    for(int j = 1; j <= c; j++)
      cin >> m[i][j];
      
  for(int i = 1; i <= l; i++){
    for(int j = 1; j <= c; j++){
      if (m[i][j] == '#'){
        bool ok = false;
      
        for(int k = 0; k < 4; k++)
          if (m[i + dir[k]][j + dir[k+1]] == '#')
            ok = true;
      
        if (!ok){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

// int main(){
// 	ll x,y;cin>>x>>y;
// 	ll ans;
// 	if (x <= y){
// 		ans = abs(y - x);
// 		if (x < 0 && abs(x) <= y){
// 			ans = min(ans,1 + y - abs(x));
// 		}
// 		else if (x < 0 && abs(x) > y){
// 			ans = min(ans,1 + abs(abs(y) - abs(x)));

// 		}
// 	}
// 	else{
// 			ans = 1 + abs(abs(y) -  abs(x));
// 			if(x * y > 0){
// 			ans = 2 + abs(abs(y) - abs(x));
// 		}
// 	}
// 	cout << ans << endl;
// 	return 0;
// }
ll copy(const ll x){return x;}
int main(){
	ll x,y;cin>>x>>y;
	ll ans = LINF;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			ll a = copy(x);
			ll b = copy(y);
			if (i == 1){
				a *= -1;
			}
			if (j == 1){
				b *= -1;
			}
			if (a <= b){
				ans = min(ans,b - a + i + j);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// 8/22 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int now = 0;
    ll ans = 0;

    rep(i, N) {
        if (now < A[i]) now = A[i];
        else ans += (now - A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3992
import java.util.*;

// djkstra ??????????????????
public class Main {

    static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int vn = sc.nextInt();
        int ve = sc.nextInt();
        int s = sc.nextInt();

        // List<Edge>[] edges = new ArrayList<Edge>[vn];
        List<List<Edge>> edges = new ArrayList<>();

        for (int i = 0; i < vn; i++) {
            edges.add(new ArrayList<>());
        }

        for (int i = 0; i < ve; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int f = sc.nextInt();
            edges.get(a).add(new Edge(a, b, f));
            // ????????°??????
            // edges[b].add(new Edge(b, a, f));
        }

        int[] distance = new int[vn];
        Arrays.fill(distance, INF);
        distance[s] = 0;
        Queue<Edge> queue = new PriorityQueue<>();
        queue.add(new Edge(s, s, 0));

        while (!queue.isEmpty()) {
            Edge e1 = queue.poll();
            if (distance[e1.target] < e1.cost) {
                continue;
            }

            for (Edge e2 : edges.get(e1.target)) {
                if (distance[e2.target] > distance[e1.target] + e2.cost) {
                    distance[e2.target] = distance[e1.target] + e2.cost;
                    queue.add(new Edge(e1.target, e2.target, distance[e2.target]));
                }
            }
        }

        for (int i = 0; i < vn; i++) {
            System.out.println(distance[i] == INF ? "INF" : distance[i]);
        }
    }

    static class Edge implements Comparable<Edge> {
        public int source;
        public int target;
        public int cost;

        public Edge(int source, int target, int cost) {
            this.source = source;
            this.target = target;
            this.cost = cost;
        }


        @Override
        public int compareTo(Edge o) {
            return this.cost - o.cost;
        }
    }
}

Measured memory_bytes: 323176
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,M,K = mint()
ans = False
for i in range(N+1):
    for j in range(M+1):
        if i*(M-j)+(N-i)*j==K:
            ans = True
            break
judge(ans)

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


#define N 50000

int main(){
    int n;

    bool is_prime[N];
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<N;i++){
      is_prime[i] = true;
    }
    for(int i=2; i*i<N; i++){
      if(is_prime[i]){
        for(int j=i*i;j<N; j+=i){
          is_prime[j] = false;
        }
      }
    }


    while(1){
      int counter = 0;
      cin >> n;
      if(n == 0)
        break;
      if(cin.eof())
        break;
      int i=0;
      while(i <= n/2){
        if(is_prime[n-i] && is_prime[i])
          counter++;
        i++;
      }
        cout << counter << endl;
      }

    return 0;
}



Measured memory_bytes: 3140
program welcome_to_atcoder
    implicit none
    integer(4):: n, m, i, all_ac, all_pena
    integer(4), allocatable:: p(:),pena(:)
    character(2), allocatable:: s(:)
    logical, allocatable:: is_ac(:)
    read*, n, m
    allocate(p(m), s(m), is_ac(n), pena(n))
    do i=1, m
        read*, p(i),s(i)
    end do
    is_ac(:) = .false.
    pena(:) = 0
    do i=1, m
        if (s(i) == "AC") then
            is_ac(p(i)) = .true.
        else
            if (.not. is_ac(p(i))) pena(p(i)) = pena(p(i)) + 1
        end if
    end do

    all_ac = 0
    all_pena = 0
    

    do i=1, n
        ! print*, is
        if (is_ac(i)) then
            all_ac = all_ac + 1
            all_pena = all_pena + pena(i)    
        end if    
    end do

    print*, all_ac, all_pena

    
end program welcome_to_atcoder

Measured memory_bytes: 1536
using System;

class A{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int A = Ar[0], B = Ar[1], C = Ar[2];
    int TempA = 0, TempB = 0, TempC = 0, count = 0;
    if (A == B && B == C && A == 1){
      Console.WriteLine("0");
      return;
    }
    if (A == B && B == C) {
      Console.WriteLine("-1");
      return;
    }
    for (; ; ){
      if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
        break;
      }
      TempA = A / 2;
      TempB = B / 2;
      TempC = C / 2;
      A = 0;
      B = 0;
      C = 0;
      A = TempB + TempC;
      B = TempA + TempC;
      C = TempA + TempB;
      count++;
    }
    Console.WriteLine(count);
  }
}      


Measured memory_bytes: 17696
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    vector<int> a(3);
    rep(i,3)cin >> a[i];
    sort(ALL(a));
    if(a[0] == a[1] && a[0] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n];
		
		for (int i = 0; i < nums.length; i++) {
			nums[i] = sc.nextInt();
		}
		long firstDigitPostive = 0;

		long prefixSum = 0;
		for (int i = 0; i < nums.length; i++) {
			prefixSum += nums[i];
			if (i % 2 == 0) {
				// odd is postive
				if (prefixSum == 0) {
					prefixSum++;
					firstDigitPostive++;
				} else if (prefixSum < 0) {
					firstDigitPostive += (1 - prefixSum);
					prefixSum += 1 - prefixSum;
				}
			} else {
				// even is negative
				if (prefixSum == 0) {
					prefixSum--;
					firstDigitPostive++;
				} else if (prefixSum > 0) {
					firstDigitPostive += (1 + prefixSum);
					prefixSum -= (prefixSum + 1) ;
				}
			}
		}
		
		prefixSum = 0;
		long firstDigitNegative = 0;
		for (int i = 0; i < nums.length; i++) {
			prefixSum += nums[i];
			if (i % 2 == 0) {
				// odd is negative
				if (prefixSum == 0) {
					prefixSum--;
					firstDigitNegative++;
				} else if (prefixSum > 0) {
					firstDigitNegative += (1 + prefixSum);
					prefixSum -= (prefixSum + 1) ;
				}
			} else {
				// even is postive
				if (prefixSum == 0) {
					prefixSum++;
					firstDigitNegative++;
				} else if (prefixSum < 0) {
					firstDigitNegative += (1 - prefixSum);
					prefixSum += 1 - prefixSum;
				}
			}
		}
		
		System.out.println(Math.min(firstDigitPostive, firstDigitNegative));
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 36776
<?php
list($A, $B, $C) = explode(" ", trim(fgets(STDIN)));
$A_end = substr($A, -1, 1);
$B_first = substr($B, 0, 1);
$B_end = substr($B, -1, 1);
$C_first = substr($C, 0, 1);
if ($A_end === $B_first && $B_end === $C_first) {
    echo 'YES';
} else {
    echo 'NO';
}


Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,X,Y,a;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  
  if(N<K){
    a=X*N;
  }else{
    a=X*K+Y*(N-K);
  }
  cout << a << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

const int MAXN = 100000;
long long prefix[MAXN];
int N, M;

int main() {
    cin >> N >> M;
    map<int, vector<int> > m;
    m.clear();
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (i == 0) prefix[0] = a % M;
        else prefix[i] = (a + prefix[i - 1]) % M;
        int mod = prefix[i];
        if (m.find(mod) != m.end()) m[mod].push_back(i);
        else { vector<int> v; v.push_back(i); m[mod] = v; }
    }
    long long ans = 0;
    if (m.find(0) != m.end()) ans += m[0].size();
    for (map<int, vector<int> >::iterator i = m.begin(); i != m.end(); i++) {
        vector<int> v = i->second;
        // cout << v.size() << "\n";
        ans += v.size() * (v.size() - 1) / 2;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main() {
	int H, W;
	std::cin >> H >> W;

	std::vector<std::vector<int>> board(H, std::vector<int>(W, 0));
	for(int y = 0; y < H; y++) {
		for(int x = 0; x < W; x++) {
			std::cin >> board[y][x];
		}
	}

	int N = 0;
	std::stringstream ss;

	for(int y = 0; y < H; y++) {
		for(int x = 0; x < W - 1; x++) {
			if(board[y][x] % 2 == 1) {
				board[y][x] -= 1;
				board[y][x + 1] += 1;
				N++;
				ss << y + 1 << " " << x + 1 << " ";
				ss << y + 1 << " " << (x + 1) + 1 << std::endl;
			}
		}
	}

	for(int y = 0; y < H - 1; y++) {
		const int x = W - 1;
		if(board[y][x] % 2 == 1) {
			board[y][x] -= 1;
			board[y + 1][x] += 1;
			N++;
			ss << y + 1 << " " << x + 1 << " ";
			ss << (y + 1) + 1 << " " << x + 1 << std::endl;
		}
	}

	std::cout << N << std::endl;
	std::cout << ss.str();

	return 0;
}

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

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

    int a, b; cin >> a >> b;

    if ((a*b)%2==0) cout << "Even";
    else cout << "Odd";

    cout << "\n";    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  string S; cin >> S;
  S[K-1] = tolower(S[K-1]);
  cout << S << endl;
}


Measured memory_bytes: 256