akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;

		int N = sc.nextInt();
		int[] S = new int[N];
		for(int i = 0; i < N; i++) {
			S[i] = sc.nextInt();
		}
		insertionSort(S, N);

		int Q = sc.nextInt();
		for(int i = 0; i < Q; i++) {
			int t = sc.nextInt();
			ans += binary_search(S, t, 0, N-1);
		}

		System.out.println(ans);
		sc.close();
	}

	// 見つかれば1、見つからなければ0
	public static int binary_search(int[] a, int x, int left, int right) {
		if(left > right) {
			return 0;
		}else {
			int mid = (left + right) / 2;
			if(a[mid] == x) {
				return 1;
			}else if(a[mid] < x) {
				return binary_search(a, x, mid+1, right);
			}else {
				return binary_search(a, x, left, mid-1);
			}
		}
	}

	// 挿入ソート
		static void insertionSort(int[] a, int n) {
			for(int i = 1; i < n; i++) {
				int v = a[i];   // 挿入する要素の保存
				int j = i - 1;
				while(j >= 0 && a[j] > v) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = v;
			}
		}
}


Measured memory_bytes: 68428
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll hell=pow(10,9);
class Tree{
	ll t[800005],lazy[800005];
	public:
	Tree(ll n){
		for(ll i=0;i<800005;i++)
			t[i]=n,lazy[i]=hell;
	}
	void push(ll v){
		ll &x=lazy[v];
		t[2*v]=min(t[2*v],x);
		t[2*v+1]=min(t[2*v+1],x);
		lazy[2*v]=min(lazy[2*v],x);
		lazy[2*v+1]=min(lazy[2*v+1],x);
		x=hell;
	}
	void upd(ll v,ll tl,ll tr,ll l,ll r,ll val){
		if(l>r)
			return;
		if(l==tl&&r==tr){
			t[v]=min(t[v],val);
			lazy[v]=min(lazy[v],val);
			return;
		}
		push(v);
		ll tm=(tl+tr)/2;
		upd(2*v,tl,tm,l,min(r,tm),val);
		upd(2*v+1,tm+1,tr,max(l,tm+1),r,val);
		t[v]=min(t[2*v],t[2*v+1]);
	}
	ll get(ll v,ll tl,ll tr,ll pos){
		if(tl==tr)
			return t[v];
		push(v);
		ll tm=(tl+tr)/2;
		if(pos<=tm) 
			return get(2*v,tl,tm,pos);
		else
			return get(2*v+1,tm+1,tr,pos);
	}
}; 
void solve(){
	ll n,q;
	cin>>n>>q;
	ll res=(n-2)*(n-2);
	Tree *t1 = new Tree(n);
	Tree *t2 = new Tree(n);
	for(ll i=0;i<q;i++){
		ll op,x;
		cin>>op>>x;
		if(op==1){
			ll val=(t1->get(1,1,n,x));
			res-=val-2;
			t2->upd(1,1,n,1,val-1,x);
		}
		else{
			ll val=(t2->get(1,1,n,x));
			res-=val-2;
			t1->upd(1,1,n,1,val-1,x);
		}
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 28772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

int main() {
	int l, r;
	cin >> l >> r;

	long long ans = 3000;

	if (r - l > 2019)
		cout << 0 << endl;

	else {
		for (long long i = l; i <= r-1; i++) {
			for (long long j = i+1; j <= r; j++) {
				ans = min((i * j) % 2019, ans);
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(b%a==0){cout<<(a+b);}
  else{cout<<(b-a);}
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i;
	char S[3][101] = {};
	for (i = 0; i < 3; i++) scanf("%s", S[i]);

	char *head[3] = {S[0], S[1], S[2]};
	int j, winner = -1, move = 0;
	while (winner == -1) {
		if (*(head[move]) != 0) move = *(head[move]++) - 'a';
		else winner = move;
	}
	
	printf("%c\n", winner + 'A');
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
vector<ll>bit;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
void add(ll a, ll w) {
	for (int x = a; x < 2*N; x += x & -x) {
		bit[x] += w;
	}
}
int sum(ll a) {
	int res = 0;
	for (int x = a; x > 0; x -= x & -x)res += bit[x];
	return res;
}

int main() {
	cin >> N;
	vector<ll>a(N+1),b(N+1),csum(N+2),copy(3*N,0);
	ll r = 0;
	ll l = 0;
	for (int i = 1; i < N+1; i++) {
		cin >> a[i];
		r = max(r, a[i]);
	}
	while (l<=r) {
		bit = copy;
		ll mid = (r + l) / 2;
		csum[1] = 0;
		for (int i = 1; i < N + 1; i++) {
			if (a[i] >= mid)b[i] = 1;
			else b[i] = -1;
			csum[i + 1] = csum[i] + b[i];
		}
		ll invN = 0;
		for (int i = 1; i < N + 2; i++) {
			invN += sum(csum[i]+N);
			add(csum[i]+N, 1);
		}
		if (invN >= N*(N+1)/4)l = mid+1;
		else r = mid - 1;;
	}
	cout << r << endl;
}


Measured memory_bytes: 7296
#include <stdio.h>

#define N 20
#define Q 200

int num_a,A[N];

int solve(int,int);

int main(){
    int M;
    int num_m;
    int i,j,k;
    

    scanf("%d",&num_a);

    for(i=0;i<num_a;i++){
        scanf("%d",&A[i]);
    }

    scanf("%d",&num_m);

    for(i=0;i<num_m;i++){
        scanf("%d",&M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }

    
    return 0;
}

int solve(int i,int m){
    if(m == 0) return 1;
    if(i >= num_a) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll H, W;
    cin >> H >> W;
    rep(y, H)rep(x, W){
        string s;
        cin >> s;
        if(s == "snuke"){
            cout << (char)(x + 'A') << y + 1 << endl;
        }
    }

    return 0;
}

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

int main(){
	int c1,c2,c3,n;
	while(cin >> c1){
		cin >> c2;
		cin >> c3;
		
		n=0;
		for(int i=0;i<10;i++){
			if(i==c1 ||i==c2 ||i==c3){
			}else if(c1+c2+i<20){
				n=n+1;
			}	
		}
		if(n>3){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define MOD 1000000007


int main() {
	int A,B,C;
	cin >> A>>B>>C;
	bool flag = true;
	if (A != B)flag = false;

	if (B != C)flag = false;
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I LOVE CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
       1.2019 is not divisible by 2 or 5, so there exists the inverse of 10 in mod2019=> that 10^k is not divisible by 2019
        why ? divisors of 2019 are 3,673 (where both of these are prime)
        2019=3*673 so for 10^k to be divivsible by 2019 it should be either divisible 3 or 673 which is neither the case..
       2.Let Tk be the digits after the k + 1-th digit, represented as an integer, that is, an + 10an−1 +
        ...+10n−k−1ak+1 (Tn = 0). Then, (i, j) satisfies the condition when Ti−1 == Tj (mod2019) (Here
         the discussion above was used).
        ==> suppose 12345678mod2019==5 and also 5678mod2019==5 so (12345678-5678)mod2019==0
        further (1234*10^4)mod2019==0 and as we know 10^4 cannot be multiple of 2019 definitely multiple comes from 1234..
       3.Ti = Ti+1 + 10^(n−i−1)*ai ,this obvious se label 1,2 in code
*/
//D-MULTIPLE OF 2019
//TC-nlogn
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void solve()
{
  string s;
  cin>>s;
  map<ll,ll>cnt;
  cnt[0]++;
  vector<ll>sum(s.size()+1,0);
  ll i;
  fo(i,0,sz(s))
  {
     
      ll t=(s[sz(s)-1-i]-'0')*modularExponentiation(10,i,2019)%2019;
      sum[i+1]=(sum[i]+t)%2019;
      cnt[sum[i+1]]++;

  }
  ll ans=0;
  for(auto x:cnt)
 {
    ans+=(ll)x.second*(x.second-1)/2;
 }
  cout<<ans<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

signed main(){
	int n;
	cin >> n;
	vector<tuple<int,int,int>> points;
	for(int t = 0;t < 2;t++){
		for(int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			points.emplace_back(x,y,t);
		}
	}
	sort(points.begin(),points.end());
	set<int> st;
	int ans = 0;
	for(int i = 0;i < n * 2;i++){
		int y,isBlue;
		tie(std::ignore,y,isBlue) = points[i];
		if(isBlue){
			auto it = st.lower_bound(y);
			if(it != st.begin()){
				it--;
				st.erase(it);
				ans++;
			}
		}else{
			st.insert(y);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define N 100010
long long int gcd(long long a, long long b) {
    return a%b==0?b:gcd(b,a%b);
}
int main(){
    int n,s;
    int t,l,r,d;
    while (scanf("%d",&n)!=EOF) {
        int ans = 0;
        for (int i=1;i<=n;i++) {

            scanf("%d",&s);
            if (i%2&&s%2) {
                ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}
/*
5
1 2 3 4 5
4
1 1 1 1
1 1 1 2
1 2 5 1
1 3 5 2
*/


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
int c[4];
string a[4]={"AC","WA","TLE","RE"};
string s;
int main(){
	cin>>n;
	rep(i,n){
		cin>>s;
		rep(j,4){
			if(s==a[j])c[j]++;
		}
	}
	rep(i,4){
		cout<<a[i]<<" x "<<c[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
N = int(input())
ans = []
for i in range(1, N+1):
    s, p = input().split()
    ans.append((s, int(p), i))
X = sorted([(s,p,i) for s,p,i in ans], key=lambda x: (x[0], -x[1]))
[print(x[2]) for x in X]


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
  int h;
  int h1=0,h2=0,h3=0;

  while(scanf("%d\n",&h)!=EOF) {
    if (h>h3) h3=h;
    if(h3>h2){int s=h2;h2=h3;h3=s;}
    if(h2>h1){int s=h1;h1=h2;h2=s;}
  }
  printf("%d\n",h1);
  printf("%d\n",h2);
  printf("%d\n",h3);
  return 0;
}

Measured memory_bytes: 604
# D - .. (Double Dots)
from collections import deque
from typing import List


def bfs(source, graph: List[List[int]], signposts: List[int]) -> None:
    queue = deque([source])
    while queue:
        u = queue.popleft()
        for v in graph[u]:
            if not signposts[v]:
                signposts[v] = u
                queue.append(v)


def main():
    N, M, *AB = map(int, open(0).read().split())

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    signposts = [0] * (N + 1)
    signposts[1] = 1
    bfs(1, graph, signposts)

    print("Yes")
    print("\n".join(map(str, signposts[2:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 56456
#include<stdio.h>
#include<string.h>
int ch[12]={1,3,5,7,8,10,12,4,6,9,11,2};
int main()
{
	int x,y;
	int a,b;
	scanf("%d%d",&x,&y);
	for(int i=0;i<12;i++)
	{
		if(ch[i]==x)
		{
			a=i;
        }
		if(ch[i]==y)
		b=i;
	}
	if(a>=0&&a<=6)
	{
		if(b>=0&&b<=6)
		printf("Yes\n");
		else
		printf("No\n");
	}
	else if(a>=7&&a<=10)
	{
		if(b>=7&&b<=10)
		printf("Yes\n");
		else
		printf("No\n");
	}
	else if(a==11)
	{
		if(b==11)
		printf("Yes\n");
		else
		printf("No\n");
	}
}

Measured memory_bytes: 128
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import Text.Printf

readInt = ( readLn :: IO Int )
getInts = map ( read :: String -> Int ) . words <$> getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	let
		chars = filter ( not . ( `elem` s ) ) [ 'a' .. 'z' ]
		res = map ( : "" ) chars ++ [ "None" ]
	putStrLn $ head res


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

int main()
{
  string s;
  cin >> s;
  bool abc[3] = {false, false, false};
  for(auto& i : s){
	abc[i - 'a'] = true;
  }
  if(abc[0]&&abc[1]&&abc[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#N,A,B=map(int, input().split())

#A=list(map(int, input().split()))

N=int(input())
N1=N

ans=0

while N>0:
    ans=ans+N%10
    N=N//10

if N1%ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  
  if(c == "a" ||c== "e" ||c== "i" ||c== "u" ||c== "o"){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)
#define Inf 2147483647
#define llInf 9223372036854775807

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	string ans = "";
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (j <= a && i <= b) {
				ans += "0";
			}
			else if (j > a&& i > b) {
				ans += "0";
			}
			else {
				ans += "1";
			}
		}
		ans += "\n";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2308
a, b, c, d = map(int, input().split())

m = -999999999999999999

ac = a * c
if ac >= m:
  m = ac

ad = a * d
if ad >= m:
  m = ad

bc = b * c
if bc >= m:
  m = bc

bd = b * d
if bd >= m:
  m = bd

print(m)


Measured memory_bytes: 9172
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

  private static void solve() {

    char[] s = ns();
    Deque<Character> qq = new ArrayDeque<>();
    for (char c : s) {
      qq.addLast(c);
    }

    int q = ni();
    boolean rev = false;

    for (int i = 0; i < q; i++) {
      int t = ni();
      if (t == 1) {
        rev = !rev;
      } else {
        boolean f = ni() == 1;
        char c = ns()[0];
        if (f == rev) {
          qq.addLast(c);
        } else {
          qq.addFirst(c);
        }
      }
    }

    StringBuilder sb = new StringBuilder();
    for (char c : qq) {
      sb.append(c);
    }
    if (rev) {
      sb.reverse();
    }
    System.out.println(sb);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

    int X1=0, X2=w, Y1=0, Y2=h;

    rep(i, n){
        int x, y, a;
        cin >> x >> y >> a;
        switch(a){
            case 1:
                X1 = max(x, X1);
                break;
            case 2:
                X2 = min(x, X2);
                break;
            case 3:
                Y1 = max(y, Y1);
                break;
            case 4:
                Y2 = min(y, Y2);
                break;
        }
    }


    ppp(max(X2-X1, 0) * max(Y2-Y1, 0));


    return 0;
}


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


using namespace std;

bool linerSearch(vector<int> data, int target) {
   for(int i = 0; i < data.size(); i++) {
      if(data[i] == target) {
         return true;
      }
   }

   return false;
}

int main () {
   int n;
   cin >> n;
   vector<int> S;
   for(int i = 0; i < n; i++) {
      int r;
      cin >> r;
      S.push_back(r);
   }

   int q;
   cin >> q;
   vector<int> T;
   for(int i = 0; i < q; i++) {
      int r;
      cin >> r;
      T.push_back(r);
   }

   int count = 0;
   for(int i = 0; i < q; i++) {
      if(linerSearch(S, T[i])) {
         count ++;
      }
   }

   cout << count << endl;
}

   



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll a,b,c,d,e,f,g,h,w,s;
  db q=0;
  cin>>a>>b>>c>>d>>e>>f;
  fr(i,31){
    fr(j,16){
      fr(k,101){
        fr(l,51){
          w=100*(a*i+b*j);
          s=c*k+d*l;
          if(100*s<q*(w+s)||s>e*(w/100)||w+s>f) continue;
          g=w+s;
          h=s;
          q=(100.0*h)/g;
        }
      }
    }
  }
  cout<<g<<" "<<h<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int 
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define inf LONG_MAX
#define ninf LONG_MIN
const int mod = 1e9+7;

 int vis(int i,int dp[] , vi g[]){
  int ans = 0;
  for(auto j : g[i]){
    if(dp[j]==-1)
      dp[j]=vis(j , dp , g);
    ans = max( ans , 1+dp[j]);
  }
  return ans;
 }
int32_t main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  
   int n,m;
    cin>>n>>m;
    vi g[n];
    int dp[n];
    f(i,n)dp[i]=-1;
    f(i,m)
    {
      int x,y;
      cin>>x>>y;
      g[x-1].pb(y-1);
    }
    int ans = 0;
    f(i,n){
      if(dp[i]==-1)
        dp[i]=vis(i, dp , g);
      ans = max( ans, dp[i]);
    }
    cout<<ans<<"\n"; 
  
  
  
  return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
using namespace std;
string f[3];
int main() {
    while (cin>>f[0]) {
        if (f[0]=="0") break;
        for (int i=1; i<3; i++) cin>>f[i];
        char res='+';
        for (int i=0; i<3; i++) {
            if (f[0][i]==f[1][i]&&f[1][i]==f[2][i]) {
                if (f[0][i]!='+') res=f[0][i];
            }
            if (f[i][0]==f[i][1]&&f[i][1]==f[i][2]) {
                if (f[i][0]!='+') res=f[i][0];
            }
        }
        if (f[0][0]==f[1][1]&&f[1][1]==f[2][2]) {
            if (f[0][0]!='+') res=f[0][0];
        }
        if (f[0][2]==f[1][1]&&f[1][1]==f[2][0]) {
            if (f[0][2]!='+') res=f[0][2];
        }
        if (res=='+') puts("NA");
        else cout<<res<<endl;
    }
}

Measured memory_bytes: 0
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

int		main(void)
{
	int		x;
	int		i;

	i=1;
	while(1)
	{
		scanf("%d",&x);
		if( x == 0 )
			break;
		printf("Case %d: %d\n",i,x);
		i=i+1;
	}

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    ll n, x; cin >> n >> x;
    V<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ll cnt = 0;
    for(int i = 0; i < n - 1; i++){
        ll sum = a[i] + a[i + 1];
        if(sum > x){
            ll tmp = sum - x;
            cnt += tmp;
            if(tmp <= a[i + 1]){
                a[i + 1] -= tmp;
            }else{
                tmp -= a[i + 1];
                a[i + 1] = 0;
                a[i] -= tmp;
            }
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 7;
int n, a[maxn], ans[maxn];

bool cal() {
	for (int i = 1; i <= n; ++i) {
		int now = i, pos = 0;
		for (int j = n; j; --j) {
			if(a[j] == now) {
				pos = j;
				break;
			}
			if(!a[j]) --now;
		}
		if(!pos) return 0;
		ans[i] = a[pos]; a[pos] = 0;
	}
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	if(!cal()) printf("-1\n");
	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;cin>>N;
  vector<long> A(N+10);
  for(int i=1;i<=N;i++)cin>>A[i];
  long mod=1000000007;
  long sum=0;
  long ruiwa=0;
  for(int i=N-1;i>=1;i--){
    ruiwa=(ruiwa+A[i+1])%mod;
    sum=(sum+(A[i]*ruiwa)%mod)%mod;
  }
  cout<<sum<<endl;
}


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

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	long long tot = 0, x;
	vector<long long> a, b;
	a.push_back(0);
	b.push_back(0);
	for(int i = 1; i <= n; ++i) {
		cin >> x;
		tot += x;
		a.push_back(tot);
	}
	tot = 0;
	for(int i = 1; i <= m; ++i) {
		cin >> x;
		tot += x;
		b.push_back(tot);
	}
	int answer = 0;
	for(int i = 0; i < (int)a.size(); ++i) {
		if(k < a[i])
			break;
		vector<long long> :: iterator it;
		it = lower_bound(b.begin(), b.end(), k - a[i]);
		if((it - b.begin()) == 0) {
			answer = max(answer, i);
			break;
		}
		if(it != b.end() && *it != k - a[i])
			--it;
		int cur = i + (it - b.begin()) - (it == b.end());
		answer = max(answer, cur);
	}
	cout << answer;
}


Measured memory_bytes: 7976
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> plist = new ArrayList<>();
		plist.add(sc.nextInt());
		plist.add(sc.nextInt());
		plist.add(sc.nextInt());
		plist.add(sc.nextInt());
		Collections.sort(plist);

		if(plist.get(0)==1&&
		plist.get(1)==4&&
		plist.get(2)==7&&
		plist.get(3)==9){
			
		System.out.println("YES" );
		}else{
			
		System.out.println("NO" );
		}


	}
}

Measured memory_bytes: 23892
N = int(input())

dic = dict()
for i in range(N):
    S = input()
    new = ''.join(sorted(S))
    
    if not new in dic:
        dic[new] = 0
        
    dic[new] += 1

ans = 0

for key,val in dic.items():
    if val > 1:
        ans += (val*(val-1)) // 2

print(ans)




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

int main(void){
  int h,w;
  cin >>h>>w;
  char a;
  int num[26]={0};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a;
      num[a-'a']++;
    }
  }
  int hq=h%2;
  int wq=w%2;
  if(hq==0&&wq==0){//双方偶数
    for(int i=0;i<26;i++){
      if(num[i]%4!=0){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  else if(hq==1&&wq==1){//双方奇数
    int one=1;
    int two=(h-1)/2+(w-1)/2;
    for(int i=0;i<26;i++){
      if(num[i]%4==1){
        one-=1;
        if(one<0){
          cout<<"No"<<endl;
          return 0;
        }
      }
      if(num[i]%4==2){
        two-=1;
        if(two<0){
          cout<<"No"<<endl;
          return 0;
        }
      }
      if(num[i]%4==3){
        one-=1;
        two-=1;
        if(one<0||two<0){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  else if(hq==1){
    int two=(w/2);
    for(int i=0;i<26;i++){
      if(num[i]%4==1||num[i]%4==3){
        cout<<"No"<<endl;
        return 0;
      }
      if(num[i]%4==2){
        two-=1;
        if(two<0){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  else if(wq==1){
    int two=(h/2);
    for(int i=0;i<26;i++){
      if(num[i]%4==1||num[i]%4==3){
        cout<<"No"<<endl;
        return 0;
      }
      if(num[i]%4==2){
        two-=1;
        if(two<0){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }

  cout<<"Yes"<<endl;
  return 0;
}


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,a,b,c,ans;
    cin >> n >> a >> b;
    c = n/(a+b);
    if(n%(a+b)<=a) print(n-b*c);
    else print(a*(c+1));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert                                                                      //copy NUL check.cpp
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ 1ad.cpp -o 1ad.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




int main()
{    ll sum=0;
	int n,i=0;
	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	for(i=1;i<=n;i++)
	cin>>a[i];
for(i=1;i<=n;i++)
	cin>>b[i];
for(i=1;i<n;i++)
	cin>>c[i];
for(i=1;i<=n;i++)
   {
   	sum+=b[a[i]];
   	if((a[i]-a[i-1])==1 && i>1 )
   		sum+=c[a[i-1]];
   }
   cout<<sum;

	return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
edges = Array.new(9) { [] }
m.times do
  s, t = gets.split.map(&:to_i)
  edges[s] << t
  edges[t] << s
end

cnt = 0
(2..n).to_a.permutation.each do |path|
  next if !edges[1].include?(path[0])

  flag = false
  (n - 2).times do |i|
    if !edges[path[i + 1]].include?(path[i])
      flag = true
      break
    end
  end
  next if flag

  cnt += 1
end

puts cnt

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

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int begin = max(a, c);
  int end = min(b, d);
  if ((end - begin) > 0) cout << end - begin << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 384
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append([s for s in input()])

# for h in range(H):
#     for w in range(W):
#         print(S[h][w], end='')
#     print()

ans = [['#' for _ in range(W)] for _ in range(H)]

# for h in range(H):
#     for w in range(W):
#         print(ans[h][w], end='')
#     print()

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            continue
        dH = [1, 1, 0, -1, -1, -1, 0, 1]
        dW = [0, 1, 1, 1, 0, -1, -1, -1]
        cnt = 0
        for dh, dw in zip(dH, dW):
            nh = h + dh
            nw = w + dw
            if (nh < 0 or H <= nh or nw < 0 or W <= nw):
                continue
            if S[nh][nw] == '#':
                cnt += 1
        ans[h][w] = cnt

for h in range(H):
    for w in range(W):
        print(ans[h][w], end='')
    print()


Measured memory_bytes: 45036
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
signed main()
{
    fast
    ll n,s=0;
    cin>>n;
    ll a[n];
    ll fr[200005]={0};
    for(ll i=0;i<n;i++){cin>>a[i]; fr[a[i]]++;}
    for(ll i=0;i<200005;i++){
        s+=(fr[i]*(fr[i]-1))/2;
    }
    for(ll i=0;i<n;i++){
        cout<<s-fr[a[i]]+1<<endl;
    }
}


Measured memory_bytes: 5760
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string s1,s2,s3;	cin >> s1 >> s2 >> s3; 
    printf("%c%c%c\n", (char)('A'+s1[0]-'a'), (char)('A'+s2[0]-'a'), (char)('A'+s3[0]-'a'));
}


Measured memory_bytes: 256
main = do
    [n,y] <- map read . words <$> getLine
    let (a,b,c) = head $ [(a,b,rest) |
                            a <- [0..n],
                            b <- [0..n-a],
                            let rest = n-a-b,
                            10000*a+5000*b+1000*rest==y] ++ [(-1,-1,-1)]
    putStr $ show a ++ " "
    putStr $ show b ++ " "
    putStrLn $ show c 

Measured memory_bytes: 892
using Yorukatsu058.Questions;
using Yorukatsu058.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu058.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc072/tasks/arc082_a
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadIntArray();
            var counts = new int[100001];

            foreach (var ai in a)
            {
                counts[ai]++;
            }

            var max = Enumerable.Range(1, 99999).Max(i => counts[i - 1] + counts[i] + counts[i + 1]);
            yield return max;
        }
    }
}


namespace Yorukatsu058
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu058.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu058.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main() {
	int X;
	cin >> X;
	int ma = 1;
	int i, x;
	bool flag = false;
		for (i = 2; i <= X; i++) {
			x = i;
			flag = false;
			while (x*i <= X)x *= i,flag = true;
			if(flag)ma = max(ma, x);
		}
		cout << ma << endl;

}

Measured memory_bytes: 256
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(1, 2), 3)


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    a = read_int(1)[0]
    b = read_int(1)[0]
    return a, b


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    s = set()
    s.add(a)
    s.add(b)
    if 1 in s:
        if 2 in s:
            return 3
        else:
            return 2
    else:
        return 1


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()


Measured memory_bytes: 6108
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        boolean flag = false;
        for (int i = 1; i < 10; i++) {
            if (num / i < 10 && num % i == 0) {
                flag = true;
            }
        }

        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 23760
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		Deque<Character> dq = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'B') {
				if(!dq.isEmpty()) dq.pop();
				continue;
			}
			dq.push(c);
		}
		while(!dq.isEmpty()) {
			System.out.print(dq.pollLast());
		}
		System.out.println();
	}
}

Measured memory_bytes: 9428
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <cfloat>
#include <climits>

using namespace std;

const int intinf = INT_MAX;
const long longinf = LONG_MAX;
const double doubleinf = DBL_MAX;

#define map std::unordered_map;
#define set std::unordered_set;


int main(void) {
    const string a("CODEFESTIVAL2016");
    const unsigned long len = a.size();

    string b;
    cin >> b;
    int cnt = 0;
    for(int i=0; i<a.size(); ++i)
        cnt += a[i] != b[i];
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int d, n;
    cin >> d >> n;

    if (d == 0) {
        if (n != 100)
            cout << n << endl;
        else
            cout << n + 1 << endl;

    }
    else if (d == 1)
        if (n != 100)
            cout << n * 100 << endl;
        else
            cout << n * 100 + 100 << endl;
    else
        if (n!= 100)
            cout << n * 10000 << endl;
        else
            cout << n * 10000 + 10000;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define N 200005

int main()
{
    int k,n;
    cin>>k>>n;
    int ara[n+5];
    for(int i=0;i<n;i++) cin>>ara[i];
    int ans=ara[n-1]-ara[0];
    for(int i=1;i<n;i++)
    {
        ans=min(ans,ara[i-1]+k-ara[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(Math.abs(x - a) < Math.abs(x - b)) System.out.println("A");
        else System.out.println("B");
    }
}

Measured memory_bytes: 35588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (n * a > b) {
			System.out.println(b);
		}else {
			System.out.println(n * a);
		}
	}

}


Measured memory_bytes: 35652
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int N,W;
int dp[101][10010];

int main(){
    
    cin>>N>>W;
    vector<int> v(N);
    vector<int> w(N);
    REP(i,N)cin>>v[i]>>w[i];
    
    for(int i=N-1;i>=0;i--){
        for(int j=0;j<=W;j++){
            if(j-w[i]<0)dp[i][j]=max(dp[i+1][j],dp[i+1][j]);
            else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
        }
    }
    
    int ans=0;
    REP(i,W+1)ans=max(ans,dp[0][i]);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 7020
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Dec 29 04:47:30 2018
//
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	if A+B >= C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;

namespace ConsoleApplication1
{
	public class Runes
	{
		static int Main(string[] args)
		{
			string s = Console.ReadLine().ToUpper();
			int posA = s.IndexOf('A');
			int posZ = s.LastIndexOf('Z');
			if (posA < 0 || posZ < 0 || posZ < posA)
				Console.WriteLine("-1");
			else
				Console.WriteLine(posZ - posA + 1);

			return 0;		
			
		}
	}
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
 int a[n],d[n];
  for(int i=0;i<n;i++){
cin>>a[i];
  d[i]=a[i];}
  sort(a,a+n);
  int b=a[n-1],c=a[n-2];
  for(int i=0;i<n;i++){
if(d[i]!=b){
  cout<<b<<endl;}
    else cout<<c<<endl;}}

Measured memory_bytes: 3200
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>

using namespace std;

class pr{
public:
  char n[10];
  int t;
};

pr p[100000];

int head = 0, tail = 0;

void eq(pr pr1){
  p[tail] = pr1;
  tail++;
  if(tail >= 100000) tail = 0;
}

pr dq(){
  pr x = p[head];
  head++;
  if(head >= 100000) head = 0;
  return x;
}

int isempty(){
  if(head == tail) return 1;
  else return 0;
}



int main(){
  int n, q;

  cin >> n >> q;

  pr pr1[n];

  for(int i = 0; i < n; i++){
    cin >> pr1[i].n >> pr1[i].t;
    eq(pr1[i]);
  }


  int time = 0;

  while(!isempty()){
    pr x = dq();
    if(x.t - q <= 0){
      time += x.t;
      cout << x.n << " " << time << endl;
    }
    else{
      time += q;
      x.t -= q;
      eq(x);
    }
  }



  return 0;

}



Measured memory_bytes: 5424
#include <stdio.h>

int main (){
  int n,num[33]={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};
  scanf("%d", &n);
  printf("%d\n", num[n-1]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<bitset>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int N = 3e5 + 10, Max = 2e5 + 10;
const ll  MOD = 1e9 + 7, OO = 1e9;
string s;
int dp[N][20];
int solve(int i, int sofar) {
	sofar %= 13;
	if (i == s.size())
		return sofar == 5;
	int&ret = dp[i][sofar];
	if (ret != -1)
		return ret;
	ret = 0;
	if (s[i] != '?') {
		return ret = solve(i + 1, sofar * 10 + s[i] - '0');
	}
	for (int j = 0; j < 10; ++j) {
		ret %= MOD;
		ret += solve(i + 1, sofar * 10 + j);
	}
	return ret = ret%MOD;
}
int main() {
	cin >> s;
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) << endl;
}


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

long long a(long long x, long long y) {
    long long tmp = 0;
    long long xx = x;
    long long yy = y;
    while (xx > 0) {
        tmp += (xx%10);
        xx /= 10;
        // cout << xx << endl;
    }
    while (yy > 0) {
        tmp += (yy%10);
        yy /= 10;
        // cout << yy << endl;
    }
    return tmp;
}

int main() {
    long long n,ans;
    cin >> n;
    ans = a(n-1,1);
    for (int i = 1; i <= n-1; i++) {
        if (a(i,n-i) < ans) {
            ans = a(i,n-i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N],b[N];
int main()
{
    scanf("%d",&n);
    bool flag=false;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]),flag|=a[i]!=b[i];
    if(!flag){printf("0\n");return 0;}
    ll sum=0;
    int mn=inf;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>b[i])
            mn=min(mn,b[i]);
        sum+=a[i];
    }
    printf("%lld\n",sum-mn);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n;
  cin >> n;
  cout << (800*n) - (200*(n/15));
  
  return 0;
}


Measured memory_bytes: 256