akhauriyash/Code-Regression huggingface dataset:
N = int(input())

def shichigosan(x):
  if x == "":
    r = 0
    r += shichigosan(x+"3")
    r += shichigosan(x+"5")
    r += shichigosan(x+"7")
    return r
  else:
    if int(x) > N:
      return 0
    else:
      r = 0
      if '3' in x and '5' in x and '7' in x:
        r = 1      
      r += shichigosan(x+"3")
      r += shichigosan(x+"5")
      r += shichigosan(x+"7")
      return r
        
print(shichigosan(""))         

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main() {
  std::string s;
  std::getline(std::cin, s);
  for (auto c : s) {
    char cc = c;
    if ('a' <= c && c <= 'z') cc = c - 'a' + 'A';
    if ('A' <= c && c <= 'Z') cc = c - 'A' + 'a';
    std::cout << cc;
  }
  std::cout << std::endl;
}



Measured memory_bytes: 3128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N;
int H[100003];
int cost[100003];
int INF = 1e9;

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

  cin >> N;
  rep(i, N) {
    cin >> H[i];
    cost[i] = INF;
  }

  cost[0] = 0;
  rep(i, N-1) {
    cost[i+1] = min(cost[i]+abs(H[i+1]- H[i]), cost[i+1]);
    cost[i+2] = min(cost[i]+abs(H[i+2]- H[i]), cost[i+2]);
  }

  cout << cost[N-1] << "\n";
  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	x := nextInt()

	var answer int64

	answer = int64(b/x) + 1

	if a == 0 {
		answer += 0
	} else {
		answer -= int64((a-1)/x) + 1
	}

	// for i := a; i <= b; i++ {
	// 	if i%x == 0 {
	// 		answer++
	// 	}
	// }

	fmt.Println(answer)
}


Measured memory_bytes: 640
# This was written by chizuchizu
import numpy as np
import sys
# import collections

# import bisect
# import math
import numpy as np

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    s, w = ip.IL()
    if s <= w:
        print("unsafe")
    else:
        print("safe")



main()


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
//typedef pair<int, int> P;

vector<int> keta(int n) {
    vector<int> k(10, 0);
    for (int i = 0; i < 3; i++) {
        k[n % 10]++;
        n /= 10;
    }
    return k;
}

int main() {

    int n;
    cin >> n;

    for (int i : keta(n / 10)) {
        if (i >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i : keta(n % 1000)) {
        if (i >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

}

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

#define REP(i,a,b) for(int i = (a) ; i < (int)(b) ; ++i )
#define _REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define mp(x,y) make_pair((x), (y))
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x,v) memset((x), (v), sizeof (x))
#define _ri1(x) scanf("%d", &(x))
#define _ri2(x,y) scanf("%d%d", &(x), &(y))
#define _ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define _ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define _pi1(a) printf("%d\n", (a))
#define _pi2(a,b) printf("%d%d\n", (a), (b))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int num[] = {0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //#endif // ONLINE_JUDGE
    while(scanf("%d",&n)==1){
        _pi1(num[n]);
    }
    return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<int> A(N);
  rep (i, N) {
    cin >> A[i];
  }
  int c = N-1;
  sort(all(A));
  int k = c;
  ll ans = 0;
  while(1) {
    if (c == 0)
      break;
    else if (k == N-1) {
      ans += (ll)A[k];
      c--;
      k--;
    }
    else if (c == 1) {
      ans += (ll)A[k];
      c--;
      k--;
    }
    else {
      ans += 2*(ll)A[k];
      c-=2;
      k--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3964
n, money = (map(int, input().split()))

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == money:
            print(i, j, n-i-j)
            break
    else:
        if i == n:
            print(-1, -1, -1)
            break
        continue
    break



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}


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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

//head
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<double> dp(n+1);
	dp[0] = 1;
	for(int coin = 0; coin < n; coin++) {
		double p;
		cin >> p;
		for(int i = coin + 1; i >= 0; i--) {
			dp[i] = (i == 0 ? 0 : dp[i-1] * p) + dp[i] * (1 - p);
		}
	}
	double ans = 0;
	for(int i = n / 2 + 1; i <= n; i++) {
		ans += dp[i];
	}
	cout << setprecision(10);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>v[100004];
bool visited[100004] = {false};
ll level[100004] = {0};
ll ans=0;
ll count1=1;

void dfs(ll a){
    ll i;
    //ll count=1;
    visited[a] = true;
    for(i=0;i<v[a].size();i++){
        if(visited[v[a][i]]==false)
            dfs(v[a][i]);
        level[a] = max(level[a],level[v[a][i]]+1);
    }
}

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
} 

int main(){
    boost();
    ll n,m;
    cin >> n >> m; 
    ll i;
    while(m--){
        ll a,b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    for(i=0;i<100004;i++)
    visited[i]= false;
    
    
    for(i=1;i<=n;i++){
        if(visited[i]==false)
        dfs(i);
    }
    for(i=1;i<=n;i++)
    ans=max(ans,level[i]);
    cout << ans  << endl;
}

Measured memory_bytes: 12660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
  int n; cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  rep(i,n) cin >> a[i];
  ans[0]=a[0];
  rep(i,n-2) ans[0]=a[i+1]-ans[0];
  ans[0]=(a[n-1]-ans[0])/2;
  rep(i,n-1) ans[i+1]=a[i]-ans[i];
  rep(i,n) printf("%d ",ans[i]*2);
return 0;
}
/*a+b=3 b=3-a
b+c=8 c=5+a
c+d=7 d=2-a
d+e=5 e=3+a
e+a=5 2a=2*/

Measured memory_bytes: 2048
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    dic = {}
    for i in range(n):
        k = input().rstrip()
        dic[k] = dic.get(k,0) + 1

    m = max(list(dic.values()))
    ans = []
    for i,k in dic.items():
        if k == m:
            ans.append(i)
    print("\n".join(sorted(ans)))




if __name__=="__main__":
    main()


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

using ll = long long;
using namespace std;
const ll MOD = 1e9 + 7;

ll mod(ll a, ll b) {
	if (a >= MOD) a = a % MOD;
	if (b >= MOD) b = b % MOD;
	return (a * b) % MOD;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	int n;
	cin >> n;
	vector<ll> white(n + 1, 1), black(n + 1, 1), leaf(n + 1), vis(n + 1);
	vector<vector<int> > edge(n + 1);
	for (int i = 1, x, y; i < n; i++) {
		cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
		leaf[x]++;
		leaf[y]++;
	}
	queue<int> q;

	for (int i = 1; i <= n; i++) {
		if (leaf[i] == 1) 	q.push(i);
	}
	int y;
	while (!q.empty()) {
		y = q.front();
		q.pop();
		vis[y] = 1;
		for (int i = 0; i < (int)edge[y].size(); i++) {
			int x = edge[y][i];
			if (vis[x] == 0) {
				white[x] = mod(white[x], white[y] + black[y]);
				black[x] = mod(black[x], white[y]);
				leaf[x]--;
			}
			if (leaf[x] == 1  && vis[x] == 0) q.push(x);
		}
	}

	ll ans = (white[y] + black[y]) % MOD;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 12908
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int INF = 0x3f3f3f3f;
//void upd(ll &x,ll y) { x=(x+y)%mod; }
char str[10];
int main()
{
//	gets(str);
scanf("%s",str);
	int len=strlen(str);
	int cnt=0;
	rep(i,0,len) if(str[i]=='1') cnt++;
	cout<<cnt;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
         
int main(void){
  char a,temp;
  cin >> a;
  if(a == 'A')temp = 'T';
  if(a == 'T')temp = 'A';
  if(a == 'G')temp = 'C';
  if(a == 'C') temp = 'G';
  cout << temp << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int ax[105];

int main()
{
    int n,x,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&ax[i]);
    sort(ax,ax+n);
    printf("%d",ax[n-1]-ax[0]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||b+c==a){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[][] s = new char[3][];
		for(int i=0; i<3; i++)
			s[i] = sc.next().toCharArray();
		int O = 2000;
		boolean[][] match = new boolean[3][O*4+1];
		for(int i=0; i<3; i++) {
			Arrays.fill(match[i], true);
			
			int j=(i+1)%3;
			for(int k=-s[j].length; k<=s[i].length; k++) {
				boolean ok = true;
				for(int l=Math.max(k, 0); l<Math.min(s[i].length, k+s[j].length); l++) {
					if(s[i][l]!='?' && s[j][l-k]!='?' && s[i][l]!=s[j][l-k]) {
						ok = false;
						break;
					}
				}
				match[i][O*2+k] = ok;
			}
		}
		
		int ans = s[0].length + s[1].length + s[2].length;
		
		for(int i=0; i<3; i++) {
			int j=(i+1)%3;
			int k=(i+2)%3;
			for(int l=0; l<=s[i].length; l++) {
				if(!match[i][O*2+l])
					continue;
				for(int m=l; m<=Math.max(s[i].length, l+s[j].length); m++) {
					if(match[j][O*2+m-l] && match[k][O*2-m]) {
						ans = Math.min(ans, Math.max(s[i].length, Math.max(l+s[j].length, m+s[k].length)));
					}
				}
			}
			for(int l=0; l<=s[i].length; l++) {
				if(!match[k][O*2-l])
					continue;
				for(int m=l; m<=Math.max(s[i].length, l+s[k].length); m++) {
					if(match[j][O*2-m+l] && match[i][O*2+m]) {
						ans = Math.min(ans, Math.max(s[i].length, Math.max(l+s[k].length, m+s[j].length)));
					}
				}
			}
		}
		
		System.out.println(ans);
		sc.close();
	}

}



Measured memory_bytes: 25812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    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;
        }
    }

    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),m = obj.nextInt();
        int sum=0;
        for(int i=0;i<m;i++) sum += obj.nextInt();
        System.out.println((sum>n)?"-1":n-sum);
    }
}


Measured memory_bytes: 27228
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

long long n;
long long a[200000 + 5];
long long pmax[200000 + 5];
long long nmax[200000 + 5];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		pmax[i] = max(pmax[i - 1], a[i]);
	for (int i = n; i >= 1; i--)
		nmax[i] = max(nmax[i + 1], a[i]);
	for (int i = 1; i <= n; i++)
	{
		cout << max(pmax[i - 1], nmax[i + 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define INF 1e9

int main(){
    //freopen("A.in", "r", stdin);
    //freopen("A.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    if(x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans=0
for i in range(n):
    if a[i] >= b[i]:
        t=b[i]
        a[i] -= t
        b[i] -= t
        ans += t
    else:
        t=a[i]
        a[i] -= t
        b[i] -= t
        ans += t

    if a[i + 1] >= b[i]:
        t=b[i]
        a[i+1]-=t
        b[i] -= t
        ans += t
    else:
        t = a[i + 1]
        a[i+1]-=t
        b[i] -= t
        ans+=t
print(ans)

Measured memory_bytes: 19004
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "SUN") {
		cout<<7<<endl;
	}
	if (S == "MON") {
		cout << 6 << endl;
	}
	if (S == "TUE") {
		cout << 5 << endl;
	}
	if (S == "WED") {
		cout << 4 << endl;
	}
	if (S == "THU") {
		cout << 3 << endl;
	}
	if (S == "FRI") {
		cout << 2 << endl;
	}
	if (S == "SAT") {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
x,k,d = map(int,input().split())
ans = abs(x)
x = abs(x)
temp = 0
if x > k*d:
    ans = abs(x)-k*d
    print(ans)
    exit()
else:
    temp = x%d
    k -= x//d
    # print(temp,k)
    if k % 2 == 1:
        ans = abs(temp-d)
    else:
        ans = temp
    print(ans)

Measured memory_bytes: 9192
n = int(input())
s = [input() for x in range(n)]
count = 0
d = {}

for i in range(n):
    s1 = list(s[i])
    s1.sort()
    string = "".join(s1)
    if (string not in d.keys()):
        d[string] = 0
    else:
        d[string] += 1
        count += d[string]

print(count)    


Measured memory_bytes: 24976
//AC記録用コピペ
//自分のコードは1テストケースファイルあたり10分程度
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3566759#1
#include <bits/stdc++.h>
using namespace std;
  
int N, Size;
string s[12];
  
  
int rec(int idx, int md, int sum, int used, vector< int >& conb) // ??´???, ??°????????????, ?????£?????°???
{
    for(int i = 0; i < N; i++) if(s[i].size() != 1 && conb[s[i][s[i].size() - 1]] == 0) return(0);
    if(idx == s[N - 1].size()) return(sum == 0);
      
    int ret = 0;
      
    for(int i = md; i < N - 1; i++) {
        if(s[i].size() <= idx) continue;
        if(conb[s[i][idx]] != -1) {
            sum += conb[s[i][idx]];
        } else {
            for(int j = 0; j < 10; j++) {
                if((used >> j) & 1) continue;
                conb[s[i][idx]] = j;
                ret += rec(idx, i + 1, sum + j, used|(1 << j), conb);
                conb[s[i][idx]] = -1;
            }
            return(ret);
              
        }
    }
      
    int digit = sum % 10;
      
    if(conb[s[N - 1][idx]] == -1) {
        if((used >> digit) & 1) return(0);
          
        conb[s[N - 1][idx]] = digit;
        ret = rec(idx + 1, 0, sum / 10, used|(1 << digit), conb);
        conb[s[N - 1][idx]] = -1;
          
    } else {
      
        if(digit != conb[s[N - 1][idx]]) return(0);
        ret = rec(idx + 1, 0, sum / 10, used, conb);
          
    }
    return(ret);
}
  
int main()
{
    while(cin >> N, N) {
        Size = 0;
        for(int i = 0; i < N; i++) {
            cin >> s[i];
            reverse(s[i].begin(), s[i].end());
            if(i != N - 1) Size = max< int >(Size, s[i].size());
        }
        vector< int > conb(128, -1);
        if(Size > s[N - 1].size()) cout << 0 << endl;
        else cout << rec(0, 0, 0, 0, conb) << endl;
    }
}


Measured memory_bytes: 3084
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    vector<char> s;
    char c;
    while(cin >> c){
        s.push_back(c);
    }
    reverse(s.begin(),s.end());
//    REP(i,0,s.size()){
//        cout << s[i];
//    }

    int p = 0;
    string add[4] = {"dream","dreamer","erase","eraser"};

    vector<char> radd[4];
    REP(i,0,4){
        vector<int> tmp;
        string tmps = add[i];
        int size = tmps.size();
        REP(j,0,size){
            radd[i].push_back(tmps[j]);
        }
        reverse(radd[i].begin(),radd[i].end());
    }


    while(true){
        bool cflag = false;
        if(p == s.size()){
            cout << "YES" << endl;
            return 0;
        }

        REP(i,0,4){
            int flag = true;
            REP(j,0,radd[i].size()){
                if(s[p + j] != radd[i][j]) flag = false;
            }
            if(flag){
                p += radd[i].size();
                cflag = true;
                break;
            }
        }

        if(cflag) continue;
        else break;
        
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
int main ()
{                                          ///without test case
  long long int a,b,c,d,t,n,i,j;
  cin >> a>>b>>c;
  cout << c<<" "<<a<<" "<<b<<"\n";
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    int n, w;
    cin >> n >> w;

    V<int> v(n), o(n);
    rep(i, n) cin >> v[i] >> o[i];

    V<int> dp(w + 1, 0);
    rep(i, n) {
        rep(j, w + 1 - o[i]) { dp[j + o[i]] = max(dp[j + o[i]], dp[j] + v[i]); }
    }
    int ans = 0;
    rep(i, w + 1) { ans = max(dp[i], ans); }
    cout << ans << endl;
}



Measured memory_bytes: 3260
import java.util.Scanner;


public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    
    for (int i = 0; i < n; i ++) {
      int a = input.nextInt();
      int b = input.nextInt();
      int c = input.nextInt();
      
      boolean result = (a*a + b*b == c*c || b*b + c*c == a*a || a*a + c*c == b*b);
      System.out.println(result == true ? "YES" : "NO");
    }
  }

}

Measured memory_bytes: 23352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	int b;
	for(int i=0;i<n;i++){
		cin>>b;
		a[b]++;
	}
	int ans=0;
	sort(a.begin(),a.end());
	for(int i=0;i<k;i++){
		ans+=a[n-1-i];
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	rep(i, 3) {
		if (s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>


using namespace std;

int main() {
    


    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if (x-r >= 0 and x+r <= w and y-r >= 0 and y+r <= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3096
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, c;

int main(){
	cin >> n;
	
	c = -1;
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a;
		if(c == a){
			ans++;
			c = -1;
		}
		else{
			c = a;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(LL S){
    LL y2 = (LL)ceil(sqrt((double)S));
    LL x3 = y2;
    LL remain = y2 * x3 - S;
    LL x2;
    if (remain == 0) x2 = 0;
    else x2 = 1;
    cout << "0 0 " << x2 << " " << y2 << " " << x3 << " " << remain << endl;
}

int main(){
    LL S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "No";
    rep(i, s.size()) {
        if(s[i] == 'C'){
            for(int j = i + 1; j < s.size(); j++) {
                if(s[j] == 'F') ans = "Yes";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
while True:
    n , x = map(int,input().split())
    if n == 0 and x == 0:
        break

    n_list = [int(x) + 1 for x in range(n)]
    p_list = list(itertools.combinations(n_list,3))
    r = 0
    for p in p_list:
        if p[0] + p[1] + p[2] == x:
            r += 1
    print(r)



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

int main() {
  int a, b, n;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int d1 = i % 10;
    int d2 = i % 100 / 10;
    int d3 = i % 1000 / 100;
    int d4 = i % 10000 / 1000;
    int d5 = i / 10000;
    if (d1 + d2 + d3 + d4 + d5 >= a && d1 + d2 + d3 + d4 + d5 <= b)
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((b/a)>=c){
        cout<<c<<endl;
    }else{
        cout<<(b/a)<<endl;
    }
  
return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[int(input())for _ in range(n)]
ans=sum(s)

x=[]
for i in range(n):
    if s[i]%10 != 0:
        x.append(s[i])
if ans%10 != 0:
    print(ans)
elif len(x)>=1:
    print(ans-min(x))
else:
    print(0)

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll COM(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 gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<pair<int,int>> works;
    int a,b;
    REP(i,N){
        cin>>a>>b;
        works.pb(mp(a,b));
    }
    sort(all(works),compare_by_b);
    string ans;ans="Yes";
    int now;now=0;
    REP(i,N){
        now+=works[i].first;
        if(now>works[i].second){
            print("No");
            return 0;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 2420
N = int(input())
As = list(map(int, input().split()))
 
A = set(As)
 
if 0 in A:
  print(0)
  exit()

rlt = 1
for i in As:
  if i > 1e18:
    print(-1)
    exit()
  else:
    rlt *= i
    if rlt > 1e18:
      print(-1)
      exit()
      
print(rlt)

Measured memory_bytes: 95696
// Problem : D - Friend Suggestions
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll ind=0;
vector<ll> vis,leader;
vector<vector<ll> > adj,adj2;
vector<ll> comp[100005];
ll n,m,k;
void dfs(ll u)
{
	vis[u]=1;
	comp[ind].pb(u);
	for(auto i:adj[u])
	{
		if(vis[i]==0)
			dfs(i);
	}
}
void solve()
{
    cin>>n>>m>>k;
    ll a,b;
    adj.resize(n+1);
    leader.resize(n+1);
    adj2.resize(n+1);
    for(ll i=0;i<m;i++)
    {
    	cin>>a>>b;
    	adj[a].pb(b);
    	adj[b].pb(a);
    }
    vector<pll> v;
    for(ll i=0;i<k;i++)
    {
    	cin>>a>>b;
    	adj2[a].pb(b);
    	adj2[b].pb(a);
    	v.pb({a,b});
    }
    vis.resize(n+1,0);
    for(ll i=1;i<=n;i++)
    {
    	leader[i]=i;
    	if(vis[i]==0)
    	{
    		dfs(i);
    		ind++;
    	}
    }
    vector<ll> cnt(n+1,0);
    for(ll i=0;i<ind;i++)
    {
    	for(ll j=0;j<comp[i].size();j++)
    	{
    		cnt[comp[i][j]]=comp[i].size();
    		leader[comp[i][j]]=comp[i][0];
    	}
    }
    for(auto i:v)
    {
    	a=i.fir;
    	b=i.sec;
    	if(leader[a]==leader[b])
    	{
    		cnt[a]--;
    		cnt[b]--;
    	}
    }
    for(ll i=1;i<=n;i++)	
    	cout<<cnt[i]-1-adj[i].size()<<" ";
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 21488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int v[n],c[n],d[n];
  for (int i=0; i<n; i++) cin >> v[i];
  for (int i=0; i<n; i++) cin >> c[i];
  for (int i=0; i<n; i++) d[i] = v[i]-c[i];
  int sum = 0;
  for (int i=0; i<n; i++){
    if (d[i] > 0) sum += d[i];
  }
    cout << sum << endl;
}


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

const int N = 1e5 + 5, mod = 1e9 + 7;
int k;
ll ans, root;
bool vis[N];
vector<int> v[N];

void dfs(int node)
{
    vis[node] = true;
    ll beg = k - 1;
    if (root != node)
        beg--;
    for (auto it: v[node])
        if (!vis[it])
        {
            ans = (ans * max(beg--, 0LL)) % mod;
            dfs(it);
        }
}

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    int n;
    cin >> n >> k;
    for (int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ans = k;
    for (int i = 1; i <= n; i++)
        if (v[i].size() == 1 && !vis[i])
            root = i,
            dfs(i);
    cout << ans;
    return 0;
}

Measured memory_bytes: 10496
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            
            for (int i = 0; i < length; i++) {
                char ch = line.charAt(i); // 文字列(line)からi番目の文字を取り出す
                // Character.isLowerCase で小文字かどうか判断可能
                if( Character.isLowerCase(ch)){
                    ch = Character.toUpperCase(ch);
                }else{
                    ch = Character.toLowerCase(ch);
                }
                answer += String.valueOf(ch);
                // Character.toUpperCase, Character.toLowerCase で変換
                // 記号は上記メソッドで変換にかけても変化しない
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31564
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n)  for(int i=0;i<n;i++)
#define per(i,n)  for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
using namespace std;

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

    string s;
    cin >> s;
    bool flag = true;
    bool check = true;
    for (int i = 0; i < s.size(); i++){
        if (check){
            if(s[i] == 'h'){
                flag = true;
                check = false;
            }
            else {
                flag = false;
                break;
            }
        }
        else {
            if(s[i] == 'i'){
                flag = true;
                check = true;
            }
            else {
                     flag = false;
                     break;
            
            }
        }
    }
    if(s.size() % 2 != 0){
        cout << "No";
        return 0;
    }
    if (flag) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
module ABC124

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_C

  ! constants for this <module>
  integer(kind=INT32), parameter, private :: len_string_max = 100000_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1) :: given_string
  integer  (kind=INT32)                 :: num_operations(0:1)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(kind=INT32) :: itr

    ! STEP.01
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! count up the number of operations
    num_operations = 0_INT32

    do itr = 1_INT32, len_trim(given_string), 1_INT32
      if (mod(itr, 2_INT32) .ne. 0_INT32) then
        if (given_string(itr:itr) .ne. '0') num_operations(0) = num_operations(0) + 1_INT32
        if (given_string(itr:itr) .ne. '1') num_operations(1) = num_operations(1) + 1_INT32
      else
        if (given_string(itr:itr) .ne. '1') num_operations(0) = num_operations(0) + 1_INT32
        if (given_string(itr:itr) .ne. '0') num_operations(1) = num_operations(1) + 1_INT32
      end if
    end do

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') minval(num_operations(:))

    ! STEP.END
    return

  end subroutine task_C

end module ABC124

program main

  ! <module>s to import
  use, non_intrinsic :: ABC124

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int cnt = 0;

    for (int i = 1; i <= n; i++) {
      int tmp = sc.nextInt();
      if (((i % 2) == 1) && ((tmp % 2) == 1)) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

vector<int> inpt;

int ans;

int main(void) {
  // Here your code !
  for (int i = 0; i < 3; ++i) {
    int tmp;
    scanf("%d", &tmp);
    inpt.push_back(tmp);
  }

  sort(inpt.begin(), inpt.end());

  ans = inpt[0] + inpt[1];

  printf("%d\n", ans);

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> bricks(n);
    for (int i = 0; i < n; ++i) {
        cin >> bricks.at(i);
    }
    int ans = 0;
    int target = 1;
    for (int i : bricks) {
        if (i == target) {
            target++;
        }
    }
    if (target == 1) {
        cout << -1 << endl;
    } else {
        cout << n - (target - 1) << endl;
    }
}


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

int main(){
  int count=0;;
  char s[101];
  scanf("%s",s);
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){count++;}
  if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]){count++;}
  if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]){count++;}
  //printf("%c%c%c%c\n",s[0],s[1],s[2],s[3]);
  if(count==0){printf("%s\n","No");}
  else{printf("%s\n","Yes");}
  return 0;
}

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

using namespace std;
const int mod = 1e9 + 7;

int main() {
  long long t1, t2, a1, a2, b1, b2, ma, mb;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  if (a1 < b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  ma = a1 * t1 + a2 * t2;
  mb = b1 * t1 + b2 * t2;
  if (ma == mb) {
    cout << "infinity\n";
  } else if (ma > mb) {
    cout << "0\n";
  } else {
    long long l = (a1 - b1) * t1, r = mb - ma;
    cout << (l / r) * 2 + ((l % r) != 0 ? 1 : 0) << '\n';
  }
  return 0;
}


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

int main() {
  long long a,b,c; scanf("%lld %lld %lld", &a, &b, &c);
  long long k; scanf("%lld", &k);
  long long ans = a - b;
  if(k&1)
    ans = b - a;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int c = sc.nextInt();
    int r = sc.nextInt();
    int cn = sc.nextInt();
    int rn = sc.nextInt();
    System.out.println((c - cn) * (r - rn));
  }
}

Measured memory_bytes: 21716
import scala.io.StdIn
import scala.collection.mutable.ListBuffer

object Main extends App {
  val Array(h, w) = StdIn.readLine.split(" ").map(_.toLong)
  val beginH = math.max(1L, h*3/12)
  val endH   = math.max(2L, h*5/12)
  val beginW = math.max(1L, w*3/12)
  val endW   = math.max(2L, w*5/12)

  val res1 = {
    val list = ListBuffer.empty[Long]
    val m = h / 2L
    val res = (beginW to endW)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a =( h * i ) 
      list += a
      list += ( m * (w-i) )
      list += ( (h-m) * (w-i) )
      val r1 = list.max - list.min
      list.clear
      val k = (w-i) / 2L
      list += a
      list += ( k * h )
      list += ( (w-i-k) * h )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._1, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val res2 = {
    val list = ListBuffer.empty[Long]
    val m = w / 2L
    val res = (beginH to endH)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a = w * i
      list += a
      list += ( m * (h-i) )
      list += ( (w-m) * (h-i))
      val r1 = list.max - list.min
      list.clear
      val k = (h-i) / 2L
      list += a
      list += ( k * w )
      list += ( (h-i-k) * w )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._1, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val ans = math.min(res1, res2)
  println(ans)
}

Measured memory_bytes: 46924
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int count_r = 0;
    int count_b = 0;
    for (auto ch : s)
    {
        if (ch == 'R')
        {
            count_r++;
        }
        else
        {
            count_b++;
        }
    }
    cout << (count_r > count_b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC15
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;
            D = int.Parse(Console.ReadLine());

            if (D == 25)
                Console.WriteLine("Christmas");

            else if (D == 24)
                Console.WriteLine("Christmas Eve");

            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");

            else
                Console.WriteLine("Christmas Eve Eve Eve");

            Console.ReadKey();
        
    

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;

int N;
bool Count[8] = {};

int color(int rate) {
	return rate / 400;
}

int main() {
	cin >> N;
	int countEx = 0;
	int rate;
	for (int i = 0; i < N; i++) {
		cin >> rate;
		if (rate < 3200) Count[color(rate)] = true;
		else countEx++;
	}
	int countColors = 0;
	for (int i = 0; i < 8; i++) {
		if (Count[i]) countColors++;
	}
	cout << max(countColors, 1) << " " << countEx + countColors << endl;
	return 0;
}

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

int main() {
  int n, i, j, c[10000] = {}, max = 0;
  scanf("%d", &n);
  int a[n], x[n];

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
    if(max < a[i]) max = a[i];
    c[a[i]]++;
  }

  for(i = 1; i <= max; i++){
    c[i] += c[i-1];
  }

  for(j = n-1; j >= 0; j--){
    x[c[a[j]]-1] = a[j];
    c[a[j]]--;
  }

  for(i = 0; i < n; i++){
    printf("%d", x[i]);
    if(i != n-1) printf(" ");
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 17424
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int digitsum(int n) {
    int ret = 0;
    while(n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if(N % digitsum(N) == 0) {
        cout << "Yes" << endl;
    }  else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
fun main(args: Array<String>) {
    var (N, M) = listOfInt()
    val A = listOfLong()
    val Q = PriorityQueue<Long>(N, compareByDescending { it })
    for (n in 0 until N) {
        Q.add(A[n])
    }
    while (M > 0) {
        val e = Q.poll()!!
        Q.add(e / 2)
        M--
    }
    var ans = 0L
    while (Q.size > 0) {
        ans += Q.poll()!!
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }

Measured memory_bytes: 71920