akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifndef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve(int tc = 0)
{
	int l, r;
	cin >> l >> r;
	int ans = INT_MAX;
	for (int i = l; i <= min(r, l + 2020); ++i)
	{
		for (int j = i + 1; j <= min(r, l + 2020); ++j)
		{
			int x = ((i % 2019) * (j % 2019)) % 2019;
			ans = min(ans, x);
		}
	}
	cout << ans << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> sk(n, vector<int>(m, 0));
    vector<int> cost(n);
    for (int i = 0; i < n; ++i) {
        cin >> cost[i];
        for (auto& el : sk[i]) {
            cin >> el;
        }
    }

    int best = 1e9;
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector<int> cnt(m);
        int cst = 0;
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                cst += cost[i];
                for (int j = 0; j < m; ++j) {
                    cnt[j] += sk[i][j];
                }
            }
        }
        int ok = 1;
        for (auto el : cnt) {
            ok &= el >= x;
        }
        if (ok) {
            best = min(best, cst);
        }
    }
    if (best == 1e9) {
        cout << -1 << "\n";
    } else {
        cout << best << "\n";
    }

}



int main() {
//    std::ios::sync_with_stdio(false);
//    std::cin.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


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

int main() {
  char C[3][4];
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> C[i][j];
    }
  }
  cout << (C[1][1] == C[2][3] && C[1][2] == C[2][2] && C[1][3] == C[2][1] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int x,t=1;
        Scanner sc = new Scanner(System.in);
        while(true){
            x=sc.nextInt();
            if(x == 0) break;
            System.out.println("Case "+ t++ +": "+x);
        }
    }
}



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

int main(void){
    int N;
    cin >> N;
    int* v = new int[N];
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v,v+N);
    float alc = v[0];
    for(int i=1;i<N;i++){
        alc = float(alc + v[i])/2;
    }
    cout << alc << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
 
int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int a,b,n,t,ans=INT_MAX;
    cin >> n >> t;
    
    while(n--)
    {
		cin >> a >> b;
		if(b<=t)
			ans=min(ans,a);
	}
	
	if(ans==INT_MAX)
		cout << "TLE";
	else
		cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String a = cin.nextLine();
        int counter=0;

        for(int i =0; i<a.length();i++)
        {
            if(a.substring(i,i+1).equals("1"))
                counter++;
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,m;
bool ab[10][10];

int dfs(int v,int N,bool visit[10]){
	bool alv=true;
	int ans;
	for(int i=0;i<n;i++){
		if(!visit[i]){
			alv=false;
		}
	}
	if(alv){
		return 1;
	}
	int ret=0;
	for(int i=0;i<n;i++){
		if(!ab[v][i])continue;
		if(visit[i])continue;
		
		visit[i]=true;
		ret+=dfs(i,N,visit);
		visit[i]=false;
	}
	return ret;
}

int main(){
	cin>>n>>m;
	REP(i,m){
		int t,s;
		cin>>t>>s;
		t--,s--;
		ab[t][s]=true;
		ab[s][t]=true;
	}
	bool visit[n];
	REP(i,n)
		visit[i]=false;
	visit[0]=true;
	cout<<dfs(0,n,visit)<<endl;
	return 0;
}
	

Measured memory_bytes: 256
#include<stdio.h>
int main( )
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b)
	{
		printf("a > b\n");
	}
	else if(a < b)
	{
	    printf("a < b\n");	
	}	
	else if(a == b)
	    printf("a == b\n");
    return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int gcd(int x,int y){
  int r;
  if( x<y ) swap(x,y);
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int w,h,c;
  cin>>w>>h>>c;
  cout<<(w/gcd(w,h))*(h/gcd(w,h))*c<<"\n";;


  return 0;
}






Measured memory_bytes: 3228
from math import sqrt

n = int(input())

ans = 0

for i in range(2,int(sqrt(n))+1):
    if n%i==0:
        x = i
        y = n//i
        while y%x==0:
            y//=x
        if (y-1)%x==0:
            ans += 1
    elif (n-1)%i==0:
        if i**2==n-1:
            ans += 1
        else:
            ans += 2

if n>2:
    ans += 2
else:
    ans += 1

print(ans)


Measured memory_bytes: 40044
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();

        int cnt = 0;
        int max = 0;
        for (char ch: S) {
            if (ch == 'I') {
                cnt++;
                max = Math.max(cnt, max);
            } else {
                cnt--;
            }
        }
        System.out.println(max);

        return;
    }

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
	int n,arr[3],i=0;
	cin>>n;
	while(n)
	{
		arr[i]=n%10;
		n/=10;
		i++;
	}
	arr[0]==arr[2]?cout<<"Yes":cout<<"No";
	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
ans=0
dic={1:300000,2:200000,3:100000}

def rank(a):
  if a<=3:
    return dic[a]
  else:
    return 0

ans+=rank(x)
ans+=rank(y)

if x==1 and y==1:
  ans+=400000
  
print(ans)  

Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_string()
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let mut k = parse_line!(usize);

    if k <= 9 {
        println!("{}", k);
        return;
    }

    let mut oldv = (1..10).map(|c| c.to_string()).collect::<Vec<_>>();
    let mut newv = Vec::new();
    let mut cnt = 9;

    loop {
        for n in oldv.iter() {
            let n = n.chars().collect::<Vec<_>>();
            let l = n[n.len() - 1].to_digit(10).unwrap();

            for r in 0..10 {
                if std::cmp::max(l, r) - std::cmp::min(l, r) <= 1 {
                    let mut n = n.clone();
                    n.push(std::char::from_digit(r, 10).unwrap());
                    let n = n.into_iter().collect::<String>();
                    cnt += 1;
                    if cnt == k {
                        println!("{}", n);
                        return;
                    }

                    newv.push(n);
                }
            }
        }

        oldv = newv;
        newv = Vec::new();
    }
}


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

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a==1){
        if(b==1)
            cout<<"Draw"<<endl;
        else
            cout<<"Alice"<<endl;
    }else if(b==1)
        cout<<"Bob"<<endl;
    else if(a<b)
        cout<<"Bob"<<endl;
    else if(a>b)
        cout<<"Alice"<<endl;
    else
        cout<<"Draw"<<endl;
}

Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)5e5+9;

int BIT[26][MAXN];

void add(int k, int idx, int val, int n)
{
    while(idx<=n)
    {
        BIT[k][idx]+=val;
        idx+=idx&(-idx);
    }

    return ;
}

int query(int k, int idx, int n)
{
    int ret = 0;

    while(idx>0)
    {
        ret+=BIT[k][idx];
        idx-=idx&(-idx);
    }

    return ret;
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    string s;
    cin>>n>>s>>q;

    for(i=0; i<26; i++)
    {
        for(j=1; j<=n; j++)
            BIT[i][j] = 0;
    }

    for(i=0; i<n; i++)
    {
        add(s[i]-'a', i+1, 1, n);
    }

    while(q--)
    {
        cin>>k;

        if(k==1)
        {
            char c;
            cin>>x>>c;
            if(s[x-1]==c);
            else
            {
                add(s[x-1]-'a', x, -1, n);
                add(c-'a', x, 1, n);

                s[x-1] = c;
            }
        }
        else
            {
                int cnt = 0;
                cin>>l>>r;

                for(i=0; i<26; i++)
                {
                    v = query(i,r,n);
                    u = query(i,l-1,n);

                    if(v-u>0) cnt++;
                }

                cout<<cnt<<endl;
            }
    }

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

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

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int w, h;
char f[102][102];

bool ng(int x, int y) {
    return (x<0 or y<0 or x>=w or y>=h);
}

void dfs(int x, int y) {
    char c = f[y][x];
    f[y][x] = '.';
    rep(i,4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(!ng(nx,ny) and f[ny][nx] == c) dfs(nx,ny);
    }
    return ;
}

int main() {
    while(cin>>h>>w and w) {
        rep(y,h) rep(x,w) cin >> f[y][x];
        
        int ans = 0;
        rep(y,h) rep(x,w) {
            if(f[y][x] == '.') continue;
            ans++;
            dfs(x, y);
        }

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

Measured memory_bytes: 1632
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n],b[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	b[0]=0,b[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;++i)
	{
		int min=(b[i-1]+abs(a[i-1]-a[i]));
		for(int j=k;j>1;--j)
		{
			if(i-j<0)
				continue;
			if(min>(b[i-j]+abs(a[i-j]-a[i])))
				min=b[i-j]+abs(a[i-j]-a[i]);
		}
		b[i]=min;
	}
	cout<<b[n-1]<<"\n";
}

Measured memory_bytes: 1024
HW = input()
masu = "none"
hw = HW.split()

Adata = []
for lop in range(int(hw[0])):
    A = input()
    Adata.append(A)

x = []
y = []
buf = ""
for lop in range(int(hw[0])):
    if str(Adata[lop]).find("#") == -1:
      x.append(lop)
      
for lop in range(int(hw[1])):
    for lop2 in range(int(hw[0])):
        buf = buf + str(Adata[lop2][lop])
    if str(buf).find("#") == -1:
        y.append(lop)
    buf = ""

for lop in range(len(x)-1,-1,-1):
    Adata.pop(x[lop])


ans = []
for lop in range(len(Adata)):
    buf = list(Adata[lop])
    for lop2 in range(len(y)-1,-1,-1):
        buf.pop(y[lop2])
    ans.append(buf)

for lop in range(len(ans)):
    ANS = ""
    for lop2 in range(len(ans[0])):
        ANS += ans[lop][lop2]
    print(ANS)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> a(N);

    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int pa=0,pb=0;

    for(int i=0;i<N;i++){
        if((i+1)%2==1){
            pa += a.at(i);
        }
        else{
            pb += a.at(i);
        }
    }

    cout << pa-pb << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
int main()
{
    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    int ans[N+1];
    ans[0]=0;
    for(int i=0;i<N;i++){
        if(i>0&&S[i]=='C'&&S[i-1]=='A'){
            ans[i+1]=ans[i]+1;
        }
        else{
            ans[i+1]=ans[i];
        }
    }

    for(int q=0;q<Q;q++){
        int l,r;
        cin >> l >> r;
        int k=ans[r]-ans[l-1];
        if(ans[l]-ans[l-1]==1){
            k--;
        }
        cout << k << '\n';
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int n;
    cin >> n;
    vll a(n);
    fori(i,0,n) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    vll b;
    ll ans = 0;
    b.push_back(a[0]);
    fori(i,1,n) {
        b.push_back(a[i]);
        b.push_back(a[i]);
    }
    fori(i,0,n-1) ans += b[i];

    
    
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 8968
import java.util.*

fun main(args: Array<String>) {
    codefestival2017qualbb()
}

fun codefestival2017qualbb() {
    val n = readLine()!!.toInt()
    val dList = readLine()!!.split(' ').map { it.toLong() }
    val m = readLine()!!.toInt()
    val tList = readLine()!!.split(' ').map { it.toLong() }

    val dQueue = PriorityQueue(dList)
    val tQueue = PriorityQueue(tList)
    while (tQueue.isNotEmpty()) {
        val t = tQueue.poll()
        while (true) {
            if (dQueue.isEmpty()) return println("NO")
            if (t == dQueue.poll()) break
        }
    }

    val answer = if (tQueue.isEmpty()) "YES" else "NO"

    println(answer)
}


Measured memory_bytes: 126520
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

bool isodd[1 << 22];
char bicnt[1 << 22];

bitset<512>dp[1 << 7];
bitset<512>ndp[1 << 7];
bitset<64>dp2[1 << 22];
bitset<64>ndp2[1 << 22];


int main() {
	int n, m;
	for (int i = 0; i < (1 << 22); ++i) {
		for (int j = 0; j < 22; ++j) {
			isodd[i] ^= ((i & (1 << j)) > 0);
			bicnt[i] += ((i & (1 << j)) > 0);
		}
	}
	while (cin >> n >> m, n) {
		vector<string>raw;
		for (int i = 0; i < n; ++i) {
			string tmp; cin >> tmp;
			raw.push_back(tmp);
		}
		if (n <= m) {
			//横長にみる
			vector<bool>flag(1 << n, true);
			for (int j = 0; j < m; ++j) {
				int value = 0;
				for (int i = 0; i < n; ++i) {
					value += ((raw[i][j] - '0') << i);
				}
				for (int i = 0; i < (1 << n); ++i) {
					if (isodd[value & i]) {
						flag[i] = false;
					}
				}
			}
			int ans = 0;
			for (int i = 0; i < (1 << n); ++i) {
				if (flag[i])ans = max(ans, (int)bicnt[i]);
			}
			cout << ans << endl;
		}
		else {
			//縦長にみる
			if (m <= 7) {
				for (int b = 0; b < (1 << m); ++b) {
					dp[b] = bitset<512>(0);
				}
				dp[0] = bitset<512>(1);
				for (int i = 0; i < n; ++i) {
					int value = 0;
					for (int j = 0; j < m; ++j) {
						value <<= 1;
						value += (raw[i][j] - '0');
					}
					for (int b = 0; b < (1 << m); ++b) {
						ndp[b] = dp[b] | (dp[b ^ value] << 1);
					}
					for (int b = 0; b < (1 << m); ++b) {
						dp[b] = ndp[b];
					}
				}
				int ans = 0;
				for (int i = 0; i <= n; ++i) {
					if (dp[0][i]) {
						ans = i;
					}
				}
				cout << ans << endl;
			}
			else {
				for (int b = 0; b < (1 << m); ++b) {
					dp2[b] = bitset<64>(0);
				}
				dp2[0] = bitset<64>(1);
				for (int i = 0; i < n; ++i) {
					int value = 0;
					for (int j = 0; j < m; ++j) {
						value <<= 1;
						value += (raw[i][j] - '0');
					}
					for (int b = 0; b < (1 << m); ++b) {
						ndp2[b] = dp2[b] | (dp2[b ^ value] << 1);
					}
					for (int b = 0; b < (1 << m); ++b) {
						dp2[b] = ndp2[b];
					}
				}
				int ans = 0;
				for (int i = 0; i <= n; ++i) {
					if (dp2[0][i]) {
						ans = i;
					}
				}
				cout << ans << endl;
			}
		}
	}
	return 0;
}



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

using namespace std;

int main()
{
	char num[11];
	int a, b;
	bool flag = true;
	
	cin >> a >> b;
	cin >> num;
	
	if (num[a] != '-') flag = false;
	
	for (int i = 0; i < a + b + 1; i++){
		if (i != a && !(num[i] >= '0' && num[i] <= '9')) flag = false;
	}
	
	if (flag == false) cout << "No" << "\n";
	else cout << "Yes" << "\n";
	
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll n = len(s);
    vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));
    dp[n][0] = 1;
    ll k = 1;
    rrep(i, n) {
        set<ll> pat;
        if (s[i] == '?') rep(i, 10) pat.insert(i);
        else pat.insert(s[i] - '0');
        for(auto x : pat) {
            rep(j, 13) {
                ll next = (j + k * x) % 13;
                dp[i][next] = (dp[i][next] + dp[i + 1][j]) % mod;
            }
        }
        k = (k * 10) % 13;
    }
    cout << dp[0][5] << endl;
    return 0;
}


Measured memory_bytes: 13648
# 前から順に見ていき、Tなら+1点、Sなら-1点とする。
# 最後まで見たときの途中の最高得点が、最後に残るTの個数。なので答えはその2倍。

# 理由：
# 最高得点a点とすると、その左側ではTがSよりもa個多いので、そのa個は消せない。右側にいくらSがあっても関係ない。
# その他が全部消える理由はイメージ的にはそんな気がするが、ちゃんとは分からない……

s = input()
score = max_score = 0
for ch in s:
    if ch == "T":
        score += 1
        max_score = max(score, max_score)
    elif ch == "S":
        score -= 1
print(max_score * 2)


Measured memory_bytes: 3500
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

public class Main {

	class P {
		double x, y;

		P(double x_, double y_) {
			x = x_;
			y = y_;
		}

		P add(P p) {
			return new P(x + p.x, y + p.y);
		}

		P sub(P p) {
			return new P(x - p.x, y - p.y);
		}

		P mul(double v) {
			return new P(x * v, y * v);
		}

		P div(double v) {
			return new P(x / v, y / v);
		}

		double dot(P p) {
			return x * p.x + y * p.y;
		}

		double det(P p) {
			return x * p.y - y * p.x;
		}

		double abs2() {
			return x * x + y * y;
		}

		double abs() {
			return Math.sqrt(abs2());
		}

		P norm() {
			return div(abs());
		}

		P rot90() {
			return new P(-y, x);
		}

		P proj(P src, P dst) {
			P p_sd = dst.sub(src).norm();
			return src.add(p_sd.mul(sub(src).dot(p_sd)));
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		P src = new P(sc.nextDouble(), sc.nextDouble());
		P dst = new P(sc.nextDouble(), sc.nextDouble());
		int q = sc.nextInt();
		while (q-- > 0) {
			P p = new P(sc.nextDouble(), sc.nextDouble());
			P x = p.proj(src, dst);
			System.out.println(x.x + " " + x.y);
		}
	}

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 41872
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a * b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

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

ll a[200005];
map<ll,ll> b;

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

    rep(i,n){
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    //計算を効率化するためにbaseを作る
    ll base=0;
    for(auto item:b){
        base += ((item.second)*(item.second-1))/2;
    }

    for(int i=0; i<n; i++){
        ll num=a[i];
        //baseとの差はnC2-n-1C2
        cout << base - (b[num]*(b[num]-1)/2)+((b[num]-1)*(b[num]-2)/2) << endl;
    }
}

Measured memory_bytes: 13112
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.conv;

void main() {
	auto N = readln.chomp.to!int;
	int alice, bob;
	auto a = readln.split.to!(int[]);
	a.sort!"a > b";

	foreach(i; 0..N) {
		if(i & 1) bob += a[i];
		else alice += a[i];
	}
	(alice - bob).writeln;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <cstdio>

using namespace std;

int main(){
	int N,T;
	cin>>N>>T;
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	int mxVal=A[N-1];
	int best=0,cnt=0;

	for(int i=N-2;i>=0;i--){
		if(mxVal-A[i]>best){
			best=mxVal-A[i];
			cnt=1;
		}else if(mxVal-A[i]==best){
			cnt++;
		}
		mxVal=max(mxVal,A[i]);

	}
	cout<<cnt<<endl;
	return 0;	
}


Measured memory_bytes: 640
#include<string>
#include<iostream>
using namespace std;
int main(){
	string x;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}		
	}
	return 0;
}

Measured memory_bytes: 1120
n = int(input())
a = [int(input()) for _ in range(n)]

a.sort()

ans = 0
tmp = 1

for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        ans += tmp % 2
        tmp = 1

if tmp%2 == 1:
    ans += 1

print(ans)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int n,k,l,r;
	cin>>n>>k;
	int a[n];
	int b[n];
	for(auto &i:a)cin>>i;
	int t[n];
	bool eq;
	for(int i=0;i<n;i++)t[i]=n;
	while(k--)
	{
		eq=1;
		for(int i=0;i<n;i++)b[i]=0;
		for(int i=0;i<n;i++)
		{
			l=max(0LL,i-a[i]);
			r=min(n-1,i+a[i]);
			b[l]++;
			if(r+1<n)b[r+1]--;
		}
		
		for(int i=1;i<n;i++)
		{b[i]+=b[i-1];}
		for(int i=0;i<n;i++)
		a[i]=b[i];
		
		for(int i=0;i<n;i++)
		{if(a[i]!=t[i]){eq=0;break;}}
		if(eq)break;
	}
	for(auto i:a)cout<<i<<" ";
}

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

ll lcm(ll x, ll y) { return (x * y) / __gcd(x, y); }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] mat = new int[n][m];
        int[] vec = new int[m];
        int[] res = new int[n];
         
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                mat[i][j] = sc.nextInt();
            }
        }
         
        for (int i = 0; i < m; i++) {
            vec[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                res[i] += mat[i][j] * vec[j];
            }
            System.out.println(res[i]);
        }
         
    }
}



Measured memory_bytes: 40676
S = input()


mae = int(S[0:2])
ato = int(S[2:4])

if mae >= 1 and mae <=12 and ato >= 1 and ato <= 12:
    print("AMBIGUOUS")
elif mae >= 0 and ato >= 1 and ato <=12:
    print("YYMM")
elif mae >= 1 and mae <=12  and ato >= 0:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  
  double concentration = 0;
  int water = 0, sugar = 0;
  for (int i = 0; i <= 30; i++) {
    for (int j = 0; j <= 30; j++) {
      for (int k = 0; k <= ceil((double)f/c); k++) {
        for (int l = 0; l <= ceil((double)f/d); l++) {
          int water_weight = a * i + b * j;
          int sugar_weight = c * k + d * l;
          int total = 100 * water_weight + sugar_weight;
          if (total <= f && sugar_weight <= e * water_weight && concentration < (double) sugar_weight / total) {
            concentration = (double) sugar_weight / total;
            water = 100 * water_weight;
            sugar = sugar_weight;
          }
        }
      }
    }
  }
  if (concentration == 0) {
    water = 100 * a;
  }
  cout << water + sugar << " " << sugar << endl;
  return 0;
}


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

using namespace std;

string N;

int main() {
	cin >> N;
	int ans = N[0] - '0';
	for (int i = 1; i < N.size(); i++) {
		if (N[i] != '9')goto next;
		ans += (N[i] - '0');
	}
	cout << ans << endl;
	return 0;
next:;
	cout << (N[0] - '0' - 1) + (N.size() - 1) * 9 << endl;
	return 0;
}

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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};
using Mint = ModInt<>;

int main()
{
	int64_t N, K;
	scanf("%lld%lld", &N, &K);
	std::vector<int> A(N);
	for (auto& e: A) scanf("%d", &e);
	Mint ans(0ll);
	for (int i{}; i < N; i++)
		for (int j{}; j < i; j++)
			if (A[j] > A[i])
				ans += Mint(1ll);
	ans *= Mint(K);
	std::vector<int> greater(N);
	for (int i{}; i < N; i++)
		for (int j{}; j < N; j++)
			if (A[j] > A[i])
				greater[i]++;
	
	for (int i{}; i < N; i++)
		ans += Mint(greater[i]) * Mint(K) * Mint(K - 1) / Mint(2);

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

	return 0;
}

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

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 2 * k;
	for (int i = 1; i < n; ++i)
		if (s[i] == s[i - 1]) ans++;
	cout << min(ans, n - 1) << endl;

	return 0;
}

Measured memory_bytes: 512
def abc091_b():
    from collections import Counter
    _strs = []
    _strt = []
    _max = 0
    _n = int(input())
    for i in range(_n):
        _strs.append(str(input()))
    _m = int(input())
    for i in range(_m):
        _strt.append(str(input()))
    _strs2 = list(set(_strs))
    for element in _strs2:
        _score = Counter(_strs)[element] - Counter(_strt)[element]
        if _score > _max:
            _max = _score
    print(_max)


abc091_b()

Measured memory_bytes: 3316
//121A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H, W =0;
    int h, w =0;
    int ans =0;
    cin >> H >> W;
    cin >> h >> w;
    ans = H*W -(H*w + W*h - (h*w));
    cout << ans;
}

Measured memory_bytes: 256
program main
  implicit none
  integer i, A(5), ans
  !read(*, *)
  read(*, *) (A(i), i = 1,5)
  ans = 0
  do i = 1,5
    if (A(i) == 0) then
      ans = i
    endif
  end do
  write(*, *) ans
end program main


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll N;
    cin >> N;

    auto div = divisor(N);

    auto dd = divisor(N-1);
    ll res = (int)dd.size()-1;
    //dump(res)

    for(auto x: div){
        if(x==1) continue;
        //dump(x)
        ll P = N;
        while(1){
            if(P%x != 0) break;
            P /= x;
        }
        if(P % x ==1) res++;
    }

    cout << res << endl;
    return 0;
}

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


multiset<double> ms;
int main() {
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++) {
	    double x;
	    cin>>x;
	    ms.insert(x);
	}
	
	while(ms.size()>1) {
	    double a=* ms.begin();
	    ms.erase(ms.begin());
	    double b= *ms.begin();
	    ms.erase(ms.begin());
	    double tans =(a+b)/2.0;
	    ms.insert(tans);
	}
	cout<<setprecision(12);
	cout<<*ms.begin()<<"\n";
	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
	val n = readLine()!!.toInt()
	val s = readLine()!!
	
	val e=s.count { it=='E' }
	var cost = if(s.first()=='W') e else e-1
	var minCost= cost

	for(i in 1 until n){
		if(s[i]=='E') cost--
		if(s[i-1]=='W') cost++
		minCost=Math.min(minCost,cost)
	}
	println(minCost)
}

Measured memory_bytes: 36600
n = gets.to_i
xs = [gets.split.map(&:to_i), gets.split.map(&:to_i)]
memo = [[0] * n, [0] * n]
2.times do |i|
  n.times do |j|
    memo[i][j] =
    if i == 0
      if j == 0
        xs[0][0]
      else
        memo[i][j-1] + xs[i][j]
      end
    else
      if j == 0
        memo[i-1][j] + xs[i][j]
      else
        [memo[i][j-1], memo[i-1][j]].max + xs[i][j]
      end
    end
  end
end
p memo[1][n-1]


Measured memory_bytes: 1788
package main

import "fmt"

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func main()  {
	var n int
	fmt.Scan(&n)


	ac := 0;
	wa := 0;
	tle := 0;
	re := 0;

	result := scanStrings(n)
	for i := range result {
		col := result[i]

		if col == "AC"{
			ac += 1
		}else if col == "WA"{
			wa += 1
		}else if col == "TLE"{
			tle += 1
		}else if col == "RE"{
			re += 1
		}
	}

	fmt.Println("AC x", ac)
	fmt.Println("WA x", wa)
	fmt.Println("TLE x", tle)
	fmt.Println("RE x", re)

}


Measured memory_bytes: 11216
#include "bits/stdc++.h"
using namespace std;
int keta(long long int x){
    int p=0;
    long long int y;
    y=x;
    while(y>0){
        y /= 10;
        p++;
    }
    return p;
}
int main(){
    long long int n,a;
    int ans=100,tmp;
    cin >> n;
    for(a=1;a<=sqrt(n);a++){
        if(n%a) continue;
        tmp=max(keta(a),keta(n/a));
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// include
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <array>

int N, K;





void dumpVector(std::vector<int>& v) {
  int size = v.size();
  for (int i = 0; i < size; ++i) {
    std::cout << v[i] << " ";
  }
  std::cout << std::endl;
}


int main() {


  std::cin >> N >> K;
  std::vector<int> denkyu(N);
  
  //	電球の強さ取得
  for (int i = 0; i < N; ++i) {
    std::cin >> denkyu[i];
  }
  
  
  //	K回繰り返す
  for (int k = 0; k < K; ++k) {
    std::vector<int> ruisekiwa(N+1);
    // 入り口出口マーキング
    for (int i = 0; i < N; ++i) {
      int left = std::max(0, i-denkyu[i]);
      int right = std::min(i+denkyu[i]+1, N);
//      std::cout << left << ":" << right << std::endl;
      ruisekiwa[left]++;
      ruisekiwa[right]--;      
    }
    //加算
    for (int i = 0; i < N; ++i) {
      ruisekiwa[i+1] += ruisekiwa[i]; // 最初の要素は加算無し
    }
    ruisekiwa.pop_back();
    
    if (ruisekiwa == denkyu) {
  		dumpVector(denkyu);
	  	return 0;
    }
    denkyu = ruisekiwa;
  }
  
  
    
  dumpVector(denkyu);
  return 0;
  
}




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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    REP(i,0,W+2) {
        S[0] += ".";
        S[H+1] += ".";
    } 
    REP(i,1,H+1) {
        cin >> S[i];
        S[i] = "." + S[i] + ".";
    }

    REP(i,1,H+1) {
        REP(j,1,W+1) {
            if(S[i][j] == '#') cout << "#";
            else {
                ll cnt = 0;
                REP(di,-1,2) {
                    REP(dj,-1,2) {
                        if(di == 0 && dj == 0) continue;
                        if(S[i+di][j+dj] == '#') ++cnt;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3604
a = list(map(int,input().split()))
fcount = 0
scount = 0
for i in range(3):
	if a[i] == 5:
		fcount +=1
	elif a[i] == 7:
		scount += 1
if fcount == 2 and scount == 1:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
 
int main()
{
	int N,a,b,c,x,y,t,vis = 1,p;
	scanf("%d",&N);
	a = 0;
	b = 0;
	c = 0;
	while(N--)
	{
		scanf("%d %d %d",&t,&x,&y);
		a = t - a;
		b = abs(x - b);
		c = abs(y - c);
		p = abs(b+c-a);
		if(b + c > a) 
		{ 
			vis = 0;
		}
		else if(p % 2 !=0)
		{
			vis = 0;
		}
		a = t;
		b = x;
		c = y;
	}
	if(vis == 1) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    int A[3];
    rep(i, 3) cin >> A[i];
    sort(A, A + 3);//2 4 5
    while(!(A[0] == A[1] && A[1] == A[2])){
        if(A[2] - A[0] >= 2){
            A[0] += 2;
            cnt++;
        }
        else{
            A[0]++;
            A[1]++;
            cnt++;
        }
        sort(A, A + 3);
    }
    cout << cnt << endl;
    //cout << A[0] << " " << A[1] << " " << A[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(20)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    string S;
    int Q;
    cin >> N >> S >> Q;
    long back_M_now = 0;
    long back_M[N];
    long back_M_cumulative_sum[N + 1], is_C_cumulative_sum[N + 1];
    back_M_cumulative_sum[0] = 0;
    is_C_cumulative_sum[0] = 0;
    for(int i = 0; i < N; i++){
        back_M[i] = back_M_now;
        if(S[i] == 'C'){
            back_M_cumulative_sum[i + 1] = back_M_cumulative_sum[i] + back_M_now;
        }else{
            back_M_cumulative_sum[i + 1] = back_M_cumulative_sum[i];
        }
        back_M_now += (S[i] == 'M');
        is_C_cumulative_sum[i + 1] = is_C_cumulative_sum[i] + (S[i] == 'C');
    }
    for(int i = 0; i < Q; i++){
        int k;
        cin >> k;
        long ans = 0;
        for(int j = 0; j < N; j++){
            if(S[j] == 'D'){
                ans += back_M_cumulative_sum[min(N, j + k)] - back_M_cumulative_sum[j] - back_M[j] * (is_C_cumulative_sum[min(N, j + k)] - is_C_cumulative_sum[j]);
            }
        }
        cout << ans << endl;
    }
}



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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl '\n'

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n = in();
  vi v;
  rep(i, n) v.push_back(in());
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] << endl;

  return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int compar(const int *val1, const int *val2);
int poker(int *ary);

int main(void) {
	int ary[5];
	int n;
	int i,m;
	char str[100],*line;

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		line=strtok(str,", ");
		sscanf(line,"%d",&m);
		ary[0]=m;
		for(i=1;i<5;i++){
			line=strtok(NULL,", ");
			sscanf(line,"%d",&m);
			ary[i]=m;
		}
		n = sizeof(ary)/sizeof(ary[0]);
		qsort(ary, n, sizeof(int),(int (*)(const void *, const void *))compar);
		poker(ary);
	}
	return 0;
}

int compar(const int *val1, const int *val2) {
	if( *val1 < *val2 )
		return -1;
	else if( *val1 == * val2 )
        	return 0;
	else
		return 1;
}

int poker(int *ary){
	if((ary[0]==ary[1] && ary[1]==ary[2] && ary[2]==ary[3]) || (ary[1]==ary[2] && ary[2]==ary[3] && ary[3]==ary[4]))
		printf("four card\n");
	else if((ary[0]==ary[1] && ary[1]==ary[2]) && (ary[3]==ary[4]) || (ary[2]==ary[3] && ary[3]==ary[4]) && (ary[0]==ary[1]))
		printf("full house\n");
	else if((ary[0]==ary[1]-1 && ary[1]==ary[2]-1) && (ary[2]==ary[3]-1) && (ary[3]==ary[4]-1))
		printf("straight\n");
	else if((ary[0]==ary[1]-9 && ary[1]==ary[2]-1) && (ary[2]==ary[3]-1) && (ary[3]==ary[4]-1))
		printf("straight\n");
	else if((ary[0]==ary[1] && ary[1]==ary[2]) || (ary[1]==ary[2] && ary[2]==ary[3]) || (ary[2]==ary[3] && ary[3]==ary[4]))
		printf("three card\n");
	else if((ary[0]==ary[1] && ary[2]==ary[3]) || (ary[0]==ary[1] && ary[3]==ary[4]) || (ary[1]==ary[2] && ary[3]==ary[4]))
		printf("two pair\n");
	else if(ary[0]==ary[1] || ary[1]==ary[2] || ary[2]==ary[3] || ary[3]==ary[4])
		printf("one pair\n");
	else
		printf("null\n");
	return 0;
}

Measured memory_bytes: 592