akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B;

    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        string s_i;

        s_i = to_string(i);
        int j;
        for (j = 0; j < s_i.size() / 2; j++) {
            if (s_i.at(j) != s_i.at(s_i.size() - 1 -j))
                break;
        }
        //cout << j << endl;
        if (j == s_i.size() /2) {
            //cout << s_i << endl;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
import fractions
num = a[0]
for i in range(1, n):
    num = fractions.gcd(num, a[i])

if k > a[-1]:
    print("IMPOSSIBLE")
elif (k in a) or (k%num==0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 81564
// In the name of God

#include <bits/stdc++.h>

using namespace std;

vector<int> sw[15];
int p[15];

bool check(set<int> &v, int ind) {
	int op = 0;
	for(int i=0; i<sw[ind].size(); i++) {
		if(v.find(sw[ind][i]) != v.end()) op++;
	}
	return (op % 2 == p[ind] % 2);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int k;
		cin >> k;
		for(int j=0; j<k; j++) {
			int x;
			cin >> x;
			sw[i].push_back(x);
		}
	}
	for(int i=0; i<m; i++) {
		cin >> p[i];
	}
	int cnt = 0;
	for(int i=0; i< (1<<n); i++) {
		set<int> open;
		for(int j = 0; j<n; j++) {
			if(i & (1<<j) ) open.insert(j+1);
		}
		bool test = true;
		for(int j=0; j<m; j++) {
			test &= check(open, j);
		}
		cnt += test;
	}
	cout << cnt;
	return 0;
}


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

int main(){
long long n,a,b,c,d,e;
cin >> n >> a >> b >> c >> d >> e;
long long ans = (n+min({a,b,c,d,e})-1)/min({a,b,c,d,e}) + 4;
cout << ans << endl;
}



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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, k;
    int temp;
    int i;
    
    scanf("%d %d", &n, &k);
    
    int kind = n;
    int count[n+1];
    int change = 0;
    
    for(i=0;i<=n;i++) count[i] = 0;
    for(i=0;i<n;i++) scanf("%d", &temp), count[temp]++;
    for(i=1;i<=n;i++) if(count[i]==0) kind--;
    
    // printf("%d\n", kind);
    
    qsort(count, n+1, sizeof(int), compare_int);
    
    i = 1;
    while(kind>k){
        if(count[i]!=0) change += count[i], kind--;
        i++;
    }
    
    // for(i=0;i<=n;i++) printf("%d ", count[i]);
    // printf("\n");
    printf("%d", change);

    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<complex>
#include<array>
#include<vector>
#include<cstdio>
using namespace std;

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

typedef  complex<double> point;

double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
	return real(conj(a)*b);
}
typedef array<point, 2> line;

point projection(const line& l, const point& p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}

point reflection(const line& l, const point& p) {
	return p + 2. * (projection(l, p) - p);
}

int main()
{
  double x0,y0,x1,y1,xa,ya;
  char tt;
  for(;cin>>x0>>tt>>y0>>tt>>x1>>tt>>y1>>tt>>xa>>tt>>ya;)
    {
      line l;
      l[0]=point(x0,y0);
      l[1]=point(x1,y1);
      point p=point(xa,ya);
      point ans=reflection(l,p);
      printf("%.10lf %.10lf\n",ans.real(),ans.imag());
    }
}

Measured memory_bytes: 1252
int main(void)
{
 int a = 0;
 int b = 0;
 int c = 0;
   
 scanf("%d %d %d",&a,&b,&c);
    
 if(a<b && b<c){
 printf("Yes\n");
 }else{
 printf("No\n");
 }
 return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

int main() {
	string S;
	std::cin >> S;

	int l = S.length();
	char c = S[0];
	for (int i = 1; i < l; i++) {
		if (c != S[i]) {
			std::cout << "Yes" << endl;
			return 0;
		}
	}

	std::cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        sc.close();
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) cnt++;
        }
        System.out.println(cnt);
    }
}

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

int main(){
	int r, D, x;
	scanf("%d%d%d", &r, &D, &x);
	for(int i = 1; i <= 10; i++){
		x = r * x - D;
		printf("%d\n", x);
	}
	return 0;
}

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

#pragma GCC optimize("O3")
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define gc getchar_unlocked
typedef long long ll;
typedef long double ld;
const double PI=acos(-1.0);
const int mod = 1000000007;


ll a[50][50];

int main()
{
    FASTIO
	
	    ll n,d,cnt=0;
	    cin>>n>>d;
	    
	    for(int i=0;i<n;i++)
	    for(int j=0;j<d;j++)
	    cin>>a[i][j];
	    
	    
	    
	    for(int i=0;i<n-1;i++)
	    {
	        
	        for(int k=i+1;k<n;k++)
	        {
	            ld dist=0.00;
	            
	        for(int j=0;j<d;j++)
	        {
	            
	            dist+=(a[i][j]-a[k][j])*(a[i][j]-a[k][j]);
	        }
	        
	        dist=sqrt(dist);
	        
	        if(dist==(int)dist)
	        ++cnt;
	        
	        }
	        
	        
	    }
	    
	    cout<<cnt;
	    
	

	return 0;
}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
 
  public static void main(String args[]){
    
    Scanner s= new Scanner(System.in);
    
    int n =s.nextInt();
    float d = s.nextInt();
    int count=0;
    
    for(int i=0;i<n;i++){
     if(Math.sqrt(Math.pow(s.nextInt(),2)+Math.pow(s.nextInt(),2))<=d)
       count++;
    }
    System.out.println(count);
    
  }
  
}

Measured memory_bytes: 59180
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(ll i=0; i < n; i++)
#define reps(i, n) for(ll i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;


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

  queue<pair<string,int>> q;
  q.push(mp("a",97));

  while(!q.empty()){
    auto p=q.front();
    q.pop();
    string s = p.first;
    int c= p.second;
    if (s.size()==n){cout << s << endl;continue;}

    for(int i=97;i<=c+1;i++){
      string t= s+(char)i;
      int mx=max(c,i);
      q.push(mp(t,mx));
    }
  }
}

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

using namespace std;

struct vw_pair {
    int v, w;
    vw_pair(int v,int w) : v(v), w(w) {};
};

typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<int> vi;
typedef vector <string> vs;
typedef vector <vi> vvi;
typedef vector <vector<vw_pair>> adj_list;
typedef vector <bool> vb;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int> max_heap_int;
typedef priority_queue<int, vi, greater<>> min_heap_int;

#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S |= (1<<j))
#define clearBit(S, j) (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1<<n)-1)

#define modulo(S, N) ((S) & (N-1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S-1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
#define turnOffLastConsecutiveBits(S) ((S) & (S+1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S-1))
#define in_range(lo, hi, x) ((x >= lo && x <= hi))

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

    int n;
    cin >> n;
    vi a(n);
    bool flag = true;
    for (int i=0;i<n;++i) cin >> a[i];
    a[0]--;
    for (int i=1;i<(n-1);++i) {
        if (a[i] > a[i+1]) {
            if (a[i]-1 >= a[i-1] && a[i]-1 == a[i+1]) --a[i];
            else {
                flag = false;
                break;
            }
        } else if (a[i] == a[i+1] && (a[i] - 1) >= a[i-1]) --a[i];
    }

    if (flag) {
        cout << "Yes\n";
    } else cout << "No\n";

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int a,b;
	cin >> a>> b;
	cout<<(a-1)*(b-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
ans=0
a=0
if M!=0:
  s=[0]*M
  c=[0]*M
  for i in range(M):
    s[i],c[i]=map(int, input().split())
    s[i]-=1
elif N==1:
  ans=0
else:
  ans=10**(N-1)
flag=[0]*N
value=[0]*N
for i in range(N):
  flag[i]=0
  value[i]=0
if (M!=0):
  for i in range(M):
    if flag[s[i]]==0:
      flag[s[i]]=1
      value[s[i]]=c[i]
      ans+=c[i]*(10**(N-1-s[i]))
    elif c[i]==value[s[i]]:
      continue
    else:
      ans=-1
      break
  if ans!=-1:
    if (flag[0]==1 and value[0]==0):
      if N==1:
        ans=0
        a=1
      else:
        ans=-1
  if ans!=-1 and ans<10**(N-1) and a==0:
    ans+=10**(N-1)
elif (M!=0):
  ans=-1
  
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


struct UnionFind {
	vector<int> par;
  
  UnionFind(int N): par(N){
  	for(int i=0;i<N;i++) par[i] =i;
  }
};





int main(){
  ios::sync_with_stdio(false);
  
  int A,B;
  cin>>A>>B;
  
  if(A>9 || B>9 ){
  	cout<<-1;
  }else{
  	cout<<A*B;
  }
  
}

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

int main(){
  int a,b,c,x;
  cin >>a >>b >>c >>x;
  int ans = 0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i+100*j+50*k == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;


int n,cnt,m;
vector<int> G[100];

vector<bool> visited;
vector<int> tin, low;
int timer;

void dfs(int v, int p = -1) {
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (int i=0; i<G[v].size(); i++) {
        int to=G[v][i];
        if (to == p) continue;
        if (visited[to]) {
            low[v] = min(low[v], tin[to]);
        } else {
            dfs(to, v);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v]) cnt++;
        }
    }
}

void find_bridges() {
    timer = 0;
    visited.assign(n, false);
    tin.assign(n, -1);
    low.assign(n, -1);
    for (int i = 0; i < n; ++i) {
        if (!visited[i])
            dfs(i);
    }
}

int main() {

    Fast_Input
    cin>>n>>m;

    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    find_bridges();
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
s=str(input())
q=int(input())

right=[]
left=[]
flag=0

for i in range(q):
    a = input()
    if int(a[0]) == 1:
        if flag == 0:
            flag=1
        else:
            flag=0
    else:
        if int(a[2]) == 1:
            if flag == 0:
                left.append(a[4])
            else:
                right.append(a[4])
        elif int(a[2]) ==2:
            if flag ==0:
                right.append(a[4])
            else:
                left.append(a[4])

right_result="".join(right)
left_result="".join(left)

if flag==0:
    print(str(left_result[::-1]+s+right_result))
else:
    print(str(right_result[::-1]+s[::-1]+left_result))


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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;

ll n,m;
pair <ll, ll> niz[105];
ll dp[105][MAXN+5];
ll rj;

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

	cin>>n>>m;
	for(int i=0; i<n; i++){
		cin>>niz[i].X>>niz[i].Y;
	}	
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	dp[0][niz[0].Y]=niz[0].X;
	for(int i=1; i<n; i++){
		for(int j=0; j<100003; j++){
			if(dp[i-1][j]!=-1){
				dp[i][j]=dp[i-1][j];
			}
			if(j>=niz[i].Y && dp[i-1][j-niz[i].Y]!=-1){
				if(dp[i][j]==-1){
					dp[i][j]=dp[i-1][j-niz[i].Y]+niz[i].X;
				}
				else{
					dp[i][j]=min(dp[i][j],dp[i-1][j-niz[i].Y]+niz[i].X);
				}
			}
		}
	}
	for(int i=0; i<100003; i++){
		if(dp[n-1][i]<=m && dp[n-1][i]!=-1){
			rj=i;
		}
	}
	cout<<rj;
	
	return 0;
}

Measured memory_bytes: 85592
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}




void solve(long long N, std::vector<long long> A){
    long long ans = 0;
    long long minnest = 1000000000000;
    long long go = 0;
    REP(i,N){
        if(A[i] < 0){
            go++;
        }
        minnest = min(minnest,llabs(A[i]));
        ans += llabs(A[i]);
    }
    if(go % 2 == 1){
        ans -= 2*minnest;
    }
    cout << ans << endl;

}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    int l = 0;
    int r = k;

    while (r <= n - 1)
    {
        if (a[l] < a[r])
        {
            print("Yes");
        }
        else
        {
            print("No");
        }

        l++;
        r++;
    }

    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
string s,w;
 
int main(){
	cin >> s >> w;
	
	bool f=true;
	REP(i,0,s.size()) if(s[i]=='?'){f=false; break;}
	if(f){cout << s << endl; return 0;}
	
	string t;
	REP(i,0,w.size()-1) t+='?';
	
	set<string> st;
	REP(i,0,s.size()){
		bool f=true;
		REP(j,0,w.size()) if(s[i+j]!='?' and s[i+j]!=w[j]) f=false;
		
		if(f){
			string a;
			a+=s.substr(0,i);
			a+=w;
			a+=s.substr(i+w.size(),s.size());
			
			REP(i,0,a.size()) if(a[i]=='?') a[i]='a';
			st.insert(a);
		}
	}
	
	if(st.size()){
		for(auto s:st){cout << s << endl; break;}
	}else{
		cout << "UNRESTORABLE" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import itertools
l1=list(map(int,input().split(" ")))
l2=list(map(int,input().split(" ")))
l3=list(map(int,input().split(" ")))
b_st=[list(sorted(l1))]
b_st.append(list(sorted(l2)))
b_st.append(list(sorted(l3)))

b_st.append(list(sorted([l1[0],l2[0],l3[0]])))
b_st.append(list(sorted([l1[1],l2[1],l3[1]])))
b_st.append(list(sorted([l1[2],l2[2],l3[2]])))
b_st.append(list(sorted([l1[0],l2[1],l3[2]])))
b_st.append(list(sorted([l1[2],l2[1],l3[0]])))
con=int(input())
#print(b_st)
f=0

if con==1:
    a=int(input())
    l2=[[a,a,a]]
elif con==2:
    list1=[int(input())for n in range(0,con)]
    l2=list[list[itertools.combinations_with_replacement(list1, 3)]]
else:
    list1=[int(input())for n in range(0,con)]
    list1=list(sorted(list1))
    l2=[[a,b,c] for a,b,c in list(list(itertools.combinations(list1,3)))]
#print(l2)
#print(b_st)
for sw in b_st:
    for lw2 in l2:
        #print(sw)
        #print(lw2)
        if sw==lw2:
            print("Yes")
            f=1
            break
    if f==1:
        break
if f==0:
    print("No")

Measured memory_bytes: 3192
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    REP(i, N)cin >> A[i];
    LL lhs = 0;
    LL rhs = 0;
    LL res = 1LL<<62;
    REP(i, N)rhs += A[i];
    REP(i, N-1){
        lhs += A[i];
        rhs -= A[i];
        res = min(res, abs(lhs-rhs));
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n ;
    cin >> n ;
    vector<int> w (n) ;
    rep(i, n) cin >> w[i] ;
    int res = 100000 ;
    for(int i = 1 ; i < n ; i++){
        int s1 = 0 ;
        int s2 = 0 ;
        rep(j, i){
            s1 += w[j] ;
        }
        for(int k = i ; k < n ; k++){
            s2 += w[k] ;
        }
        int t = abs(s1 - s2) ;
        res = min(res,t) ;
    }
    cout << res << endl ;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];
  int ans = 0, m = inf;
  rep(i,n){
    if(p[i] < m) ans++;
    chmin(m, p[i]);
  }
  cout << ans << endl;
}

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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n,m;
	cin>>n>>m;
	ll first=0,second=0;
	if(n>=2){
		first=n*(n-1)/2;
	}
	if(m>=2){
		second=m*(m-1)/2;
	}
	cout<<first+second<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

#標準入力
n = int(input())
#a = list(map(int, input().split()))

#mapはmap(function, iterable)のように使うが、扱いづらいのでlistと併用すべき
#lista = list(map(int, str.split()))

ans="No"

for i in range(1,10):
    for j in range(1,10):
        if n==i *j :
            ans = "Yes"


print(ans)

Measured memory_bytes: 9156
<?php
fscanf(STDIN, "%d %d", $k, $n);
$as=explode(' ',trim(fgets(STDIN)));
$max = 0;
foreach ($as as $i => $a) {
  $dis = $i == 0 ? $a + $k - $as[$n-1] : $a - $as[$i-1];
  $max = max($max, $dis);
}
echo $k - $max;

Measured memory_bytes: 19060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  int n; cin >> n;
  int count = 0;

  rep(i,n) {
    int k = i + 1;
    int a;
    cin >> a;

    if(k % 2 != 0 && a % 2 != 0) count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main()
{
  int A[100];
  int i,j,v,N;

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

  for(i=1; i<=N-1; i++){
    for(j=0; j<N-1; j++)
      printf("%d ",A[j]);
    printf("%d\n",A[j]);
    v = A[i];
    j = i - 1;
    while((j>=0) && (A[j]>v)){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
 }
  for(j=0; j<N-1; j++)
      printf("%d ",A[j]);
  printf("%d\n",A[j]);

  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;



int main() {
    string s; io.scan(s);
    int Q; io.scan(Q);
    
    int t, f; char c;
    bool is_rev = false;
    string buf1, buf2; buf1.reserve(100002); buf2.reserve(100002);
    string *front = &buf1, *back = &buf2;
    REP(i, Q) {
        io.scan(t);
        if (t == 1) {// 反転
            is_rev = !is_rev;
            string *tmp = front;
            front = back;
            back = tmp;
            //io.printl(is_rev ? "反" : "順", *front, *back);
        }
        else { // 追加
            io.scan(f, c);
            if (f == 1) { // 先頭に追加
                front->push_back(c);
                //io.printl("front:", *front);
            }
            else { // 末尾に追加
                back->push_back(c);
                //io.printl("back :", *back);
            }
        }
    }
    
    reverse(front->begin(), front->end());
    if (is_rev) {
        reverse(s.begin(), s.end());
    }
    string tmp(*front + s + *back);
    io.print(tmp);

    return 0;
}


Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<string,string> pss;
vector<int> fi;
vector<int> ope;
int K;
double fR,fL;
double P,E,T;
double MissP=0.0;
void trysleep(double prob,int num,double L,double R)
{
  //cout << "L R num prob: " << L << ' ' << R << ' ' << num << ' ' << prob << endl;
  double mid=(L+R)/2.0;
  if((L-T>E || T-R>E) || (num==K && abs(mid-T)>E)) 
    {
      MissP+=prob;
      return;
    }
  else if(num==K && abs(mid-T)<=E)
    {
      return;
    }
      
  else
    {
      if(mid<=T)
	{
	  trysleep(prob*(1.0-P),num+1,mid,R);
	  trysleep(prob*P,num+1,L,mid);
	}
      else if(mid>T)
	{
	  trysleep(prob*(1.0-P),num+1,L,mid);
	  trysleep(prob*P,num+1,mid,R);
	}
      return;
    }
}
int main(void)
{
  cin >> K >> fR >> fL;
  cin >> P >> E >> T;
  trysleep(1.0,0,fR,fL);
  cout << fixed << setprecision(12) << 1.0-MissP << endl;
  return 0;
}



Measured memory_bytes: 3288
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//A 65
//a 97


int main(){
  int x,y,z;cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}

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

int n, W;
long long f[2][100005];

int main() {
	scanf("%d %d", &n, &W);
	memset(f, -123, sizeof f);
	f[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		int u, v; scanf("%d %d", &u, &v);
		for (int w = 0; w <= W; ++w) {
			f[1][w] = max(f[1][w], f[0][w]);
			if (w + u <= W) {
				f[1][w + u] = max(f[1][w + u], f[0][w] + v);
			}
		}
		for (int w = 0; w <= W; ++w) {
			f[0][w] = f[1][w];
			f[1][w] = -1e18;
		}
	}
	printf("%lld\n", *max_element(f[0], f[0] + W + 1));
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if(U == S){
    cout <<A-1<< "\n";
    cout <<B<< "\n";
    }else{
    cout <<A<< "\n";
    cout <<B-1<< "\n";
    }
}

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

int N,Q; vector<int> A,B,C;
void input()
{
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cin >> Q;
    B.resize(Q); C.resize(Q);
    for (int i = 0; i < Q; ++i) cin >> B[i] >> C[i];
}

void solve()
{
    long long sum = 0; 
    map<int,long long> M;
    for (int i = 0; i < N; ++i) {
        sum += A[i];
        M[A[i]]++;
    }

    for (int i = 0; i < Q; ++i){
        sum +=  M[B[i]] * (C[i] - B[i]);
        M[C[i]] += M[B[i]];
        M[B[i]] = 0;
        cout << sum << endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 10392
#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,a[maxn];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if (n%2==0) {
		for (int i=n;i>=2;i-=2)
			printf("%d ",a[i]);
		for (int i=1;i<=n;i+=2)
			printf("%d ",a[i]);
		printf("\n");
	}
	else {
		for (int i=n;i>=1;i-=2)
			printf("%d ",a[i]);
		for (int i=2;i<=n;i+=2)
			printf("%d ",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <vector>
using namespace std;
int a[100010];
int c[16];
int dp[1<<16];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		a[x] ^= z;
		a[y] ^= z;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		c[a[i]]++;
	}
	vector<int> v;
	for (int i = 1; i < 16; i++) {
		ans += c[i] / 2;
		if (c[i] & 1) {
		       v.push_back(i);
		}
	}
	int m = v.size();
	dp[0] = 0;
	for (int i = 1; i < 1 << m; i++) {
		int k = 0, x = 0;
		for (int j = 0; j < m; j++) {
			if (i >> j & 1) {
				x ^= v[j];
				k++;
			}
		}
		if (x) {
			dp[i] = 100;
		} else {
			dp[i] = k - 1;
		}
		for (int j = i; j; j = i & (j - 1)) {
			if (dp[i] > dp[j] + dp[i^j]) {
				dp[i] = dp[j] + dp[i^j];
			}
		}
	}
	printf("%d\n", ans + dp[(1<<m)-1]);
	return 0;
}


Measured memory_bytes: 768
S = input()

flag = True
for i in range(len(S)):
    if i % 2 == 1:  # 偶数
        if S[i] == "R":
            flag = False
            break
    if i % 2 == 0:  # 奇数
        if S[i] == "L":
            flag = False
            break

if flag == True:
    print("Yes")
else:
    print("No")

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

  int N;
  Scd(N);
  
  vi a(N);
  vi b(1e6+1);
  Rep(i,N) Scd(a[i]), b[a[i]]++;
  
  int ans = 0;
  bool ok = true;
  Rep(i,N){
    b[a[i]]--;
    ok = true;
    for( int j=1; j*j<=a[i]; j++ ){
      if( a[i]%j==0 ){
        if( b[a[i]/j] || b[j] ) ok = false;
      }
    } 
    b[a[i]]++;
    ans += ok;
  }
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 8004
#include<iostream>  
#include<cmath>
#include<string>
using namespace std;
int main(){ 
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int num,min=10000000;
	for(int i=-20;i<=100;i++){
		num=0;
		for(int j=0;j<n;j++)
		    num+=(arr[j]-i)*(arr[j]-i);
		if(num<min)
			min=num;
	}
	cout<<min;
}




 




Measured memory_bytes: 256
import numpy as np

N = int(input())
p = [0] + list(map(float, input().split()))

dp = np.zeros((3100, 3100))
#dp[i, j] = i枚目までのコインを投げて，表の個数がj枚である確率
#pythonのlistだと遅いので，numpyにおけるベクトル漸化式としてdpを埋めていく

dp[1, 0] = 1-p[1]
dp[1, 1] = p[1]

for i in range(2, N + 1):
    dp[i] = np.roll(dp[i-1], 1) * p[i] + dp[i-1] * (1-p[i])
    #dp[i][j] = i-1枚目までで表がj-1かつi回目で表　＋　i-1回目までで表がj枚かつi回目で裏（MECE）
    #つまり，dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i])
    #numpyを使ってベクトル漸化式と見ることで，for_loopを一層分解消。
    #print(i, j, dp[i][j])

ans = 0

for k in range(-(-N//2), N+1):
    ans += dp[N, k]

print(ans)

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

int main(){
  string s;
  cin >> s;
  if(s == "ABC") puts("ARC");
  else puts("ABC");
  return 0;
}


Measured memory_bytes: 3572
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):
    if (a[i] == a[i-1]+1 and i > 0):
        s += c[a[i-1]-1]
    s += b[a[i]-1]
print(s)

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



int main(){
    vector<int> x(4,0);
    for (int i = 0; i < 3; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        x[a]++,x[b]++;
    }
    for (int i = 0; i < 4; i++) {
       if(x[i]>=3){
           puts("NO");
           return 0;  
       }
    }
    puts("YES");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int K;
    cin >> K;
    vector<int> I(K);
    for (int i = 0; i < K; i++) {
        string s;
        cin >> s;
        I[i] = s[0] == 'm' ? 0 : s[0] == 't' ? 1 : 2;
    }
    vector<int> N(K);
    for (int i = 0; i < K; i++) {
        string s;
        cin >> s;
        N[i] = s[0] == 'm' ? 0 : s[0] == 't' ? 1 : 2;
    }
    int p1 = 0, p2 = 0;
    for (int i = 0; i < K; i++) {
        bool l1 = false, l2 = false;
        if (I[i] == 0) {
            if (N[i] == 0) {
            } else if (N[i] == 1) {
                p2 = min(p2 + 1, 5);
            } else {
                l2 = p2 == 0 ? true : false;
                l1 = p2 == 5 ? true : false;
                p2 = 0;
            }
        } else if (I[i] == 1) {
            p1 = min(p1 + 1, 5);
            if (N[i] == 0) {
            } else if (N[i] == 1) {
                p2 = min(p2 + 1, 5);
            } else {
                l2 = p2 == 0 ? true : false;
                l1 = p2 > 0 ? true : false;
                p2 = 0;
            }
        } else {
            if (N[i] == 0) {
                l1 = p1 == 0 ? true : false;
                l2 = p1 == 5 ? true : false;
            } else if (N[i] == 1) {
                p2 = min(p2 + 1, 5);
                l1 = p1 == 0 ? true : false;
                l2 = p1 > 0 ? true : false;
            } else {
                if (p1 == 0 and p2 == 0) {
                    l1 = l2 = false;
                } else if (p1 == 0 or p2 == 0) {
                    l1 = p1 == 0 ? true : false;
                    l2 = p2 == 0 ? true : false;
                } else {
                    l1 = p1 < p2;
                    l2 = p2 < p1;
                }
                p2 = 0;
            }
            p1 = 0;
        }
        if (l1 and not l2) { return (cout << "Nakajima-kun" << endl), 0; }
        if (not l1 and l2) { return (cout << "Isono-kun" << endl), 0; }
    }
    cout << "Hikiwake-kun" << endl;
    return 0;
}



Measured memory_bytes: 3192
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(h)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
ans=0
for i in range(h):
    for j in range(w):
        ans+=c[abs(a[i][j])][1]
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long n = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());

		long ans = n % k;

		if (k - ans < ans) {
			ans = k - ans;
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 22868
def main04():
    buf = input("");
    bufs = buf.split(" ");
    val1 = [];
    for i in range(len(bufs)):
        val1.append(int(bufs[i]));
    val2 = [];
    for i in range(val1[0]):
        buf = input("");
        bufs = buf.split(" ");
        kari = [];
        kari.append(int(bufs[0]));
        kari.append(int(bufs[1]));
        val2.append(kari);
    min1 = 10000;
    for i in range(val1[0]):
        if val2[i][1] < val1[1] + 1 and val2[i][0] < min1:
            min1 = val2[i][0];
    if min1 == 10000:
        print("TLE");
    else:
        print(min1);

if __name__ == '__main__':
    main04()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class ITP1
{
    static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        Q3_B();

        //int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
    }

    static void Q1()
    {
        int input = int.Parse(Console.ReadLine());

        int h = input / 3600;
        int m = input % 3600 / 60;
        int s = input % 3600 % 60;

        Console.WriteLine(String.Format("{0}:{1}:{2}", h, m, s));
    }

    static void Q2_A()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        String sign = a[0] - a[1] > 0 ? ">" : a[0] - a[1] == 0 ? "==" : "<";

        Console.WriteLine(String.Format("a {0} b",sign));
    }

    static void Q2_B()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
        String answer = a[2] - a[1] > 0 ? a[1] - a[0] > 0 ? "Yes" : "No" : "No";

        Console.WriteLine(answer);
    }

    static void Q2_C()
    {
        List<int> a = new List<int>(Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s))));
        a.Sort();

        Console.WriteLine(String.Format("{0} {1} {2}",a[0],a[1],a[2])); 
    }

    static void Q2_D()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        int chk = 0;

        //x-max
        if (a[0] - a[2] - a[4] >= 0) chk++;
        //x-min
        if (a[2] - a[4] >= 0) chk++;
        //y-max
        if (a[1] - a[3] - a[4] >= 0) chk++;
        //y-min
        if (a[3] - a[4] >= 0) chk++;

        String answer = chk == 4 ? "Yes" : "No";
        Console.WriteLine(answer);
        
    }

    static void Q3_A()
    {
        for (int i = 0; i < 1000; i++)
        {
            Console.WriteLine("Hello World");
        }
    }

    static void Q3_B()
    {
        String a = "";
        for (int i = 1; i <= 10000; i++)
        {
            a = Console.ReadLine();
            if (a != null)
            {
                Console.WriteLine("Case {0}: {1}", i, a);
            }
            else
            {
                break;
            }

        }
    }
}

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

int main () {
  int n , a , b ;
  cin >> n >> a >> b ;
  
  int answer = 0 ;
  answer = a + b - n ;
  if(answer <= 0 ) answer = 0 ;
  
  cout << min(a,b) << ' ' << answer << endl ;
}

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

int main() {
  int N,ans=0;
  cin >> N;
  for(int i=0;i<N;i++) {
    int l,r;
    cin >> l >> r;
    ans += (r-l+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = [1,n]
for i in range(m):
    temp = list(map(int, input().split()))
    l[0] = max(l[0],temp[0])
    l[1] = min(l[1],temp[1])

print(int(max(l[1]-l[0]+1, 0)))

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

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n;
   cin >> n;
   ll ans=0;
   ans+= (n/500)*1000;
   n=n%500;
   ans+=(n/5)*5;
   cout << ans;
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int H=in();
	auto A=vecin(H);
	REP(i,H){
		int key = A[i];
		cout << "node " << i+1 << ": key = " << key << ", ";
		int parent = (i+1)/2;
		if(i>0){
			cout << "parent key = " << A[parent-1] << ", ";
		}
		int left = 2*(i+1);
		if(left<=H){
			cout << "left key = " << A[left-1] << ", ";
		}
		int right = 2*(i+1)+1;
		if(right<=H){
			cout << "right key = " << A[right-1] << ", ";
		}
		cout << endl;
	}
	
	return 0;
}



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

struct Mod
{
    static const auto P = int(1e9+7);
    long long k;

    Mod() = default;
    static Mod unit() { return 1; }
    Mod(const long long k) : k(k%P) {}
};

Mod operator+(const Mod a, const Mod b) { return a.k + b.k; }
Mod operator*(const Mod a, const Mod b) { return a.k * b.k; }
Mod& operator+=(Mod& a, const Mod b) { return a = a+b; }

using Matrix = array<array<Mod, 4>, 4>;

Matrix identity()
{
    auto I = Matrix{};
    for (auto i = 0; i < 4; i++) I[i][i] = 1;
    return I;
}

Matrix operator*(const Matrix A, const Matrix B)
{
    auto C = Matrix{};
    for (auto i = 0; i < 4; i++) for (auto j = 0; j < 4; j++)
        for (auto k = 0; k < 4; k++)
            C[i][k] += A[i][j] * B[j][k];
    return C;
}

Matrix& operator*=(Matrix& A, const Matrix B) { return A = A * B; }

Matrix power(const Matrix A, const int k)
{
    if (k == 0) return identity();
    else if (k % 2 == 0) return power(A*A, k/2);
    else return A * power(A*A, k/2);
}

int main()
{
    int N, M; cin >> N >> M;

    auto A = Matrix{}, B = Matrix{};
    for (auto i = 0; i < 4; i++) for (auto j = 0; j < 4; j++)
        if ((j & i) == i) A[i][j] = B[i][j] = 1;
    for (auto i = 0; i < 4; i++) A[3][i] += 1;

    auto C = identity();
    auto last_forbidden = -1;
    for (auto i = 0; i < M; i++)
    {
        int x; cin >> x;
        C *= power(A, x - last_forbidden - 1) * B;
        last_forbidden = x;
    }
    C *= power(A, N-1 - last_forbidden);

    cout << C[0][3].k << endl;
}


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

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");

        int max = 0;
        boolean onCheck = false;
        int cl = 1; // current length

        for(String x : input){
            if(x.equals("1")){
                cl++;
                onCheck = true;
            }else if(onCheck){
                max = Math.max(cl,max);
                cl = 1;
                onCheck = false;
            }
        }

        max = Math.max(cl,max);

        System.out.println(max);
    }
}



Measured memory_bytes: 24384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
  set<int> xx,yy;
  for(int i=0;100*a*i<=f;i++){
      int k=100*a*i;
      for(int j=0;k+100*b*j<=f;j++){
          int tmp=k+b*j*100;
          if(tmp<=f)xx.insert(tmp);
      }
  }
  for(int i=0;c*i<=f;i++){
      int k=c*i;
      for(int j=0;k+d*j<=f;j++){
          int tmp=k+d*j;
          if(tmp<=f)yy.insert(tmp);
      }
  }
  int x=0,y=0;
  double maxi=0;
  for(auto i:xx)for(auto j:yy){
      a=i+j;
      if(a>f||i==0)continue;
      if((100.0+e)*j<=e*a){
          double k=1.0*j/a;
          if(maxi<=k){
              maxi=k;
              x=i;y=j;
          }
      }
  }
  cout<<x+y<<' '<<y<<endl;
  return 0;
  }


Measured memory_bytes: 384
def resolve():
    N = int(input())
    ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

    for _ in range(N):
        S = str(input())
        ans[S] += 1
    print('AC x', ans['AC'])
    print('WA x', ans['WA'])
    print('TLE x', ans['TLE'])
    print('RE x', ans['RE'])

    return
resolve()

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}//pは素数,aのb乗をpで割った余り
ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}//pは素数,(nCr)%p
ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}//最大公約数
ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}//最小公倍数

bool check_continue(int P,vector<int> V){
	if(P!=0)return true;
	int cnt=0;
	for(int i=0;i<V.size();i++){
		if(V[i]>0)cnt++;
	}
	if(cnt==1)return false;
	return true;
}

int main() {
	
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int y,m,d;
		cin>>y>>m>>d;
		int ans=0;
		if(y%3==0){
			ans+=21-d;
		}else{
			if(m%2==0)ans+=20-d;
			else ans+=21-d;
		}
		m++;
		if(m==11){
			m=1;
			y++;
		}
		while(y!=1000){
			if(y%3==0){
				ans+=20;
			}else{
				if(m%2==0)ans+=19;
				else ans+=20;
			}
			m++;
			if(m==11){
				m=1;
				y++;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 3088