akhauriyash/Code-Regression huggingface dataset:
import sys

if __name__ == '__main__':
    A, B = list(map(lambda x:int(x), sys.stdin.readline().split(' ')))
    ans = 0
    for i in range(2):
        if A >= B:
            ans += A
            A -= 1
        else:
            ans += B
            B -= 1
    print(ans)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

//????????????
class Dice {
private:
	map<char, string> mp;
public:
	//string d = "UFRLBD";
	string d = "RENSWL";
	vector<int> v; //UFRLBD:123456
	Dice() {
		init();
		v.resize(6);
	};
	Dice(vector<int> v) :v(v) {
		init();
	};
	void init(){
		mp[d[0]] = "2354";
		mp[d[1]] = "1463";
		mp[d[2]] = "1265";
		mp[d[3]] = "1562";
		mp[d[4]] = "1364";
		mp[d[5]] = "2453";
	}
	void input() { rep(i, 0, 6) { cin >> v[i]; } }
	void roll(char c) { roll(mp[c]); }
	void roll(string s) {
		int tmp = v[s[0] - '1'];
		rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
		v[s[s.size() - 1] - '1'] = tmp;
	}
	bool operator==(const Dice &D)const { return v == D.v; }
};

signed main() {
	int n; cin >> n;
	vector<Dice> D(n); rep(i, 0, n) { D[i].input(); }
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			rep(k, 0, 1000) {
				if (D[i] == D[j]) {
					cout << "No" << endl;
					return 0;
				}
				D[j].roll( D[j].d[rand() % 6] );
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3288
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define REP(i, j, k) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int sum[20000], tmp[20000];

int inv(int n, int r, int *tar) {
    int m = 1;
    for (int i = 0; i < 2 * r; i++) {
        tar[i] = m / n;
        m = (m % n) * 10;
    }
}

int add(int r) {
    int carry = 0;
    for (int i = 2 * r - 1; i >= 0; i--) {
        sum[i] += tmp[i] + carry;
        carry = sum[i] / 10;
        sum[i] %= 10;
    }
}

int main(){
    int n, k, m, r;
    while(cin >>n >>k >>m >>r && (n || k || m || r)){
        inv(n, r, sum);
        if(m == 1){
            REP(i, n, 1){
                inv(n * i, r, tmp);
                add(r);
            }
        }
        cout <<sum[0] <<".";
        REP(i, r + 1, 1) cout <<sum[i];
        cout <<endl;
    }
    return 0;
}

Measured memory_bytes: 1316
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> parse(int n, string& s) {
    char c = s[0];
    int tmp = 1;
    vector<int> res;
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            c = s[i];
            res.push_back(tmp);
            tmp = 1;
        } else {
            tmp++;
        }
    }
    res.push_back(tmp);
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << parse(s.size(), s).size() - 1 << endl;
    return 0;
}

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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

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

    string a;
	cin >> a;

	map<char, ll> cnt;
	ll n = a.size();
	ll ans = n*(n-1)/2;

	for(auto c : a){
		++cnt[c];
	}


	for(auto c : cnt){
		ans -= c.second*(c.second-1)/2;
	}


	ppp(ans+1);



    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  while(cin >> N && N){
    vector<vector<int> > xy(21, vector<int>(21, 0));
    for(int i = 0; i < N; i++){
      int x, y;
      cin >> x >> y;
      xy[y][x] = 1;
    }
    int M;
    cin >> M;
    pair<int, int> player_pos = make_pair(10, 10);  //(y, x)
    int get = 0;
    for(int i = 0; i < M; i++){
      char d;
      int l;
      cin >> d >> l;
      if(d == 'N'){
        player_pos.first += l;
        for(int j = player_pos.first - l; j <= player_pos.first; j++){
          if(xy[j][player_pos.second] == 1){
            get++;
            xy[j][player_pos.second] = 0;
          }
        }
      }else if(d == 'S'){
        player_pos.first -= l;
        for(int j = player_pos.first + l; j >= player_pos.first; j--){
          if(xy[j][player_pos.second] == 1){
            get++;
            xy[j][player_pos.second] = 0;
          }
        }
      }else if(d == 'E'){
        player_pos.second += l;
        for(int j = player_pos.second - l; j <= player_pos.second; j++){
          if(xy[player_pos.first][j] == 1){
            get++;
            xy[player_pos.first][j] = 0;
          }
        }
      }else if(d == 'W'){
        player_pos.second -= l;
        for(int j = player_pos.second + l; j >= player_pos.second; j--){
          if(xy[player_pos.first][j] == 1){
            get++;
            xy[player_pos.first][j] = 0;
          }
        }
      }
      // cout << "(" << player_pos.second << ", " << player_pos.first << ")" << endl;
    }
    // cout << get << endl;
    if(get == N)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,a;cin>>n>>a;
    int x[n];rep(i,0,n)cin>>x[i];
    ll dp[n+1][2501][n+1];
    memset(dp,0,sizeof dp);
    dp[0][0][0]=1;
    rep(i,0,n){
        rep(j,0,2501){
            rep(k,0,n+1){
                dp[i+1][j][k]+=dp[i][j][k];
                if(k<50&&j+x[i]<=2500)dp[i+1][j+x[i]][k+1]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    rep(i,1,n+1){
        ans+=dp[n][i*a][i];
    }
    cout<<ans<<endl;
}


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

using namespace std;
#define pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "yes" << endl 
#define no cout << "no" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
        }
#define max 101
void solve(){ 
	   int N,L;
    string S[max];
    cin >> N >> L;
    for(int i=0; i<N; i++)
       cin >> S[i];
       sort(S,S+N);
    for(int i=0;i<N;i++)
       cout << S[i];
    cout << endl;
}
    
    
int main(){
    booster;
    solve();
    _terminated;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int r, D, x;
int main(void){
    cin >> r >> D >> x;
    REP(i,10){
        x = r*x - D;
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 256
ans_n=0
ans_k=0
count=0
while True:
    try:
        N=list(map(int,input().split(",")))
        ans_n +=N[0]*N[1]
        ans_k +=N[1]
        count +=1
    except:
        print(ans_n)
        ans=ans_k/count
        if int(ans)+0.5<=ans:
            ans=int(ans+1)
        print(ans)
        break



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

int main() {
	int n;
	cin >> n;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];
	vector<ll> asum(n + 1, 0);
	rep(i, n) {
		asum[i + 1] = asum[i] + as[i];
	}
	//dp[i][j]...iからjまでの合成コストの総和の最小値
	//dp[i][j]...min(dp[i][i] + dp[i+1][j] + asum[j] - asum[i-1] ,
	// dp[i][i+1] + dp[i+2][j] + asum[j]  - asum[i-1] , ...
	// dp[i][j-1] + dp[j][j] + asum[j]  - asum[i-1] )
	vector<vector<ll>> dp(n, vector<ll>(n, INF));
	rep(i, n) {
		dp[i][i] = 0;
	}
	for (int length = 2; length <= n; length++) {
		for (int left = 0; left <= n - length; left++) {
			int right = left + length - 1;
			ll add = asum[right + 1] - asum[left];
			ll cost = INF;
			for (int shift = 0; left + shift + 1 <= right; shift++) {
				ll a = dp[left][left + shift] + dp[left + shift + 1][right];
				cost = min(cost, a);
			}
			cost += add;
			dp[left][right] = cost;
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}
	


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

int main(void){
    int n, a[100], count = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];

    for(int i = 0; i < n; ++i){
        int minj = i;
        for(int j = i; j < n; ++j){
            if(a[j] < a[minj]) minj = j;
        }
        swap(a[i], a[minj]);
        if(i != minj) count++;
    }
    for(int i = 0; i < n-1; ++i) cout << a[i] << ' ';
    cout << a[n-1] << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3116
//file_name:ABC46_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    ll ans = 0;

    if(a==b&&b==c){
        ans=1;
    }else if(a!=b&&b!=c&&c!=a){
        ans=3;
    }else{
        ans=2;
    }

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



Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int N = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}
		if (sum >= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 47972
from collections import deque
h,w = map(int,input().split())

Map = []
Cnt = 0
for i in range(h):
    tmp = list(input())
    Cnt += tmp.count('#')
    Map.append(tmp)
q = deque()
q.append((0,0,0,True))
while q:
    y,x,cnt,flag= q.pop()
    if flag ==False:
        continue
    if y<0 or y>=h or x<0 or x>=w:
        continue
    if Map[y][x]!='#':
        continue
    cnt += 1
    if cnt==Cnt and y==h-1 and x == w-1:
        if flag:
            print('Possible')
        exit()
    q.append((y+1,x,cnt,flag))
    q.append((y,x+1,cnt,flag))
    flag = False
    q.append((y-1,x,cnt,flag))
    q.append((y,x-1,cnt,flag))

print('Impossible')

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vt vector
#define pb push_back
#define pob pop_back
#define vi vt<int>
#define vvi vt<vi>
#define vii vt<ii>
#define vvii vt<vii>
typedef long long ll;
#define For(i,a,b) for(int i = a; i < b; i++)
#define foR(i,a,b) for(int i = a; i <= b; i++)
#define roF(i,a,b) for(int i = a - 1; i >= b; i--)
#define Rof(i,a,b) for(int i = a; i >= b; i--)

int a[1000];
vi ans;
signed main (){
//	freopen("test.inp","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin >> n;
	For(i,0,n){
		cin >> a[i];
	}
	Rof(i,n-1,0){
		int vt;
		For(j,0,n){
			if(a[j] == i){
				vt = j;
				break;
			}
		}
		if(vt == i){
			continue;
		}
		For(j,0,vt){
			ans.pb(1);
		}
		For(j,vt,i){
			ans.pb(1);
			ans.pb(n-1);		
		}
		For(j,i,n){
			ans.pb(1);
		}
		For(j,vt,i){
			swap(a[j],a[j+1]);
		}
	}
	cout << ans.size() << "\n";
	For(i,0,ans.size()){
		cout << ans[i] << "\n";
	}
}



Measured memory_bytes: 1016
io = STDIN
t=[]
5.times{ t<<io.gets.to_i}
ar=t.map{|t|[t,t%10==0 ? 10 : t%10]}.sort_by{|i,j|-j}

puts ar[0..-2].inject(0){|s,(i,j)|s+(i/10.0).ceil*10} + ar[-1][0]


Measured memory_bytes: 1788
#include <iostream>
#include <array>
//#include <fstream>
 
int main()
{
    const u_int max_point = 16;
    u_int a, b, n, x, y;
    //std::ifstream ifs("515.txt");
    while(1){
        //ifs >> a >> b;
        std::cin >> a >> b;
        if(a == 0 && b == 0)
            break;
        
        std::array<std::array<u_int, max_point>, max_point> path;
        for(u_int i = 0; i < max_point; ++i){
            path[i].fill(0);
        }
        
        //工事中の点の入力
        //ifs >> n;
        std::cin >> n;
        for(u_int i = 0; i < n; ++i){
            //ifs >> x >> y;
            std::cin >> x >> y;
            path[x - 1][y - 1] = -1;
        }
         
        for(u_int i = 0; i < a; ++i){
            for(u_int j = 0; j < b; ++j){
                if(path[i][j] == -1){
                    path[i][j] = 0;
                }
                else{
                    if(i ==0 && j == 0){
                        path[i][j] = 1;
                    }
                    else if(i == 0){
                        path[i][j] = path[i][j - 1];
                    }
                    else if(j == 0){
                        path[i][j] = path[i - 1][j];
                    }
                    else{
                        path[i][j] = path[i - 1][j] + path[i][j - 1];
                    }
                }
            }
        }
        std::cout << path[a - 1][b - 1] << std::endl;              
    }
    //ifs.close();
 
    return 0;
}

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
N =int(input())
adj = [set() for i in range(N)]

lis =[[int(i)-1 for i in input().split()]for _ in range(N-1)]

ans =["" for i in range(N)]

D =[int(i) for i in input().split()]
D.sort()
wa = sum(D[:-1])

que =[]

for (i,j) in lis:
    adj[i].add(j)
    adj[j].add(i)

for i,se in enumerate(adj):
    if len(list(se))==1:
        que.append(i)

for _ in range(N-1):
    i = que.pop(0)
    j = list(adj[i])[0]
    ans[i] = str(D.pop(0))
    adj[j].remove(i)
    if len(list(adj[j]))==1:
        que.append(j)
i =que.pop(0)
ans[i] = str(D.pop(0))

print(wa)
print(" ".join(ans))

Measured memory_bytes: 8648
n = int(input())
#freq = []
#slst = []
dic1 = {}
for i in range(n):
  temp = input()
  dic1.setdefault(temp, 0)
  dic1[temp] += 1
fmax = max(dic1.values())
mflst = []
ks = list(dic1.keys())
for i in dic1:
  if dic1[i] == fmax:
    mflst.append(i)
    
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

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

int main(){
  int N;
  cin>>N;
  vector<int> T(N);
  for(int i=0;i<N;i++){
    cin>>T.at(i);
  }
  int M;
  cin>>M;
  vector<int> P(M),X(M);
  for(int i=0;i<M;i++){
    cin>>P.at(i)>>X.at(i);
  }
  
  for(int i=0;i<M;i++){
    int sum=0;
    for(int j=0;j<N;j++){
      if(j+1==P.at(i)){
        sum+=X.at(i);
      }else{
        sum+=T.at(j);
      }
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        l:i64,a:i64,b:i64,MOD:i64,
    }
    // 初項a, 公差b, 長さl, mod m

    // let mut v = Matrix::new(vec![vec![1, 2, 3], vec![1, 2, 3], vec![1, 2, 3]]);
    // let mut w = Matrix::new(vec![vec![1, 2, 3], vec![1, 2, 3], vec![1, 2, 3]]);
    // let ans = v.dot(&w, 99999);
    // dbg!(&ans);
    // dbg!(&v.pow(4));
    let mut x = 1;
    let mut ans = 0;
    let mut l = l;
    let mut a = a;
    while l > 0 {
        x *= 10;
        if a >= x {
            continue;
        }
        let mut l2 = min(l, (x - a - 1) / b + 1);
        let mut mat = Matrix::new(vec![vec![1, 0, b], vec![1, x, 0], vec![0, 0, 1]]);
        let mut aa = mat.pow(l2 as usize, MOD);
        ans = ((a % MOD) * aa[1][0] % MOD) + (ans * aa[1][1] % MOD) + aa[1][2] % MOD;
        ans %= MOD;
        ans = (ans + MOD) % MOD;
        l -= l2;
        a += b * l2;
        // a = (a + MOD) % MOD;
    }
    println!("{}", ans);
}

struct Matrix {
    m: Vec<Vec<i64>>,
}
impl Matrix {
    fn new(v: Vec<Vec<i64>>) -> Matrix {
        Matrix { m: v }
    }
    fn set(&mut self, v: Vec<Vec<i64>>) {
        self.m = v.clone();
    }
    fn dot(&self, m: &Matrix, md: i64) -> Vec<Vec<i64>> {
        let a = self.m.len();
        let b = self.m[0].len();
        let c = m.m[0].len();
        // (a,b) -> (b,c)
        let mut ret = vec![vec![0; c]; a];
        for i in 0..a {
            for j in 0..c {
                for k in 0..b {
                    ret[i][j] += (self.m[i][k] % md) * (m.m[k][j] % md) % md;
                }
            }
        }
        ret
    }
    fn pow(&mut self, k: usize, md: i64) -> Vec<Vec<i64>> {
        let n = self.m.len();
        let mut y = vec![vec![0; n]; n];
        for i in 0..n {
            y[i][i] = 1;
        }
        let mut z = self.m.clone();
        let mut k = k;
        while k > 0 {
            if k & 1 == 1 {
                y = Matrix::new(y).dot(&Matrix::new(z.clone()), md);
            }
            z = Matrix::new(z.clone()).dot(&Matrix::new(z.clone()), md);
            k >>= 1;
        }
        y
    }
}


Measured memory_bytes: 2188
from queue import Queue

n,q =map(int,input().split()) ##n:プロセス数、q:クオンタム

qu=Queue()  ##意味を調べる

for i in range(n):
    name,t=input().split()
    qu.put((name,int(t))) ##Queueのput?
    

cnt=0

while qu.qsize()>0: ##qsize?
    name,t=qu.get() 
    cnt+=min(q,t)  ##処理時間と残り時間の小さい方をたす
    if q< t:
        qu.put((name,t-q))  ##残り時間から処理時間を引いて、後ろに回す
    else:
        print(name,cnt)



Measured memory_bytes: 13632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        
        String result = "No";
        if (k*500 >= t) result = "Yes";
        System.out.println(result);
    }
}


Measured memory_bytes: 35612
#include<bits/stdc++.h>
using namespace std;
string a,b;
int lena,lenb;
int main(){
	getline(cin,a),getline(cin,b);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<char>());
	if(a<b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
using namespace std;
int dp[2002] ;
int fun(int x)
{
    if(x==0) return 1 ;
    if(dp[x]!=-1) return dp[x] ;
    int as=0 ;
    for(int i = 3 ; i <= x ; i++)
    {
        as+=fun(x-i) ; as%=mod ;
    }
    return dp[x]=as ;
}
int32_t main()
{
    memset(dp,-1,sizeof(dp)) ;
    int n ; cin>>n ;
    cout<<fun(n)<<endl ;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<K;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int X;
      cin>>X;
      A.at(X-1)=1;
    }
  }
  int cnt=0;
  for(int i=0;i<N;i++) cnt+=A.at(i);
  cout<<N-cnt;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    string s;cin>>s;
    deque<char>v;
    for(int i=0;i<s.size();i++){
        v.pb(s[i]);
    }
    ll q;cin>>q;
    bool r=0;
    while(q--){
        ll d;cin>>d;
        if(d==1)r=1-r;
        else{
            ll a;char b;cin>>a>>b;
            if((a==1&&r==0)||(a==2&&r==1))v.push_front(b);
            else v.pb(b);
        }
    }
    if(r){
        for(int i=v.size()-1;i>=0;i--)cout<<v[i];
    }else{
        for(int i=0;i<v.size();i++)cout<<v[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 976
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int string_compare(const void *a, const void *b)
{
    return(strcmp((char *)a, (char *)b));
}

int main(void){

    char s[5001];

    scanf("%s", s);

    int K;
    int len = strlen(s);

    scanf("%d", &K);

    char t[25001][6];

    int c = 0;

    for(int i = 0; i <= len - 5; i++){
        t[c][0] = s[i];
        t[c][1] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = s[i+3];
        t[c][4] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = s[i+3];
        t[c][4] = s[i+4];
        t[c][5] = '\0';
        c++;
    }

    if(len >= 4){
        int i = len - 4;
        t[c][0] = s[i];
        t[c][1] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = s[i+3];
        t[c][4] = '\0';
        c++;
    }

    if(len >= 3){
        int i = len - 3;
        t[c][0] = s[i];
        t[c][1] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = s[i+2];
        t[c][3] = '\0';
        c++;
    }

    if(len >= 2){
        int i = len - 2;
        t[c][0] = s[i];
        t[c][1] = '\0';
        c++;
        t[c][0] = s[i];
        t[c][1] = s[i+1];
        t[c][2] = '\0';
        c++;
    }

    t[c][0] = s[len-1];
    t[c][1] = '\0';
    c++;

    qsort((void *)t, c, 6, string_compare);

    int l = 1;

    if(K == 1){
        printf("%s\n", t[0]);
    }else{
    for(int i = 1; i < c; i++){
        if(strcmp(t[i], t[i-1]) != 0){
            l++;
        }
        if(l == K){
            printf("%s\n", t[i]);
            break;
        }
    }
    }

    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int c = 0;
    rep(i,n) {
        if (c>x) {
            cout << i << endl;
            return 0;
        }
        c += l[i];
    }
    if (c>x) cout << n << endl;
    else cout << n+1 << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int[] p = new int[a];
        int[] q = new int[b];
        int[] r = new int[c];
        for(int i = 0; i < a; i++){
            p[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < b; i++){
            q[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < c; i++){
            r[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);
        int[] s = new int[x+y];
        for(int i = 1; i <= x; i++){
            s[i-1] = p[a-i];
        }
        for(int i = 1; i <= y; i++){
            s[x+i-1] = q[b-i];
        }
        Arrays.sort(s);
        
        int ri = c-1;
        int si = x+y-1;
        long ans = 0;
        for(int i = 0; i < x+y; i++){
            if(ri >= 0 && r[ri] > s[si]){
                ans += r[ri];
                ri--;
            }else{
                ans += s[si];
                si--;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const ll INF = 0x3f3f3f;


int main(){
    ll n,k;
    cin>>n>>k;
    ll sum[N] = {0};
    ll a[N] = {0};
    rep(i,n){
        cin>>a[i];
        sum[i+1] = sum[i]+a[i];
    }
    ll mx = 0,j = 0;
    for(int i = k+1; i <= n; i++){
        if(sum[i] - sum[i-k] > mx){
            mx = sum[i] - sum[i-k];
            j = i-k;
        }
        // cout<<i<<" "<<i-k<<endl;
    }
    // cout<<j<<endl;
    map<ll,double> mp;
    for(int i = 1; i <= 1000; i++){
        for(int j = 1; j <= i; j++){
            mp[i] += (1.0*j/i);
        }
    }
    double rst = 0;
    for(int i = j; i < j+k; i++){
        // cout<<mp[i]<<endl;
        rst += mp[a[i]];
    }
    printf("%.6lf\n",rst);


    return 0;
}

Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b;
        a = sc.nextInt();
        b = sc.nextInt();
        double c = ((double)(a)+(double)(b))/2;
        long d = Math.round(c);
        System.out.println(d);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int A, B, C, D;
	string s, t;
	cin >> s;
	t = s[0];
	A = stoi(t);
	t = s[1];
	B = stoi(t);
	t = s[2];
	C = stoi(t);
	t = s[3];
	D = stoi(t);

	const int ADD = 0;
	const int SUB = 1;

	int tp = A;
	bool find = false;
	rep(i, 2)
	{
		rep(j, 2)
		{
			rep(k, 2)
			{
				s = to_string(A);
				tp = A;
				if (i == ADD) {
					tp += B;
					s += "+" + to_string(B);
				}
				else {
					tp -= B;
					s += "-" + to_string(B);
				}

				if (j == ADD) {
					tp += C;
					s += "+" + to_string(C);
				}
				else {
					tp -= C;
					s += "-" + to_string(C);
				}

				if (k == ADD) {
					tp += D;
					s += "+" + to_string(D);
				} else {
					tp -= D;
					s += "-" + to_string(D);
				}

				if (tp == 7) {
					find = true;
					s += "=7";
					cout << s << endl;
				}

				if (find) break;
			}
			if (find) break;
		}
		if (find) break;
	}

	return 0;
}

Measured memory_bytes: 3660
using System;

class P
{
    static void Main()
    {
        int q = int.Parse(Console.ReadLine());
        for(int i = 0;i < q;i++)
        {
            var x = Console.ReadLine();
            var y = Console.ReadLine();
            Console.WriteLine(lcs(x,y));
        }
    }
        
        static int lcs(string x,string y)
        {
            int[,] c = new int[1001,1001];
            int m = x.Length;
            int n = y.Length;
            x= " "+x;
            y= " "+y;
            
            for(int i = 1; i<=m; i++)
            {
                for(int j =1 ; j<=n; j++)
                {
                   c[i,j] = x[i]==y[j] ? c[i-1,j-1] + 1
                   : Math.Max(c[i-1,j],c[i,j-1]);
                }
            }
            return c[m,n];
        }
}

Measured memory_bytes: 18452
#include<iostream>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    while(H!=0 && W!=0){
        for(int j=0;j<H;j++){
            if(j%2!=0){
                for(int i=0;i<W;i++){
                    if(i%2!=0){
                    cout<<"#";
                    }else cout <<".";
                }
            }else 
                for(int i=0;i<W;i++){
                    if(i%2!=0){
                    cout<<".";
                    }else cout <<"#";
                }
            cout << endl;
        }cout <<endl;
    cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3096
while True:
    n=int(input())
    if n>0:
        l=list()
        for i in range(n):
            s=int(input())
        
            l.append(s)
        l.remove(max(l))
        l.remove(min(l))
        x=sum(l)
        y=len(l)
        print(int(x/y))
    if n==0:
        break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

/*（๑•﹏•๑｀) */
int main() {
    int H,W,N,sr,sc;
    cin >> H >> W >> N;
    cin >> sr >> sc;
    string S,T;
    cin >> S;
    cin >> T;

    int L = 1;
    int R = W;
    int U = 1;
    int D = H;

    bool udrop = false;
    bool ldrop = false;
    REPr(i,N){
        if (T[i] == 'L'){
            R = min(R+1,W);
        }else if (T[i] == 'R'){
            L = max(L-1,1);
        }else if (T[i] == 'U'){
            D = min(D+1,H);
        }else if (T[i] == 'D'){
            U = max(U-1,1);
        }
        //////////////////////////////////
        if (S[i] == 'L'){
            L++;
        }else if (S[i] == 'R'){
            R--;
        }else if (S[i] == 'U'){
            U++;
        }else if (S[i] == 'D'){
            D--;
        }

        if ((R < L) || (D < U)){
            cout << "NO" << endl;
            return 0;
        }
    }

    if (((L <= sc) && (sc <= R)) and ((U <= sr) && (sr <= D))){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 776
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
 
 int main(){
     ll N,K;cin>>N>>K;
     ll A[N];
     REP(i,N) cin>>A[i];
     vector<ll> cnt(40,0);//下からからi桁に1が何個有るか
     REP(j,40){
         REP(i,N)
         if(A[i]>>j & 1){
             cnt[j]++;
         }
     }
    K++;
    ll ans = 0;
    REP(j,40){
        if(K>>j&1){
            //Kのj(0)桁目が1のとき
            //Kのj(0)桁目を0としたときを考えることができる
            ll tmp = 0;
            //jbit目が０，j-1までは最適,j+1からはKと同じものを候補として計算する
            REP(m,40){
                 if(m<j){
                    //最適
                    tmp += (1LL<<m)*max(cnt[m],N-cnt[m]);
                }else if(m>j){
                    tmp += (K>>m&1) ? (1LL<<m) * (N-cnt[m]) : (1LL<<m) * cnt[m];
                }else{
                    //jbit目
                    tmp += (1LL<<m) * cnt[m];
                }
            }
        if(ans<tmp) ans = tmp;
        }
    }
    cout<<ans<<endl;
    return 0;
 }

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};
namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

struct distcomp{
    P p;
    distcomp(P p):p(p){}
    bool operator()(const C &a, const C &b){
        return abs(p -a.p) +a.r < abs(p -b.p) +b.r;
    }
};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        VP sg(2);
        for(int d=0; d<2; d++){
            double x,y;
            cin >> x >> y;
            sg[d] = P(x, y);
        }
        vector<vector<C> > c(2);
        for(int i=0; i<n; i++){
            double x,y,r;
            cin >> x >> y >> r;
            P p(x, y);
            for(int d=0; d<2; d++){
                if(abs(sg[d] -p) +EPS < r && abs(sg[1-d] -p) > r +EPS){
                    c[d].push_back(C(p, r));
                }
            }
        }

        vector<vector<int> > num(2);
        for(int d=0; d<2; d++){
            int m = c[d].size();
            num[d] = vector<int>(m, 1);
            distcomp comp(sg[d]);
            sort(c[d].begin(), c[d].end(), comp);
            for(int i=0; i<m; i++){
                for(int j=0; j<i; j++){
                    if(abs(c[d][i].p -c[d][j].p) +c[d][j].r +EPS < c[d][i].r){
                        num[d][i] = max(num[d][i], num[d][j]+1);
                    }
                }
            }
            c[d].push_back(C(sg[d], 0));
            num[d].push_back(0);
        }

        int ans = 0;
        for(int i=0; i<(int)num[0].size(); i++){
            for(int j=0; j<(int)num[1].size(); j++){
                if(abs(c[0][i].p -c[1][j].p) > c[0][i].r +c[1][j].r +EPS){
                    ans = max(ans, num[0][i] +num[1][j]);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3256
N = int(input())
A_list = [int(i) for i in input().split(" ")]

flag=True
for num in A_list:
  if num % 2 == 0:
    if num % 6 != 0 and num % 10 != 0:
      flag=False
      break
if(flag):
  print("APPROVED")
else:
  print("DENIED")


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

#define pb push_back

using namespace std;

const int INF = 4e5;

int n, k, c;
string s;
vector<int> p1, p2, t;

void build(int v, int tl, int tr, vector<int> &res){
    if(tl == tr) t[v] = res[tl];
    else{
        int tm = (tl + tr)/2;
        build(v * 2, tl, tm, res);
        build(v * 2 + 1, tm + 1, tr, res);
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}
int qry(int v, int tl, int tr, int l, int r){
    if(l > r) return 0;
    if(tl == l && tr == r) return t[v];
    int tm = (tl + tr)/2;
    return max(qry(v * 2, tl, tm, l, min(r, tm)), qry(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k >> c >> s;
    int z = max(c, 1);
    p1.assign(n, 0);
    p2.assign(n, 0);
    for(int i = 0; i < n; ++i){
        if(s[i] != 'x'){
            if(i - c > 0) p1[i] = p1[i - c - 1] + 1;
            else p1[i] = 1;
        }
        if(i > 0) p1[i] = max(p1[i], p1[i - 1]);
    }
    // for(auto i : p1) cout << i << " ";
    // cout << "\n";
    for(int i = n - 1; i >= 0; --i){
        if(s[i] != 'x'){
            if(i + c < n) p2[i] = p2[i + c + 1] + 1;
            else p2[i] = 1;
        }
        if(i < n - 1) p2[i] = max(p2[i], p2[i + 1]);
    }
    // for(auto i : p2) cout << i << " ";
    // cout << "\n";
    vector<int> res;
    //res[i] is valid for [i - c + 1, to i]
    for(int i = 0; i < n + c; ++i){
        int l = 0 , r = 0;
        if(i >= z) l += p1[i - z];
        if(i < n - 1) r += p2[i + 1];
        res.pb(l + r);
    }
    // for(int i = 0; i < res.size(); ++i){
    //     cout << i - z + 1 + 1 << " " << i + 1 << ": " << res[i] << "\n";
    // }
    t.assign(4 * res.size() + 5, 0);
    build(1, 0, res.size() - 1, res);
    for(int i = 0; i < n; ++i){
        int cur = qry(1, 0, res.size() - 1, i, min(i + z - 1, (int) res.size() - 1));
        if(cur < k) cout << i + 1 << "\n";
    }
    // for(auto i : res) cout << i << " ";
    return 0;
}

Measured memory_bytes: 7308
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll n;
ll A[30];
ll q;
std::map<ll, bool> mp;

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

  rep( i, n )
    std::cin >> A[i];

  rep( i, 1<<n )
  {
    ll sum = 0;

    rep( j, n ) if( i>>j&1 )
      sum += A[j];

    mp[sum] = true;
  }

  std::cin >> q;

  rep( Q, q )
  {
    ll m;
    std::cin >> m;

    puts( mp.count(m) ? "yes" : "no" );
  }

  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;

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

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  REP(i, m) {
    ll x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.unite(x, y);
  }
  set<ll> st;
  REP(i, n) { st.insert(uf.find(i)); }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N;
	cin >> N;
	VVC S(N, VC(N));
	REP(i, N) REP(j, N) cin >> S[i][j];

	ll ans = 0;
	VVC prev = S;
	REP(mvCnt, N) {
		bool ok = true;
		VVC next(N, VC(N));
		REP(i, N) {
			REP(j, N) {
				next[i][(j + 1) % N] = prev[i][j];
			}
		}

		REP(i, N) {
			REP(j, N) {
				if (next[i][j] != next[j][i]) {
					ok = false;
					goto EXIT;
				}
			}
		}
EXIT:
		if (ok) ans++;
		swap(prev, next);
	}

	cout << ans * N << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> d(n+1, vector<ll>(n+1));
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            ll a;
            cin >> a;
            d[i][j] = a;
            ans += a;
        }
    }
    vector<vector<ll>> rec(n+1, vector<ll>(n+1));
    ll del = 0;
    for(int k = 1; k <= n; k++)
    {
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                if(d[i][j] > d[i][k] + d[k][j])
                {
                    cout << -1 << endl;
                    return 0;
                }
                else if(d[i][j] == d[i][k] + d[k][j] && i!=k && k!=j && rec[i][j] == false) 
                {
                    del += d[i][j];
                    rec[i][j] = true;
                }
            }
        }
    }
    cout << (ans - del) / 2 << endl;
}



Measured memory_bytes: 1664