akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdlib>
#include <cstring>

struct Node{
    int key;
    Node *next,*prev;
};

// 番兵
Node* nil;

Node* searchList(int key){
    Node* cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node* cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil) break;
        if(isf++ > 0){
            printf(" ");
        }
        printf("%d",cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node* n){
    if(n == nil) return;
    n->prev->next = n->next;
    n->next->prev = n->prev;
    free(n);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(searchList(key));
}

void insert(int key){
    Node* node = (Node*)malloc(sizeof(Node));
    node->key = key;
    // 番兵の次に要素を追加
    node->next = nil->next;
    nil->next->prev = node;
    nil->next = node;
    node->prev = nil;
}

int main(){
    int key,n;
    int size = 0;
    char com[20];
    int np = 0,nd = 0;
    scanf("%d",&n);
    init();
    
    for(int i = 0;i < n;++i){
        scanf("%s%d",com,&key);
        
        if(com[0] == 'i'){
            insert(key);
            np++;
            size++;
        }else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F'){
                    deleteFirst();
                }
                else if(com[6] == 'L'){
                    deleteLast();
                }
            }
            else{
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}



Measured memory_bytes: 33928
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a==b) cout << c << endl;
	if(b==c) cout << a << endl;
	if(c==a) cout << b << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, a, cnt = 1, ans = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a % 2 == 0) {
			cnt *= 2;
		}
		ans *= 3;
	}
	printf("%d\n", ans - cnt);
	return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef pair<int, int>  P;
typedef pair<int, P>  PP;
const int maxn=4e3+10;
char a[maxn],b[maxn],c[maxn];
bool xab[maxn],xba[maxn],xbc[maxn],xac[maxn],xcb[maxn];
int main()
{
    cin>>a>>b>>c;
    int lena=strlen(a),lenb=strlen(b),lenc=strlen(c);
    int len=max(max(strlen(a),strlen(b)),strlen(c));
    for(int i=-len;i<=len;i++)
    {
        int flag=0;
        for(int j=0;j<lena;j++)
        {
            if(0<=j+i&&j+i<lenb)
            {
                if(a[j]!='?'&&a[j]!=b[i+j]&&b[i+j]!='?')
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0){
            xab[i+len]=1;
        }
    }
    
    for(int i=-len;i<=len;i++)
    {
        int flag=0;
        for(int j=0;j<lenb;j++)
        {
            if(0<=j+i&&j+i<lenc)
            {
                if(b[j]!='?'&&b[j]!=c[i+j]&&c[i+j]!='?')
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0){
            xbc[i+len]=1;
        }
    }
    
    for(int i=-len;i<=len;i++)
    {
        int flag=0;
        for(int j=0;j<lena;j++)
        {
            if(0<=j+i&&j+i<lenc)
            {
                if(a[j]!='?'&&a[j]!=c[i+j]&&c[i+j]!='?')
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)
            xac[i+len]=1;
    }
    
    int ans=1e9;
    for(int i=-len*2;i<=len*2;i++)
        for(int j=-len*2;j<=len*2;j++)
        {
            int l=0,r=lena;
            l=min(min(-i,-j),l);
            r=max(r,max(-i+lenb,-j+lenc));
            if(-len<=i&&i<=len&&xab[i+len]==0)
                continue;
            int p=j-i;
            if(-len<=p&&p<=len&&xbc[p+len]==0)
                continue;
            
            if(-len<=j&&j<=len&&xac[j+len]==0)
                continue;
            
            ans=min(r-l,ans);
        }
    cout<<ans;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,d,e;
  
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

  if((c-e>=0&&c+e<=a)&&(d-e>=0&&d+e<=b)) printf("Yes\n");
  else printf("No\n");
  
    return 0;

}



Measured memory_bytes: 2692
N = int(input())
T, A = 1, 1
for i in range(N):
    t, a = map(int, input().split())
    # それぞれ一番近い倍数をもとめる
    tt = (T + t - 1) // t
    at = (A + a - 1) // a
    # 大きい方で掛ける
    mt = max([tt, at])
    T = t * mt
    A = a * mt
print(T + A)


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

using namespace std;

int V;  //  頂点数
const int MAX_V = 10001;
vector<int> G[MAX_V];  // グラフの隣接リスト表現
int match[MAX_V];      // マッチングのペア
bool used[MAX_V];      // DFS で既に調べたかのフラグ

// u と v を結ぶ辺をグラフに追加する
void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

// 増加パスを DFSで探す
bool dfs(int v) {
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        int u = G[v][i], w = match[u];
        if (w < 0 || !used[w] && dfs(w)) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

// 二部グラフの最大マッチングを求める
int bipartite_matching() {
    int res = 0;
    memset(match, -1, sizeof(match));
    //cout << "V:" << V << endl;
    for (int v = 0; v < V; v++) {
        //cout << "v:" << v << " match[v]:" << match[v] << endl;
        if (match[v] < 0) {
            memset(used, 0, sizeof(used));
            if (dfs(v)) {
                res++;
            }
        }
    }
    return res;
}

int main(int argc, char *argv[]) {
	int x, y, e;
	cin >> x >> y >> e;
    V = x + y;
	for (int i = 0; i < e; i++) {
	    int from, to;
	    cin >> from >> to;
	    add_edge(from, to + 1000);
	}
    cout << bipartite_matching() << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pii pair<ll,ll>
#define forn(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int main()
{
      boost;
      ll a,b;
      char c;
      cin>>a>>c>>b;
      if(c=='+')
      cout<<(long long int)a+b<<endl;
      else if(c=='-')
      {
            cout<<a-b<<endl;
      }
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

signed main() {

	int N;
	cin >> N;
	vector<int> x(N), y(N);
	rep(i, N) cin >> x[i] >> y[i];

	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	int ans = INF;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			int p = x[j] - x[i];
			int q = y[j] - y[i];

			UnionFind uf(N);
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (k == l) continue;
					if (x[l] - x[k] == p && y[l] - y[k] == q) uf.unite(k, l);
				}
			}
			int t = 0;
			for (int k = 0; k < N; k++) {
				if (uf.unite(0, k)) t++;
			}
			ans = min(ans, t);

		}
	}
	cout << ans+1 << endl;

	return 0;
}


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

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl


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

int main(void) {
  string s, t;
  int a, b;
  string u;
  cin >> s >> t >> a >> b >> u;

  if(s==u){
    prt2(a-1, b);
  } else {
    prt2(a, b-1);
  }

}


Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
w = [str(input()) for i in range(n)]

flag = 1

if len(w) != len(set(w)):
    flag = 0

# print(w)
moji = w[0][-1]
for i in w[1:]:
    # print(i)
    if moji != i[0]:
        flag = 0
    moji = i[-1]

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


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {

	int N, K;
	cin >> N >> K;

	vector<int> d(K);
	vector<int> X(1000);
	int k = 0;
	set<int> A;

	for (int i = 0; i < K; ++i)
	{
		cin >> d[i];
		for (int j = 0; j < d[i]; ++j)
		{
			cin >> X[k];
			k++;
		}
		k++;
	}

	for (int i = 0; i < 1000; ++i)
	{
		A.insert(X[i]);
	}

	cout << N - A.size()+1 << endl;

	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 56;

int c[N];

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		++c[--u]; ++c[--v];
	}
	for (int i = 0; i < n; ++i) {
		printf("%d\n", c[i]);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main(){
  vector<int> v(5);
  for(int i = 0;i < 5;i++){
    cin >> v[i];
  }
  int k;
  cin >> k;
  for(int i = 0; i < 5;i++){
    for(int j = i+1;j<5;j++){
      if(abs(v[i]-v[j])>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int digit(int n){
   if(n < 10)  return n;
   return digit(n/10) + n%10;
}
int main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  
  cout<<max({A,B,C})*pow(2,K)+A+B+C-max({A,B,C});
return 0;}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int n,q;
    cin>>n;
    ll x,sum=0;
    ll d[100001]={0};
    for(int i=0;i<n;i++){
        cin>>x;
        d[x]++;
        sum+=x;
    }
    cin>>q;
    ll a,b;
    while(q--){
        cin>>a>>b;
        sum-=d[a]*a;
        sum+=d[a]*b;
        d[b]+=d[a];
        d[a]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 4416
s=input()
l=len(s)
sum=0
for i in range(l):
  tmp=0
  for j in range(0,l-i+1):
    r=2**(max(j-1,0))*2**(max(l-j-i-1,0))
    #print(j,l-j-i,s[j:j+i],r)
    if not (s[j:j+i]==''):
    	tmp=int(s[j:j+i])*r
    sum+=tmp
print(sum+int(s))
    

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> dx;
  vector<int> dy;
  int n = s.length();
  bool x_mode = true;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(s[i]=='T'){
      if(x_mode){
        dx.push_back(cnt);
      }else{
        dy.push_back(cnt);
      }
      cnt = 0;
      x_mode = !x_mode;
    }else{
      cnt++;
      if(i==n-1){
        if(x_mode){
          dx.push_back(cnt);
        }else{
          dy.push_back(cnt);
        }
      }
    }
  }
  if(dy.size()==0){
    dy.push_back(0);
  }
  bool dpx[dx.size()][16001];
  bool dpy[dy.size()][16001];
  for(int j = 0; j < 16001; j++){
    dpx[0][j] = (j==dx[0]+8000) ? true : false;
    dpy[0][j] = (j==dy[0]+8000||j==-dy[0]+8000) ? true : false;
  }
  for(int i = 1; i < dx.size(); i++){
    for(int j = 0; j < 16001; j++){
      dpx[i][j] = ((j-dx[i]>=0) ? dpx[i-1][j-dx[i]] : false )|| ((j+dx[i]<=16000) ? dpx[i-1][j+dx[i]] : false );
    }
  }
  for(int i = 1; i < dy.size(); i++){
    for(int j = 0; j < 16001; j++){
      dpy[i][j] = ((j-dy[i]>=0) ? dpy[i-1][j-dy[i]] : false )|| ((j+dy[i]<=16000) ? dpy[i-1][j+dy[i]] : false );
    }
  }
  int x,y;
  cin >> x >> y;
  if(dpx[dx.size()-1][x+8000]&&dpy[dy.size()-1][y+8000]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 124288
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n,m;
	cin >> n >> m;

	ll x[n],y[n],z[n];
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	int sign[3];
	ll sum[n];
	ll ans=0;
	for(int i=0;i<(1<<3);i++){
		for(int j=0;j<3;j++){
			if((i>>j & 1) == 0) sign[j]=1;
			else		sign[j]=-1;
		}
		for(int j=0;j<n;j++) sum[j] = x[j]*sign[0]+y[j]*sign[1]+z[j]*sign[2];
		sort(sum,sum+n,greater<ll>());
		ll tmp=0;
		for(int j=0;j<m;j++) tmp+=sum[j];
		ans = max(ans,tmp);
	}
	cout << ans << "\n";

	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;


void init()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 3e3+3;

vector<pair<int, int>> arr;

int dp[N][N];
int n;
int solve(int idx, int t){
	if(idx == n || t <= 0)
		return 0;
	int & cur = dp[idx][t];
	if(~cur)
		return cur;
	return cur = max(arr[idx].second + solve(idx+1, t - arr[idx].first), solve(idx+1, t));
}

int main()
{
	init();
	int t;
	clr(dp, -1);
	cin >> n >> t;
	lp(i, n){
		int n1, n2;
		cin >> n1 >> n2;
		arr.push_back({n1, n2});
	}
	sort(arr.begin(), arr.end());
	cout << solve(0, t);
	return 0;
}


Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
using namespace std;
using ll = long long int;
int main()
{
    int n;
    cin >> n;

    vector<int> high(n);
    for (size_t i = 0; i < n; i++)
    {
        int hi;
        cin >> hi;
        high[i] = hi;
    }

    vector<int> move(n);
    for (int i = (n - 1); i >= 0; i--)
    {
        if (i == (n - 1))
        {
            move[i] = 0;
        }
        else if (high[i] >= high[i + 1])
        {
            move[i] = move[i + 1] + 1;
        }
        else
        {
            move[i] = 0;
        }
    }

    int ans = *max_element(move.begin(), move.end());
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 100
#define MAX_M 100

int n, m;
int s1[MAX_N];
int s2[MAX_M];

vector<int> ans_list[2];

int main(){
	
	while (true){
	
		cin >> n >> m;
		if (n == 0 && m == 0)
			break;

		int sum1 = 0, sum2 = 0;

		for (int i = 0; i < n; i++){
			cin >> s1[i];
			sum1 += s1[i];
		}
	
		for (int i = 0; i < m; i++){
			cin >> s2[i];
			sum2 += s2[i];
		}

		sort(s1, s1 + n);
		sort(s2, s2 + m);

		bool flag = false;

		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				sum1 -= s1[i];
				sum2 -= s2[j];
				sum1 += s2[j];
				sum2 += s1[i];
				if (sum1 == sum2){

					ans_list[0].push_back(s1[i]);
					ans_list[1].push_back(s2[j]);
					i = n;
					j = m;
					flag = true;
					break;
				}
				sum1 += s1[i];
				sum2 += s2[j];
				sum1 -= s2[j];
				sum2 -= s1[i];
			}
		}

		if (!flag){
			ans_list[0].push_back(-1);
			ans_list[1].push_back(-1);
		}

	}

	for (int i = 0; i < ans_list[0].size(); i++){
		if (ans_list[0][i] != -1)
			cout << ans_list[0][i] << " " << ans_list[1][i] << endl;
		else
			cout << -1 << endl;
	}

	return 0;

}

Measured memory_bytes: 1216
while True:
    z=list(map(int,input().split()))
    if z == [-1,-1,-1]:
        break
    if z[0]==-1 or z[1]==-1:
        print('F')
    elif z[0]+z[1]>=80:
        print('A')
    elif z[0]+z[1] >=65:
        print('B')
    elif z[0]+z[1] >=50 or z[2] >=50:
        print('C')
    elif z[0]+z[1] >=30 :
        print('D')
    else :
        print("F")

Measured memory_bytes: 7660
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s[110];
	char t[8] = "keyence";
	cin >> s;
	int cnt = 0;
	rep(i, min((int)strlen(s), 7)) {
		if (s[i] == t[i]) {
			cnt++;
		}
		else {
			break;
		}
	}
	rep(i, min((int)strlen(s), 7)) {
		if (s[strlen(s) - 1 - i] == t[6 - i]) {
			cnt++;
		}
		else {
			break;
		}
	}
	YES(cnt >= 7);
	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  n = sc.nextLine();
        int total = 0;

        for (char i : n.toCharArray())
            total += Integer.parseInt(String.valueOf(i));

        double div = Double.parseDouble(n) / total;

        if (div == (int) div)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 21716
#B - Substring
S = input()
T = input()
ans = 10**9
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Measured memory_bytes: 9116
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end


class UnionFindTree
  attr_accessor:par,:rank
  def initialize(n)
    @par=Array.new(n){|i| i}
    @rank=array(n,1,0)
  end

  def find(x)
    return x if @par[x]==x
    @par[x]=find(@par[x])
    return @par[x]
  end

  def union(x,y)
    x=find(x)
    y=find(y)
    if @rank[x]<@rank[y]
      @par[x]=y
    else
      @par[y]=x
      @rank[x]+=1 if @rank[x]==@rank[y]
    end
  end

  def same?(x,y)
    return find(x)==find(y)
  end
end
class Edge
  attr_accessor:to,:from,:c
  def initialize(from,to,cost)
    @from=from
    @to=to
    @c=cost
  end
end
V,E=get_i
edges=array(E,1)
E.times do|i|
  s,t,w=get_i
  edges[i]=Edge.new(s,t,w)
end
uft=UnionFindTree.new(V)

edges.sort!{|x,y| x.c<=>y.c}
ans=0
E.times do|i|
  e=edges[i]
  unless uft.same?(e.from,e.to)
    uft.union(e.from,e.to)
    ans+=e.c
  end
end
puts ans


Measured memory_bytes: 15980
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,P;
    cin >> N >> P;
    ll tmp=2;
    ll cnt;
    ll ans=1;
    if(N==1){
      cout << P;
    }else{
      cnt=0;
      while(P%tmp==0){
        P=P/tmp;
        cnt++;
      }
      ans*=pow(tmp,cnt/N);
      tmp=3;
      while(tmp*tmp<=P){
          cnt=0;
          while(P%tmp==0){
            P=P/tmp;
            cnt++;
          }
          ans*=pow(tmp,cnt/N);
          tmp+=2;
        }
        cout << ans;
      }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
x = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
  
l = primes(101010)
c = Counter(l)

while c[x] != 1:
  x+=1

print(x)

Measured memory_bytes: 4564
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i].fi;
    a[i].se = i + 1;
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; ++i) {
    cout << a[i].se << " \n"[i == n - 1];
  }
}


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

int main()
{
	long long num,i,j,tmp;
	string s;
	cin >> s;
	for(i=0;i<8;i++)
	{
		for(num=i,tmp=s[0]-'0',j=1;j<4;num/=2,j++)
			if(num&1) tmp+=s[j]-'0';
			else tmp-=s[j]-'0'; 
		if(tmp==7) break;
	}
	for(j=1,cout << s[0];j<4;i/=2,cout << s[j],j++)
		if(i&1) cout << '+';
		else cout << '-';
	puts("=7");	
}

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

int main()
{
    int n,q,i;
    string s;
    cin >> n >> q >> s;
    vector<int> list;
    for(i = 0;i < n-1;++i){
        if(s.at(i) == 'A' && s.at(i+1) == 'C'){
            list.push_back(i+1);
        }
    }
    int l,r,low,high;
    for(i = 0;i < q;++i){
        cin >> l >> r;
        if(list.size() == 0){
            cout << 0 << endl;
        }else{
            low =  lower_bound(list.begin(),list.end(),l)-list.begin();
            high = upper_bound(list.begin(),list.end(),r-1)-list.begin();
            cout << high-low << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 1276
def check(s):
    c = False
    if s[:3] == "AGC" or s[1:] == "AGC" or s[0] + s[2:] == "AGC" or s[:2] + s[3] == "AGC" or s[:3] == "ACG" or s[1:] == "ACG" or s[:3] == "GAC" or s[1:] == "GAC":
        c = True
    return c

from collections import defaultdict
from itertools import product
N = int( input())
Q = 10**9 + 7
dp = [ defaultdict( int) for _ in range(N+1)]

for s in product("AGCT", repeat = 3):
    dp[3]["".join(s)] = 1
ans = 0
for i in range(4, N+1):
    for c in product("AGCT", repeat = 3):
        c = "".join(c)
        for t in "AGCT":
            if check(c+t):
                # print(c+t, dp[i-1][c])
                ans += (dp[i-1][c]*pow(4,N-i,Q))%Q
                ans %= Q
            else:
                dp[i][c[1:]+t] += dp[i-1][c]
                dp[i][c[1:]+t] %= Q
if N == 3:
    ans = 3
print( (pow(4,N,Q) - ans)%Q)

Measured memory_bytes: 4164
#include<stdio.h>
int main(void)
{
  long long d,i,j=1,x,y,integral,ans;
  
  
  while(scanf("%lld",&d)!=EOF)
    {
      integral=0;
      j=0;
      for(i=1;i<=600;i+=d)
	{
	  y=0;
	  x=0;
	  ans=0;
	  y=j*d*j*d;
	  x=d;
	  ans=x*y;
	  integral+=ans;
	  j++;	
	}
      printf("%lld\n",integral);
    }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}

void init_com() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll _fact[200005];
void init_fact() {
  _fact[0] = 1;
  ll num = 1;
  for (ll i = 1; i < 200000; i++) {
    num = num * i % MOD;
    _fact[i] = num;
  }
}
ll fact(ll num) {
  // cout << "num:" << num << endl;
  if (num <= 1) {
    return 1;
  }
  return _fact[num];
}

int main() {
  init_com();
  init_fact();

  ll n, k;
  scanf("%lld %lld", &n, &k);

  ll ans = 0;
  ll bottom = max(n - k, 1LL);
  for (ll r = n; r >= bottom; r--) {
    ll people = n - r;

    ll plus;

    if (people == 0) {
      plus = 1;
    } else {
      ll p = com(n, r);

      ll f1 = fact(people + r - 1);
      ll f2 = fact(people);
      ll f3 = fact(r - 1);

      // plus = p * f1 / f2 / f3;
      plus = p % MOD;
      plus = plus * f1 % MOD;
      plus = plus * modinv(f2, MOD) % MOD;
      plus = plus * modinv(f3, MOD) % MOD;
    }

    ans = (ans + plus) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 13824
from collections import Counter
N = int(input())
A_arr = list(map(int, input().split()))

A_arr = sorted(A_arr, reverse=True)
C_arr = Counter(A_arr)

count = 0
for i in range(N):
    v_max = A_arr[i]
    if C_arr[v_max] == 0:
        continue
    C_arr[v_max] -= 1
    v_pair = 2**v_max.bit_length() - v_max
    if C_arr[v_pair] > 0:
        C_arr[v_pair] -= 1
        count += 1
    else:
        pass

print(count)

Measured memory_bytes: 33424
#include <stdio.h>

int main(void)
{
	char i,j;
	
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1756
import java.util.*;
import java.util.TreeMap;
import java.util.Map;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        
        for(int i=1; i<=N-1; i++){
            map.put(i, 0);
        }
        for(int i=1; i<=N-1; i++){
            for(int j=i+1; j<=N; j++){
                int r = Math.min(j - i, Math.abs(X - i) + Math.abs(j - Y) + 1);
                r = Math.min(r, Math.abs(Y - i) + Math.abs(j - X) + 1);
                if(map.containsKey(r)){
                    map.put(r, map.get(r) + 1);
                }
                else{
                    map.put(r, 1);
                }
            }
        }
        for(int x : map.keySet()){
            System.out.println(map.get(x));
        }
    }
}

Measured memory_bytes: 60764
#!/usr/bin/env python3

n,m,l = map(int,input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
  data = input().split()
  for j in range(m):
    A[i][j] = int(data[j])

for i in range(m):
  data = input().split()
  for j in range(l):
    B[i][j] = int(data[j])

for i in range(n):
  for j in range(l):
    for k in range(m):
      C[i][j] += A[i][k]*B[k][j]

for i in range(n):
  print(*C[i])


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

set<ll> row, col, pls, mns;
vector<string> c(8);

bool dfs(ll x = 0) {
    if (x == 8) {
        rep(i, 8) printf("%s\n", c[i].c_str());
        return true;
    }
    if (col.count(x) == 0) return dfs(x + 1);
    bool f = false;
    rep(y, 8) {
        if (row.count(y) == 0) continue;
        ll p = x + y;
        ll m = x - y + 7;
        if (pls.count(p) == 0) continue;
        if (mns.count(m) == 0) continue;
        c[y][x] = 'Q';
        row.erase(y);
        pls.erase(p);
        mns.erase(m);
        if (dfs(x + 1)) {
            f = true;
            break;
        }
        c[y][x] = '.';
        row.insert(y);
        pls.insert(p);
        mns.insert(m);
    }
    return f;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    rep(i, 8) c[i] = "........";
    rep(i, 8) {
        ll y, x;
        cin >> y >> x;
        c[y][x] = 'Q';
    }
    rep(i, 8) {
        row.insert(i);
        col.insert(i);
    }
    rep(i, 15) {
        pls.insert(i);
        mns.insert(i);
    }
    rep(i, 8) {
        rep(j, 8) {
            if (c[i][j] == 'Q') {
                row.erase(i);
                col.erase(j);
                pls.erase(i + j);
                mns.erase(j - i + 7);
            }
        }
    }
    dfs();
    return 0;
}



Measured memory_bytes: 3236
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6 + 5;
const int maxn2 = 1e5 + 5;
int a[maxn], b[maxn], vis[maxn];

int main()
{
    int n;
    cin >> n;
    memset(b, 0, sizeof b);
    memset(vis, 0, sizeof vis);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        if (vis[a[i]]) 
        {
            b[a[i]] = 1;
            continue;
        }
        for (int j = 2; j * a[i] <= 1000000; j++)
        {
            b[j * a[i]] = 1;
        }
        vis[a[i]] = 1;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += b[a[i]] == 0;
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
    long long k,a,b,s,sum=1;
    cin>>k>>a>>b;
    s=b-a;
    if (s<=2) {
        cout<<k+1<<endl;
    }
    
    else{
        for (int i=1; k>0; i++) {
            
            
        
            
            if (sum>=a&&k>=2) {
                sum+=s;
                sum-=1;
                k-=2;
            }
            else k-=1;sum+=1;
        }
        cout<<sum<<endl;
        
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main(){
    int n, k;
    cin>>n>>k;
    int a;
    long double j, c=0.0;
    for(int i=1;i<=n;i++){
        a=i;
        j=1.0;
        while(a<k){
            a*=2;
            j/=2.0;
        }
        c+=j/n;
    }
    cout<<fixed<<setprecision(12)<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc163/tasks/abc163_d


def main():
    n, k = map(int, input().split(" "))
    # このやり方だと当然TLE
    # total = 0
    # for i in range(k, n + 2):
    #     a = 0
    #     b = 0
    #     for j in range(i):
    #         a += j
    #         b += n - j
    #     total += b - a + 1
    # print(total)
    max_num = sum(range(n - k + 1, n + 1))
    min_num = sum(range(k))
    c = max_num - min_num + 1
    total = c
    for i in range(k, n + 1):
        max_num += n - i
        min_num += i
        c = max_num - min_num + 1
        total += c
    print(total % 1000000007)


if __name__ == '__main__':
    main()


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

int main(){
    int H,W;
    int a,b;
    
    while(1){
        cin >> H >> W;
        
        if(H==0||W==0)break;
    
        for(a=1;a<=H;a++){          //aをHの数だけ繰り返す
            if (a==1||a==H){        //上端か下端の時
                for(b=1;b<=W;b++){  //bをWの数だけ繰り返す
                    cout << '#' ;
                }
            
               
            }
            else{                   //上端でも下端でもない時
                for(b=1;b<=W;b++){
                    if(b==1||b==W){     //右端か左端の時
                        cout << '#';
                    }
                    else{               //右端でも左端でもない時
                        cout << '.';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N - a; b++) {
            int c = N - a - b;
            if (10000 * a + 5000 * b + 1000 * c == Y) {
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
def is_ancestor?(name1, name2)
  return true if name2 == @top
  p = name1
  while p != @top
    p = @parent[p]
    return true if p == name2
  end
  false
end

loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  @parent = {}
  cur_gen = 0
  @top = gets.chomp
  current = [@top]
  (n-1).times do
    name = gets.chomp
    gen = name.count(' ')
    name.delete!(' ')
    @parent[name] = current[gen - 1]
    current[gen] = name
    cur_gen = gen
  end

  m.times do
    s = gets.chomp.chop.split
    case s[3]
    when 'child'
      puts @parent[s[0]] == s[5] ? 'True' : 'False'
    when 'parent'
      puts @parent[s[5]] == s[0] ? 'True' : 'False'
    when 'sibling'
      puts @parent[s[0]] == @parent[s[5]] ? 'True' : 'False'
    when 'descendant'
      puts is_ancestor?(s[0], s[5]) ? 'True' : 'False'
    when 'ancestor'
      puts is_ancestor?(s[5], s[0]) ? 'True' : 'False'
    end
  end
  puts
end

Measured memory_bytes: 9060
import sys
input = sys.stdin.readline

N = int(input())

G = [[] * N for _ in range(N)]
for _ in range(N - 1):
  a, b, c = map(int, input().split())
  G[a - 1].append((b - 1, c))
  G[b - 1].append((a - 1, c))

Q, K = map(int, input().split())

D = [-1] * N
s = [(K - 1, 0)]
while s:
  v, c = s.pop()
  D[v] = c
  for vv, cc in G[v]:
    if D[vv] < 0:
      s.append((vv, cc + c))

for _ in range(Q):
  x, y = map(int, input().split())
  print(D[x - 1] + D[y - 1])

Measured memory_bytes: 46188
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n;
double a;

int main() {
scanf("%d", &n);
a = n / 3.0;
printf("%.10lf\n", a * a * a);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll ans=0;
        ll a,b,n;cin>>n>>a>>b;
        ans=a*(n/(a+b))+min(a,n%(a+b));
        cout<<ans<<endl;
    }   
    return 0;   
}   

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int ans = 0;
			for (int i = 0; i < 50000; i++) {
				int p = i * 108 / 100;
				if (n == p) {
					ans = i;
					break;
				}
			}
			if (ans > 0) {
				Console.WriteLine(ans);
			} else {
				Console.WriteLine(":(");
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
    int i, max, min, size;
    double sum=0;
    scanf("%d", &size);
    int arr[size];

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

    max = -9999999999;
    min=9999999999;

    for(i=0; i<size; i++)
    {
        if(arr[i] > max)
        {
            max = arr[i];
        }

        if(arr[i] < min)
        {
            min = arr[i];
        }
        sum=sum+arr[i];
    }

    printf("%d %d %.0lf\n",min,max,sum);

    return 0;
}




Measured memory_bytes: 2104
#include<cstdio>
#include<vector>
#define l(x) id[x]
#define r(x) id[x]+sz[x]-1
std::vector<int> a[200005];
int n,q,cnt,fa[200005],id[200005],sz[200005],ans[200005],s[200005];
void add(int x,int y){a[x].push_back(y);a[y].push_back(x);}
void dfs(int v)
{
	id[v]=++cnt;sz[v]=1;
	for (int i=0;i<a[v].size();i++)
	{
	    int u=a[v][i];
	    if (u==fa[v]) continue;
	    fa[u]=v;
	    dfs(u);
	    sz[v]=sz[v]+sz[u];
	}
}
void tag(int x,int v){s[l(x)]=s[l(x)]+v;s[r(x)+1]=s[r(x)+1]-v;}
int main()
{
	scanf("%d%d",&n,&q);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
	}
	dfs(1);
	while (q--)
	{
		int x,v;
		scanf("%d%d",&x,&v);
		tag(x,v);
	}
	for (int i=1;i<=n;i++) ans[i]=ans[i-1]+s[i];
	for (int i=1;i<=n;i++) printf("%d ",ans[id[i]]);
	return 0;
}

Measured memory_bytes: 26368
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	string s, t;
	int ans = 0;
	cin >> s;
	cin >> t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;


	return 0;
}

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

int n,dp[110][10][2];

signed main()
{
	ios::sync_with_stdio(false);
	string s;
	int k;
	cin>>s>>k;
	n=s.size();
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++){
		int num=s[i-1]-'0';
		for(int j=0;j<=k;j++){
			for(int l=1;l<=9;l++){
				if(l==num){
					if(j<k) dp[i][j+1][0]+=dp[i-1][j][0];
					if(j<k) dp[i][j+1][1]+=dp[i-1][j][1];
				}
				else if(l>num){
					if(j<k) dp[i][j+1][1]+=dp[i-1][j][1];
				}
				else{
					if(j<k) dp[i][j+1][1]+=dp[i-1][j][0];
					if(j<k) dp[i][j+1][1]+=dp[i-1][j][1];
				}
			}
			if(num==0){
				dp[i][j][0]+=dp[i-1][j][0];
				dp[i][j][1]+=dp[i-1][j][1];
			}
			else{
				dp[i][j][1]+=dp[i-1][j][0];
				dp[i][j][1]+=dp[i-1][j][1];
			}
		}
	}
	cout<<dp[n][k][0]+dp[n][k][1]<<endl;
	return 0;
}

Measured memory_bytes: 256
//Author:: Pham Ngoc Minh- Chuyen Thai Binh
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int const maxn=1e5+5;
int n,a[maxn],dp[maxn];
void nhap()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(i>=3)
        {
            dp[i]=oo;
        }
    }
}
void qhd()
{
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3; i<=n; i++)
    {
        dp[i]=min(dp[i],min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])));
    }
}
void kq()
{
    cout<<dp[n];
}
int main()
{
    bost
    nhap();
    qhd();
    kq();
    //Write Code Here :>>>>
    return 0;
}
// I love Chuyen Thai Binh Verry much ! Now, you alaways in my code of me <3
// Chuyen Thai Binh La Nha :>>


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


signed main(){
    FAST;

    int x, a;
    cin>>x>>a;
    if(x<a) cout<<0;
    else cout<<10;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int INF = 1e9 + 5;
int main()
{
    int n, k;
    scanf("%d%d",&n,&k);
    vi v(n);
    for(int &a : v) scanf("%d",&a);
    vi dp(n + k, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k; j++) dp[i + j] = min(dp[i + j], dp[i] + abs(v[i + j] - v[i]));
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 1024
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // // #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b;
}

Measured memory_bytes: 256
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    N = int(input().rstrip())
    a_list = input().rstrip().split(' ')
    cost = 0
    min_cost = 1e10
    for i in range(-100,101):
        cost = 0
        for a in a_list:
            a_num = int(a)
            cost = cost + (a_num - i) * (a_num-i)
            # print(i,a_num,cost)
        if(cost < min_cost):
            min_cost = cost
            # print('new ans',min_cost)
    print(min_cost)
    
if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll A[200005];
ll Asum[200005];
ll ans=mod;

bool check(ll index,ll border,ll sub){
	ll x=Asum[index]-sub;
	ll y=Asum[border+1]-sub-x;
    if (x>=y) return true;
    else return false;
}
ll binary_search(ll start,ll border,ll sub) {
	//P>=Qとなる最小のindexを返す
    ll ng = start-1; 
    ll ok = border+1; 
    while (abs(ok - ng)>1) {
        ll mid = (ok + ng) / 2;
        if (check(mid,border,sub)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){

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

cin>>N;

rep(i,N) cin>>A[i];

Asum[0]=A[0];
rep1(i,N){
	Asum[i]=Asum[i-1]+A[i];
}

rep1(kiru,N-2){
	ll P,Q;
	ll in=binary_search(0,kiru-1,0);
	if(in==0){
		P=Asum[in];
		Q=Asum[kiru]-P;
	}
	if(0<in<kiru){
		ll P1,Q1;
		P1=Asum[in];
		Q1=Asum[kiru]-P1;
		ll P2,Q2;
		P2=Asum[in-1];
		Q2=Asum[kiru]-P2;
		if(abs(P1-Q1)<=abs(Q2-P2)){
			P=P1; Q=Q1;
		}else{
			P=P2; Q=Q2;
		}
	}if(in==kiru){
		P=Asum[kiru-1];
		Q=Asum[kiru]-P;
	}

	//cout<<in<<endl;

	ll R,S;
	ll ind=binary_search(kiru+1,N-2,Asum[kiru]);
	if(ind==kiru+1){
		R=Asum[ind]-Asum[kiru];
		S=Asum[N-1]-Asum[kiru]-R;
	}
	if(kiru+1<ind<N-1){
		ll R1,S1;
		R1=Asum[ind]-Asum[kiru];
		S1=Asum[N-1]-Asum[kiru]-R1;
		ll R2,S2;
		R2=Asum[ind-1]-Asum[kiru];
		S2=Asum[N-1]-Asum[kiru]-R2;
		if(abs(R1-S1)<=abs(S2-R2)){
			R=R1; S=S1;
		}else{
			R=R2; S=S2;
		}
	}
	if(ind==N-1){
		R=Asum[N-2]-Asum[kiru];
		S=Asum[N-1]-Asum[kiru]-R;
	}

	//cout<<ind<<endl;
	//cout<<P<<" "<<Q<<" "<<R<<" "<<S<<endl;

	ll cmp1=min(min(P,Q),min(R,S));
	ll cmp2=max(max(P,Q),max(R,S));
	ans=min(ans,abs(cmp1-cmp2));
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 3328
#include <iostream>

int main() {
  unsigned N, M, K;
  std::cin >> N >> M >> K;
  for (unsigned i = 0; i <= N; ++i) {
    for (unsigned j = 0; j <= M; ++j) {
      if (i * j + (N - i) * (M - j) == K) {
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 888
n,m = map(int,input().split())
a=[]
b=[]
for i in range(m):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
if min(b)<max(a):
  print(0)
else:
  print(min(b)-max(a)+1)
  

Measured memory_bytes: 11016