akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
    #include<math.h>
    
    int power(int,int);
    
    int main(void){
        int p,q;
        p=sqrt(100100);
        q=(int)p;
        
        int rtset[q];
        int i;
        
        for(i=0;i<q;i++){
            rtset[i]=i*i;
        }
        i=1;
        
        int a,b;
        scanf("%d %d",&a,&b);
        int bb=114514;
        while(bb!=0){
            bb=b/power(10,i);
            i++;
        }
        a=a*power(10,i-1)+b;
        for(i=0;i<q;i++){
            if(a==rtset[i]){
                printf("Yes\n");
                return 0;
            }
        }
        printf("No\n");
        return 0;
    }
    
    int power(a,b){
        int i,ans=1;
        for(i=0;i<b;i++){
            ans*=a;
        }
        return ans;
    }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

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

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1;i <= 1000;i++) {
		double x1 = i * 0.08;
		double x2 = i * 0.1;
		x1 = floor(x1);x2 = floor(x2);
		if (x1 == a && x2 == b) {
			cout << i << endl; return 0;
		}
	}cout << "-1" << endl;
}

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

int euclidean(int a, int b){
    int a1 = max(a,b);
    int a2 = min(a,b);
    if(a2 == 0) return a1;
    int a3 = a1%a2;
    for(;a3 > 0;){
        a1 = a2;
        a2 = a3;
        a3 = a1%a2;
    }
    return a2;
}

int main(void){
    int N;
    cin>>N;
    vector<int> A(N,0);
    vector<int> L(N+1,0);
    vector<int> R(N+1,0);
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    for(int i = 1; i<=N; i++){
        L[i] = euclidean(L[i-1],A[i-1]);
    }
    for(int i = N-1; i>=0; i--){
        R[i] = euclidean(R[i+1],A[i]);
    }

    int gcd = 0;
    for(int i = 0; i<N; i++){
        gcd = max(gcd, euclidean(L[i],R[i+1]));
    }
    cout<< gcd <<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
  int H , W,i,j,k;

  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) {
      break;
    }
		for(i=0;i<W;i++){
			printf("#");
		}
		printf("\n");
		for(j=0;j<H-2;j++){
			printf("#");
			for(i=0;i<W-2;i++){
					printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(i=0;i<W;i++){
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct point{ ll x; ll y; };

int main(){
    Init();
    point p1, p2, p3, p4;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    p3.x = p2.x - (p2.y - p1.y);
    p3.y = p2.y + (p2.x - p1.x);
    p4.x = p3.x - (p2.x - p1.x);
    p4.y = p3.y - (p2.y - p1.y);
    cout << p3.x << " " << p3.y << " " << p4.x << " " << p4.y << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  char s[101];
  
  bool isfour = false;
  scanf("%d", &n);
  REP(i,n){
    scanf("%c", &s[i]);
    if(s[i] == 'Y'){
      isfour = true;
    }
  }

  if(isfour){
    printf("Four\n");
  }else{
    printf("Three\n");
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;
int n, p, ans = 1, cnt;
int jl[10000009];
int prime[10000009], isp[10000009];
template <typename T>inline void in(T &x){
	T ch = getchar(), f = 1; x = 0;
	while(!isdigit(ch)) f = ch == '-' ? -1 : f, ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}
int cal(int x, int y){
	int z = 1;
	while(y){
		if(y & 1) {
//			if(z > 2147483647 && x > 2147483647)
//				return -1;
			z *= x;
		}
//		if(x > 2147483647) return -1;
		x *= x;
		y >>= 1;
//		if(z <= 0) return -1;
	}
	return z;
}
void pre(){
	for(int i = 2; i <= ceil(sqrt(p)); i++){
		if(!isp[i]){
			isp[i] = i;
			prime[++cnt] = i;
		}
		for(int j = 1; j <= cnt; j++){
			if(prime[j] > isp[i] || i * prime[j] > ceil(sqrt(p))) break;
			isp[i*prime[j]] = prime[j];
		}
	}
}
signed main(){
	in(n), in(p);
	if(n == 1){
		cout<<p;
		return 0;
	}
	pre();//int i = 2;
//	while(1){
		for(int i = 1; i <= cnt; i++){
		//	cout<<prime[i]<<" "<<p<<endl;
			if(p < prime[i]) break;
			if(p % prime[i])
				continue;
			while(!(p % prime[i]))
				jl[i]++, p /= prime[i];
			ans *= cal(prime[i], jl[i] / n);
		//	if(p == 1) break;
		//	p /= i;
	//		i = 1;
		}
//		int x = cal(i, n);
//		cout<<i<<" "<<x<<endl;
//		if(x > p || x <= 0) break;
//		if(p % x){
//			i++;
//			continue;
//		}
//		ans *= i;
//		p /= x;
//	}
//	for(int i = 1; i <= 1000000; i++){
//		if(jl[i] < n) continue;
//		cout<<i<<" "<<jl[i]<<endl;
//		ans *= cal(i, jl[i] / n);
//	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define rev(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>

int main()
{
    ll r,w;
    cin>>r>>w;
    ll dp[r+1][w+1];

    vector<string>mat(r);

    rep(i,r) cin>>mat[i];

    // dp[1][1]=1;


    for(int i=0;i<=r;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0)
            dp[i][j]=0;
            else if(i==1&&j==1)
            dp[i][j]=1;

            else if(mat[i-1][j-1]=='.'){
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
            }
            else
            {
                dp[i][j]=0;
            }
            
        }
    }
    cout<<dp[r][w]<<endl;

}

Measured memory_bytes: 9088
#include <iostream>
#include <cctype>

int main() {
	char str[1200];
	int str_size;
	std::cin.getline(str, sizeof(str));
	str_size = sizeof(str) / sizeof(str[0]);

	for(int i=0; i<str_size; i++){
		if(isupper(str[i])){
			str[i] = tolower(str[i]);
		}
		else if(islower(str[i])){
			str[i] = toupper(str[i]);
		}
	}

	std::cout << str << std::endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int res = -k;
	if (m2 >= m1)
		res += (h2 - h1) * 60 + (m2 - m1);
	else
		res += (h2 - h1 - 1) * 60 + (60 - (m1 - m2));
	cout << res << endl;

	return 0;
}


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


int main() {

	int judge[1000000];
	for(int k=0;k<1000000;k++)judge[k]=1;
	int n,sum;
	
	while(cin>>n){
		if(n==0||n==1){
			sum = 0;
		}else{
			sum = 1;
			for(int i=3;i<n+1;i+=2){
				if (judge[i]==1){
					sum++;
					for(int j=2;j<=n/i;j++)
						judge[i*j] = 0;
				}	
			}
		}
		
		cout << sum <<endl;
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int ans=0;
    FOR(i,1,n){
        string s = to_string(i);
        if (s.size()%2==1) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <memory.h>
using namespace std;

const int maxn = 1e5 + 10;
vector<int> G[maxn];
bool vis[maxn];
void dfs(int u, int& cnt)
{
	cnt++;
	vis[u] = 1;
	for(int i=0; i<(int)G[u].size(); i++)
	{
		if(!vis[G[u][i]]) dfs(G[u][i], cnt);
	}
}

int main()
{
	int n, m, k;
	while(cin>>n>>m)
	{
		vector<vector<int> > l(m+1);
		for(int i=1; i<=n; i++) G[i].clear();
		memset(vis, 0, sizeof(vis));
		for(int i=1; i<=n; i++)
		{
			scanf("%d", &k);
			while(k--)
			{
				int x;
				scanf("%d", &x);
				l[x].push_back(i);
			}
		}
		for(int i=1; i<=m; i++)
		{
			for(int j=1; j<(int)l[i].size(); j++)
			{
				G[l[i][j]].push_back(l[i][j-1]);
				G[l[i][j-1]].push_back(l[i][j]);
			}
		}
		int cnt = 0;
		dfs(1, cnt);
		cout<<((cnt == n) ? "YES" : "NO")<<endl;
	}
}








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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)
print(t)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n, i, s, c1, c2;
	scanf( "%d", &n );
	int a[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &a[i] );
	}
	
	c1 = 0;
	c2 = 0;
	
	for( i = 0; i < n; i++ ){
		for( s = 2; s <= sqrt(a[i]); s++ ){
			if( a[i] % s == 0 ){
				c1 = 1;
				break;
			}
		}
		if( c1 == 0 ){
			c2++;
		}
		c1 = 0;
		
	}
	
	printf( "%d\n", c2 );
	
	return 0;
}


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

int main(){
  int N,L;
  int sum =0;
  cin >> N >> L;
  
  vector<int> p(N);
  
  rep(i,N) p[i] = L+i;
  rep(i,N) sum += p[i];
  
  int ans = 1e9;
  
  rep(i,N){
    int t = sum-p[i];
    if(abs(sum-t) < abs(sum-ans))ans = t;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int s=0;
	for(i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		s+=x;
	}
	cout<<s-n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long N,K,sa;
  scanf("%ld",&N);
  scanf("%ld",&K);
  sa=N%K;
  if(K>2*sa)
    printf("%ld",sa);
  if(K<2*sa)
    printf("%ld",K-sa);
  return 0;
  }

Measured memory_bytes: 1704
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 1;
        for (int i = 0; i < 5; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35720
from collections import deque
n,m=map(int,input().split())
tunagari={}
for i in range(m):
    a,b=map(int,input().split())
    if a not in tunagari:
        tunagari[a]=[b]
    else:
        tunagari[a].append(b)
    if b not in tunagari:
        tunagari[b]=[a]
    else:
        tunagari[b].append(a)
heya=["." for i in range(n)]
ans=[0 for i in range(n)]
heya[0]=0
tmp=deque([1])
count=1
while tmp:
    now=tmp.popleft()
    for i in tunagari[now]:
        if heya[i-1]==".":
            heya[i-1]=heya[now-1]+1
            tmp.append(i)
            ans[i-1]=now

print("Yes")
for i in ans[1:]:
    print(i)

Measured memory_bytes: 119096
#include<iostream>
#include<cstring>

using namespace std;

const int maxN=15;
int A[3][3];
int b[maxN];
int N;
bool B[3][3];

int main(){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> A[i][j];
        }
    }
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> b[i];
    }
    memset(B,false,sizeof(B));

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(b[i]==A[j][k]) B[j][k]=true;
            }
        }
    }

    for(int i=0;i<3;i++){
        if(B[i][0]&&B[i][1]&&B[i][2]){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    for(int j=0;j<3;j++){
        if(B[0][j]&&B[1][j]&&B[2][j]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if((B[0][0]&&B[1][1]&&B[2][2]) || (B[0][2]&&B[1][1]&&B[2][0])){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" <<endl;
    return 0;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,max_w;
	cin>>n>>max_w;
	ll w[n+1],v[n+1];
	ll dp[n+1][max_w+1];
	for(ll r=1;r<=n;r++)
	{
		cin>>w[r]>>v[r];
	}
	for(ll z=0;z<=n;z++)
	{
		for(ll p=0;p<=max_w;p++)
		{
			if(p==0||z==0)
			{
				dp[z][p]=0;
				continue;
			}
			ll inc=0;
			ll exc=0;
			if(p>=w[z])
			{
				inc=dp[z-1][p-w[z]] + v[z];
			}
			exc=dp[z-1][p];
			dp[z][p]=max(inc,exc);
		}
	}
	cout<<dp[n][max_w]<<endl;
}

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

vector<string> split(const string& str, char del) {
    vector<string> result;
    string subStr;
    for (const char c : str) {
        if (c == del) {
            result.push_back(subStr);
            subStr.clear();
        } else {
            subStr += c;
        }
    }
    result.push_back(subStr);
    return result;
}

int main() {
    string w;
    cin >> w;
    int ans = 0;
    string t;
    while(true) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        vector<string> list = split(t, ' ');
        for (string i : list) {
            for (char & j : i) if (65 <= (int)j && (int)j <= 90) j = (char)((int)j + 32);
            if (i == w) ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3212
import sys
input=sys.stdin.readline
n=int(input())
p=[]
for i in range(n):
	s=input().rstrip()
	p.append(s)
p.sort()
ans=0
cnt=1
for i in range(n-1):
	if p[i]==p[i+1]:
		cnt+=1
	else:
		ans=max(ans,cnt)
		cnt=1
ans=max(ans,cnt)
q=[]
for i in range(n-ans+1):
	if p[i]==p[i+ans-1]:
		q.append(p[i])
q.sort()
for i in range(len(q)):
	print(q[i])


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

using namespace std;

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

ll counter[200005];
ll tot[200005];
ll cur = 0;

vector<int> AdjList[200005];
ll N, Q, A, B;

void dfs(int x, int p){
	cur += counter[x];
	tot[x] = cur;
	for (auto it : AdjList[x]){
		if (it == p) continue;
		dfs(it,x);
	}
	cur -= counter[x];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> Q;
	for (int i = 1; i < N; ++i){
		cin >> A >> B;
		AdjList[A].push_back(B);
		AdjList[B].push_back(A);
	}
	for (int i = 1; i <= Q; ++i){
		cin >> A >> B;
		counter[A] += B;
	}
	dfs(1,-1);
	for (int i = 1; i <= N; ++i){
		cout << tot[i] << ' ';
	}
	cout << '\n';
}

Measured memory_bytes: 25600
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int b[200005], a[200005];

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=n;i>=1;i--) {
		if(a[i]) {
			b[i] = 1;
			if(i > 1) {
				for(int j=1;j*j<=i;j++) {
					if(i % j) continue;
					a[j] ^= 1;
					if(i/j != j)
						a[i/j]^=1;
				}
			}
		}
	}
	int ct = 0;
	for(int i=1;i<=n;i++)
		ct += b[i];
	cout << ct << endl;
	for(int i=1;i<=n;i++)
		if(b[i])
			cout << i << " ";
}



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

void insertionSort( std::vector< int >& vec )
{
  for( int i = 1; i < vec.size(); ++i )
  {
    int v = vec[i];
    int j = i - 1;
    while( ( j >= 0 ) && ( vec[j] > v ) )
    {
      vec[j + 1] = vec[j];
      --j;
    }
    vec[j + 1] = v;
    
    for( std::vector < int >::iterator it = vec.begin(); it != vec.end() - 1; ++it )
    {
      std::cout << *it << " ";
    }
    std::cout << vec.back() << std::endl;
  }
}

int main()
{
  std::ios::sync_with_stdio( false );
  int length = 0;
  std::string buffer;
  std::cin >> length; std::cin.ignore();
  std::getline( std::cin, buffer );
  std::istringstream iss( buffer );

  std::cout << buffer << std::endl;

  int n;
  std::vector < int > vec;
  vec.reserve( length );
  while( iss >> n ) { vec.push_back( n ); }

  insertionSort( vec );
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

vector<int> to[2505];
vector<int> ot[2505];
bool readchablefrom1[2505];
bool readchabletoN[2505];
bool ok[2505];


void dfs(int v){
	if(readchablefrom1[v]) return; //閉路が存在するので
	readchablefrom1[v] = true;
	for(auto&& x: to[v]) dfs(x);
}

void rdfs(int v){
	if(readchabletoN[v]) return;
	readchabletoN[v] = true;
	for(auto&& x: ot[v]) rdfs(x);
}

int main(){
	int n,m,p; cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;
	FOR(i,1,m){
		int a,b,c; cin >> a >> b >> c;
		c -= p; c = -c;
		to[a].push_back(b);
		ot[b].push_back(a);
		edges.emplace_back(a,b,c);
	}
	dfs(1);
	rdfs(n);

	FOR(i,1,n) ok[i] = readchabletoN[i]&readchablefrom1[i];

	{//bellman ford algorithm
		vector<int> dist(n+1, INF);
		dist[1] = 0;
		int steps = 0;
		bool updated = true;
		while(updated){
			updated = false;
			for(auto&& x: edges){
				int a,b,c; tie(a,b,c) = x;
				if(!ok[a]) continue;
				if(!ok[b]) continue;
				int newD = dist[a]+c;
				if(newD < dist[b]){
					dist[b] = newD;
					updated = true;
				}
			}
			steps += 1;
			if(steps > n){ //負閉路が存在
				cout << -1 << endl;
				return 0;
			}
		}
		dist[n] = -dist[n];
		cout << max(0,dist[n]) << endl;
	}

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,t,mi = INF;
	cin >> n >> t;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		if(b <= t) chmin(mi,a);
	}
	if(mi != INF) cout << mi << endl;
	else cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 256
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 2000 + 7;

int A[MAX_N << 1];

int main() {
  int N, x;
  RI(N, x);
  ll ans = 0;
  REP(i, N) {
    RI(A[i]);
    ans += A[i];
    A[N + i] = A[i];
  }
  REP1(i, 1, N - 1) {
    ll pans = 1ll * i * x;
    deque<int> deq;
    REP(j, 2 * N) {
      while (!deq.empty() && deq.front() < j - i) deq.pop_front();
      while (!deq.empty() && A[deq.back()] >= A[j]) deq.pop_back();
      deq.PB(j);
      if (j >= N) pans += A[deq.front()];
    }
    ans = min(ans, pans);
  }
  PL(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

template<class T> inline bool chmin(T&a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T&a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

using namespace std;
int main(){
    int dp[100010][3] = {};
    int n;
    cin >> n;
    int a[100010][3];

    for(int i=0;i<n;++i){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<3;++k){
                if(j==k)continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int res;
    for(int i=0;i<3;++i){
        chmax(res, dp[n][i]);
    }
    cout << res << "\n";
}

Measured memory_bytes: 2560
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int t,i,n,s,f,sum;
	while(1)	{
		scanf("%d",&t);
		if(t==0)	break;
		scanf("%d",&n);
		sum=0;
		for(i=0;i<n;i++)	{
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(sum>=t)	printf("OK\n");
		else printf("%d\n",t-sum);
	}
	return 0;
}


Measured memory_bytes: 2740
#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 n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
   
  int min_ans = 100000000;
  rep(p,100) {
    int ans = 0;
    rep(i,n) {
      ans += (x[i] - p) * (x[i] - p);
    }
    min_ans = min(ans,min_ans);
  }
  cout << min_ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/16
@author: shinjisu
"""


# ABC 095 C Half and Half
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    X = getIntList()
    d.dmp((N),'N')
    d.dmp(X, 'X')
    x = sorted(X)
    d.dmp(X, 'X')
    d.dmp(x, 'x')
    b1 = x[N//2-1]
    b2 = x[N//2]
    d.dmp((b1,b2),'b1,b2')
    for b in X:
        if b <= b1:
            print(b2)
        else:
            print(b1)
    return None


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 26284
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MOD=998244353;

int adm(int x,int y){
	return (x+y)%MOD;
}
int mim(int x,int y){
	return (x-y+MOD)%MOD;
}
int t3m(int x){
	int y=(x+x)%MOD;
	return (x+y)%MOD;
}

//i番目まで使って和がjのものの個数
int dp[305][100000];
int dpx[305][100000];

int main(){
	int N;
	cin>>N;
	int a[301];
	int sum[301];
	sum[0]=0;
	rep1(i,N){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	
	dp[0][0]=1;
	rep(i,N){
		rep(j,sum[i]+1){
			dp[i+1][j]=adm(dp[i+1][j],dp[i][j]);
			dp[i+1][j]=adm(dp[i+1][j],dp[i][j]);
			dp[i+1][j+a[i+1]]=adm(dp[i+1][j+a[i+1]],dp[i][j]);
		}
	}
//	rep(j,sum[N]+1)cout<<dp[N][j]<<" ";
//  	cout<<endl;
  
  	dpx[0][0]=1;
	rep(i,N){
		rep(j,sum[i]+1){
			dpx[i+1][j]=adm(dpx[i+1][j],dpx[i][j]);
			dpx[i+1][j+a[i+1]]=adm(dpx[i+1][j+a[i+1]],dpx[i][j]);
		}
	}
//	rep(j,sum[N]+1)cout<<dpx[N][j]<<" ";
//  	cout<<endl;
  
	int al=1;
	rep(i,N){
		al=t3m(al);
	}
	int ans=al;
	int h=sum[N]/2;
	
	if(sum[N]%2==1){
		int ng=0;
		for(int i=h+1;i<=sum[N];i++){
			ng=adm(ng,dp[N][i]);
		}
		ng=t3m(ng);
		ans=mim(ans,ng);
	}
	else{
		int ng=0;
		for(int i=h;i<=sum[N];i++){
			ng=adm(ng,dp[N][i]);
		}
		ng=t3m(ng);
		int cv=t3m(dpx[N][h]);
		ans=adm(ans,cv);
		ans=mim(ans,ng);
	}
	
	cout<<ans<<endl;
	
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int N,O=0;
  cin >>N;
  long long int L[N];
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if((L[i]-L[j])*(L[j]-L[k])*(L[k]-L[i])!=0){          
          if(L[i]+L[j]>L[k]){
            if(L[i]+L[k]>L[j]){
              if(L[j]+L[k]>L[i]){
                O++;
              }
            }
          }
        }
      }
    }
  }
  
  cout << O;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

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

  if (S == "AAA") {
    cout << "No" << endl;
  }
  if (S == "BBB") {
    cout << "No" << endl;
  }
  if (S == "AAB") {
    cout << "Yes" << endl;
  }

  if (S == "ABA") {
    cout << "Yes" << endl;
  }

  if (S == "ABB") {
    cout << "Yes" << endl;
  }

  if (S == "BAA") {
    cout << "Yes" << endl;
  }

  if (S == "BAB") {
    cout << "Yes" << endl;
  }

  if (S == "BBA") {
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 256
import java.util.*;

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

        for(int i = 0; i < x ; i++){
                lang[i] = sc.next();
        }

        for(int z=0 ; z < x; z++){
            System.out.println(lang[z]);
            System.out.println(lang[z]);
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);

  rep(i, n){
    cin >> v[i];
  }
  int nk=min(n, k);
  int ans=0;
  rep(i, nk+1){
    for(int j=n; j>=n+i-nk; j--){
      int sum=0;
      priority_queue<int, vector<int>, greater<int> > PQ;
      rep(ni, i){
        PQ.push(v[ni]);
        sum+=v[ni];
      }
      for(int nj=j; nj<n; nj++){
        PQ.push(v[nj]);
        sum+=v[nj];
      }
      for(int qi=0; !PQ.empty() && qi<k-i-(n-j); qi++){
        int num=PQ.top();PQ.pop();
        if(num<0){
          sum-=num;
        }
      }
      ans=max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
typedef long long int lli;
typedef vector<int> vi;
#define all(x) x.begin(), x.end()
#define FIO     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define endl "\n"
#define pb push_back
#define mp make_pair
#define re(i,n)        for(int i=0;i<(n);i++)
#define re1(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define FORD(i,a,b)     for(int i=(a);i>=(b);i--)
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
const int mod = 1000000007;
//===================================DEBUG TEMPLATE=================================================
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
 
template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
//====================================DEBUG TEMPLATE==============================================
bool vis[100002];
int val[100002];
int a[100002];

int solve(int n)
{
    int result;
    //deb(result);
    if(vis[n])
    {
        result=val[n];
    }
    else
    {
        result=min(solve(n-1)+abs(a[n]-a[n-1])  ,  solve(n-2)+abs(a[n]-a[n-2]) );
        vis[n]=true;
        val[n]=result;
    }
    //deb(n);
    return result;
}

int main()
{
    FIO;
    int n;
    cin>>n;
    // re(i,n+1)
    //     cout<<vis[i]<<" ";
    // cout<<endl;
    re1(i,1,n+1)
        cin>>a[i];
    vis[1]=vis[2]=1;
    val[1]=0;
    val[2]=abs(a[2]-a[1]);

    cout<<solve(n);
}

Measured memory_bytes: 6816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF (1LL<<59)
#define int ll

signed main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    
    
    
    static int dp[2002][2002];
    rep(i,2002)rep(j,2002)dp[i][j] = INF;
    rep(i,n)dp[i][0] = a[i];
    
    
    rep(i,n){
        for(int j=1;j<=n;j++){
            dp[i][j] = min(dp[i][j-1],a[(i-j+n)%n]);
        }
    }
    
    ll ans = INF;
    rep(i,n+1){
        int tmp = 0;
        rep(j,n){
            tmp += dp[j][i];
        }
        tmp+=i*x;
        ans = min<ll>(ans,tmp);
    }
    cout<<ans<<endl;
    
    
    
}

Measured memory_bytes: 31616
n,m=map(int,input().split())
a=[list(str(input())) for _ in range(n)]
b=[list(str(input())) for _ in range(m)]
            
#print(a,b)

for i in range(n-m+1):#二回
    for j in range(n-m+1):#二回
        jugh=True
      #  print(i,j)
        for x in range(m):
            for y in range(m):
         #       print(x,y)
                if a[x+i][y+j]!=b[x][y]:
                    jugh=False
                   # print(x,y)
                    break
        if jugh==True:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include <math.h>
#include<algorithm>
#include <stack>
#include <string>
#define ll long long int
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    long long int n,m;
    long long int a[200005],sum=0;
    scanf("%lld %lld",&n,&m);
    for(long long int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    for(long long int i=0;i<n-m;i++)
    {
        sum+=a[i];
    }
    cout<<sum;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int f[maxn];
int main(){
	int n;
	in(n);
	int ans=0;
	FOR(i,1,n){
		int c;
		in(c);
		ans+=(!f[c]);
		f[c]=true;
	}
	out(ans);
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }


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

	vector<int> a(N);
	vector<int> b(N);

	rep(i, N) cin >> a[i] >> b[i];

	sort(all(b), greater<int>());
	vector<int> sum_b(N + 1);

	rep(i, N) sum_b[i + 1] = sum_b[i] + b[i];

	auto max_a = *max_element(all(a));

	int ans = H;

	reple(i, 0, N)
	{
		int tmpH = H - sum_b[i];

		if (tmpH <= 0)
		{
			chmin(ans, i);
		}
		else
		{
			int counta = tmpH / max_a;
			if (tmpH % max_a > 0) counta++;
			chmin(ans, counta + i);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define all(x) x.begin(),x.end()
#define vsort(x) sort(all(x))
#define vrev(x) reverse(all(x));
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define opsp(x) cout<<x<<' '
#define opy cout<<"YES\n"
#define opn cout<<"NO\n"
#define flush fflush(stdout)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define reprev(i,a,b) for(int i=a;i>=b;i--)

void solve(){
	string s,t;int c=0;
	cin>>s>>t;
	for(int i=0;i<(int)s.length();i++){
		if(s[i]!=t[i]) c++;
	}
	cout<<c;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    //test{solve();}
	solve();
    return 0;
}


Measured memory_bytes: 3796
s=str(input())
s=list(s)
l=[]

for i in range(len(s)):
    if s[i]=='A' or s[i]=='C' or s[i]=='T' or s[i]=='G':
        l.append(1)
    else:
        l.append(0)

count=0
a=[]
for i in range(len(s)):
    if (l[i]!=0):
        #if l[i]==1:
        count+=1
    a.append(count)
    if l[i]==0:
        count=0
#    count=0
print(max(a))
"""     
        print()
    while l[i]==1:
        count+=1
        print(count)
 """    
    #if l[i]==0:
        



Measured memory_bytes: 3064
package main

import (
	"fmt"
)

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

	ans := "No"
	if n % 7 == 0 {
		ans = "Yes"
	} else {
		for i := 0; i < n; i += 7 {
			if (n-i)%4 == 0 {
				ans = "Yes"
				break
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
while True:
    m,f,r=map(int,input().split())
    if m==f==r==-1:
        break

    elif m==-1 or f==-1:
        print("F")

    elif m+f>=80:
        print("A")

    elif 65<=m+f<80:
        print("B")

    elif 50<=m+f<65:
        print("C")

    elif r>=50:
        print("C")

    elif 30<=m+f<50:
        print("D")

    else:
        print("F")

Measured memory_bytes: 7720
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a,b,c,d,n=0, ans = 0,ans2=0;
	string s;
	cin >>a >>b>>c>>d;
	ans = min(a, b);
	ans2 = min(c, d);
	cout << ans+ans2 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())


d = [0]*K
a = [0]*K

for i in range(K):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))

n = list(range(1,N+1))

for i in range(K):
    for j in range(d[i]):
        for k in range(len(n)):
            if n[k] == a[i][j]:
                n[k] = 0

ans = 0
for i in range(len(n)):
    if n[i] != 0:
        ans += 1

print(ans)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f;

   while(cin>>a)
   {
       string s;
       double g,h;
       for(b=1;b<=a;b++)
       {
           cin>>g>>s;
           if(s[0]=='J')
           {
               h+=g;
           }
           else
           {
               h+=(g*380000.0);
           }
       }
       printf("%lf\n",h);
   }






    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long n,s;
  scanf("%ld %ld", &n, &s);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long mod = 998244353;
  long value;
  long dp[n][s+1];
  for (long i = 0; i < n; i++) {
    for (long j = 0; j <= s; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 2;
  if (a[0] <= s) {
    dp[0][a[0]] = 1;
  }
  for (long i = 1; i < n; i++) {
    for (long j = 0; j <= s; j++) {
      dp[i][j] += dp[i-1][j]*2;
      dp[i][j] %= mod;
      value = j+a[i];
      if (value <= s) {
        dp[i][value] += dp[i-1][j];
        dp[i][value] %= mod;
      }
    }
  }
  printf("%ld\n", dp[n-1][s]);

  return 0;
}

Measured memory_bytes: 72004
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    D_sum = sum((int(i) for i in str(N)))
    print("YNeos"[N%D_sum!=0::2])
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    string N;
    cin >> N;
    ll K;
    cin >> K;
    ll len = N.size();
    vector<vector<ll> > dp1(len + 1, vector<ll>(4));
    vector<vector<ll> > dp2(len + 1, vector<ll>(4));
    rep(i,len + 1){
        rep(j,4){
            dp1[i][j] = 0;
            dp2[i][j] = 0;
        }
    }
    dp1[1][1] = 1;
    dp2[1][0] = 1;
    dp2[1][1] = ctoi(N[0]) - 1;
    for (ll i = 1; i < len; i++){
        if (ctoi(N[i]) == 0){
            dp1[i + 1][1] = dp1[i][1];
            dp1[i + 1][2] = dp1[i][2];
            dp1[i + 1][3] = dp1[i][3];
            dp2[i + 1][0] = dp2[i][0];
            dp2[i + 1][1] += dp2[i][0] * 9;
            dp2[i + 1][1] += dp2[i][1];
            dp2[i + 1][2] += dp2[i][1] * 9;
            dp2[i + 1][2] += dp2[i][2];
            dp2[i + 1][3] += dp2[i][2] * 9;
            dp2[i + 1][3] += dp2[i][3];
        }
        else{
            dp1[i + 1][1] = dp1[i][0];
            dp1[i + 1][2] = dp1[i][1];
            dp1[i + 1][3] = dp1[i][2];
            dp2[i + 1][1] += dp1[i][0] * (ctoi(N[i]) - 1);
            dp2[i + 1][1] += dp1[i][1];
            dp2[i + 1][2] += dp1[i][1] * (ctoi(N[i]) - 1);
            dp2[i + 1][2] += dp1[i][2];
            dp2[i + 1][3] += dp1[i][2] * (ctoi(N[i]) - 1);
            dp2[i + 1][3] += dp1[i][3];
            dp2[i + 1][0] += dp2[i][0];
            dp2[i + 1][1] += dp2[i][0] * 9;
            dp2[i + 1][1] += dp2[i][1];
            dp2[i + 1][2] += dp2[i][1] * 9;
            dp2[i + 1][2] += dp2[i][2];
            dp2[i + 1][3] += dp2[i][2] * 9;
            dp2[i + 1][3] += dp2[i][3];
        }
    }
    cout << dp1[len][K] + dp2[len][K] << endl;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    left = [A[0]] * N
    right = [A[-1]] * N

    for i in range(1,N):
        left[i] = max(A[i], left[i-1])
    for i in reversed(range(0,N-1)):
        right[i] = max(A[i], right[i+1])

    for i in range(N):
        if i == 0:
            print(right[1])
        elif i == N-1:
            print(left[N-2])
        else:
            print(max(left[i-1], right[i+1]))


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15592