akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int n; cin>>n;
    vi v(n);
    for(int i = 0; i < n; i++) cin>>v[i];
    sort(all(v));
    int sum = 0;
    for(int i = 0; i < n-1; i++) sum+=v[i];
    if(sum>v[n-1]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
ll seg[N*4];
void build(ll nod,ll l,ll r){
    seg[nod]=l;
    if (r-l==1) return ;
    ll mid=(r+l)/2;
    build(nod*2,l,mid);
    build(nod*2+1,mid,r);
    return ;
}
void upd(ll nod,ll l,ll r,ll id){
    if (r-l==1){
        seg[nod]=N+10;
        return ;
    }
    ll mid=(r+l)/2;
    if (mid>id) upd(nod*2,l,mid,id);
    else upd(nod*2+1,mid,r,id);
    seg[nod]=min(seg[nod*2],seg[nod*2+1]);
}
ll get(ll nod,ll l,ll r,ll L,ll R){
    if (l>=R || L>=r) return N+100;
    if (l>=L && r<=R) return seg[nod];
    ll mid=(r+l)/2;
    return min(get(nod*2,l,mid,L,R),get(nod*2+1,mid,r,L,R));
}
int32_t main(){
    ll n,m;
    cin >> n >> m;
    vector <pii> a;
    for (int i=1;i<=n;i++){
        ll l,r;
        cin >> l >> r;
        a.pb({l,r});
    }
    sort(a.begin(),a.end());
    ll ans=0;
    vector <int> c;
    build(1,1,m+1);
    for (int i=0;i<a.size();i++){
        ll l=a[i].F,r=a[i].S;
        ll z=get(1,1,m+1,r,m+1);
      //  cout << l << " " << r << " " << z << endl;
        if (z>m){
            c.pb(l);
          //  cout << l << endl;
        }
        else{
            ans++;
            upd(1,1,m+1,z);
        }
    }
    ll z=ans;
    sort(c.begin(),c.end());
    ll cnt=1;
    for (int i=0;i<c.size();i++){
        if (cnt>m-z) break;
        if (c[i]>=cnt){
            ans++;
            cnt++;
        }
    }
    cout << n-ans;
}


Measured memory_bytes: 13976
N=int(input())
A=[]
A=list(map(int,input().split()))
A.sort(reverse=True)
L=10**18
S=1
if A[N-1]==0:
    print("0")
else:
    for i in range(N):
        S=S*A[i]
        if S>L:
            print("-1")
            break
    if S<=L:
        print(S)


Measured memory_bytes: 21592
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[0 for i in range(5)] for j in range(L+1)]

def cost(s, a):
    if s == 0 or s == 4:
        return a
    elif s == 1 or s == 3:
        if a > 0:
            return a%2
        else:
            return 2
    else:
        return (a+1)%2

for i in range(L):
    a = A[i]
    DP[i+1][0] = min(DP[i][:1]) + cost(0, a)
    DP[i+1][1] = min(DP[i][:2]) + cost(1, a)
    DP[i+1][2] = min(DP[i][:3]) + cost(2, a)
    DP[i+1][3] = min(DP[i][:4]) + cost(3, a)
    DP[i+1][4] = min(DP[i][:5]) + cost(4, a)



print(min(DP[L]))

Measured memory_bytes: 74104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll maax(ll a,ll b){
    if(a>b)return a;
    else return b;
}
int main(void){
    ll prime=1000000007;
    int h,w;cin>>h>>w;
    vector<string>Grid(h);rep(i,h)cin>>Grid.at(i);
    vector<vector<ll>>dp(h,vector<ll>(w,0));
    rep(i,w){
        if(Grid.at(0).at(i)=='#')break;
        dp.at(0).at(i)=1;
    }
    rep(i,h){
        if(Grid.at(i).at(0)=='#')break;
        dp.at(i).at(0)=1;
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(Grid.at(i).at(j)=='.')dp.at(i).at(j)=(dp.at(i-1).at(j)+dp.at(i).at(j-1))%prime;
        }
    }
    cout<<dp.at(h-1).at(w-1)<<endl;
}

Measured memory_bytes: 9216
n, w = map(int, input().split())
weights, values = zip(*[tuple(map(int, input().split()))for _ in range(n)])
dp = [0]*(w+1)
for i in range(1, n+1):
    for j in reversed(range(1, w+1)):
        if j-weights[i-1] < 0:
            continue
        dp[j] = max(dp[j], dp[j-weights[i-1]]+values[i-1])
print(dp[-1])

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

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

	int n, q;
	while(cin >> n >> q, n) {
		int cnt[10010] = { 0 };
		for(int i = 0; i < n; i++) {
			int m, d;
			cin >> m;
			while(m--) {
				cin >> d;
				cnt[d]++;
			}
		}
		int ansd = 0, ansc = -1;
		for(int i = 1; i <= 10000; i++) {
			if(cnt[i] >= q && cnt[i] > ansc) {
				ansd = i;
				ansc = cnt[i];
			}
		}
		cout << ansd << endl;
	}
}

Measured memory_bytes: 3240
def E(n):
  return n*(1+n)/2/n

n, k = map(int, input().split())
l = list(map(int, input().split()))
ex = []
exsum = [0] *300000

tmpmax = 0
for i in range(n):
  ex.append(E(l[i]))

for i in range(n-k+1):
  if i == 0:
    for j in range(k):
      tmpmax += ex[i+j]
      exsum[i] = tmpmax
  else:
    exsum[i] = exsum[i-1] - ex[i-1] + ex[i+k-1]
  
a = exsum.index(max(exsum))

print(exsum[a])



Measured memory_bytes: 85000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>S>>T;
    S.append(T);
    N = atoi(S.c_str());
    bool yes = false;
    rep(i,500) if(i*i == N) yes = true;
    cout<<(yes ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  String b = sc.next();
   if(b.equals("A")){
   System.out.print("T");
   }else if(b.equals("T")){
   System.out.print("A");
   }else if(b.equals("C")){
   System.out.print("G");
   }else if(b.equals("G")){
   System.out.print("C");
   }else{
     System.out.print("Input Error");
   }
 }
}

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

from collections import deque

def bfs(s):
    seen = [0]*N
    d = [0]*N
    prev = [0]*N
    todo = deque()
    seen[s]=1
    todo.append(s)
    while len(todo):
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + 1
          prev[b] = a
    return d, prev

d, prev = bfs(0)
order = list(zip(*sorted(enumerate(d), key=lambda x:x[1])))[0]

dp = [1]*N
for v in order[::-1]:
    if len(G[v])==0:
        dp[v] = 1
    dp[prev[v]] += dp[v]
    
sizes=[0]*N
for i in range(N):
  if i == 0:
    tmp = max([dp[v] for v in G[i]])
    sizes[i]=tmp
    continue
  tmp = max(dp[i]-1,N-dp[i])
  sizes[i]=tmp
  
MIN=10**20
argmin=-1
for i in range(N):
  if sizes[i]<MIN:
    MIN=sizes[i]
    argmin=i
    
c = sorted(c,reverse=True)
score=[0]*N
score[argmin]=c[0]

def bfs2(s):
    i = 1
    seen = [0]*N
    todo = deque()
    seen[s]=1
    todo.append(s)
    while len(todo):
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          score[b] = c[i]
          i += 1
    return 
  
bfs2(argmin)

ans=0
for i in range(N):
  for j in G[i]:
    if i>j:continue
    ans += min(score[i],score[j])
    
print(ans)
print(*score)

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

void input_txt(char (*a)[51],int n){
	rep(i,n){
		rep(j,n)cin >> a[i][j];
	}
}

bool turn(int n,int m,char (*a)[51],char (*b)[51]){
	bool exist = false;
	rep(i,n){
		rep(j,n){
				bool match = true;
				if(i+m-1>n or j+m-1>n) continue;//超えたら止まる
				for(int y=0;y<m;y++){
					for(int x=0;x<m;x++){
						if(a[i+y][j+x]!=b[y][x]) match=false;
					}
				}
				if(match) exist=true;
		}
	}
	return exist;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//入力
	int m,n;
	char a[51][51],b[51][51];
	cin >> n >> m;
	input_txt(a,n);
	input_txt(b,m);

	cout << ((turn(n,m,a,b)) ? "Yes":"No") <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, a, b;
  cin >> n >> a >> b;
  ll diff = abs(a-b);
  if (a>b) { swap(a,b); }
  // Here, a<=b

  if (diff%2 == 1) {
    // Here, we battle in 1 or n
    // ll ans1 = max(abs(1-a),abs(1-b));
    // ll ans2 = max(abs(n-a),abs(n-b));

    // Here, we battle in middle
    ll ans3 = 0, ans4 = 0;
    {
      // go 1.
      ll _a = a, _b = b;
      ans3 += _a-1;
      _a -= ans3;
      _b -= ans3;
      assert(_a == 1);

      --_b;
      ++ans3;
      // Here, parity is same
      ans3 += (_b-1)/2;
    }
    {
      // go n.
      ll _a = a, _b = b;
      ans4 += n-_b;
      _a += ans4;
      _b += ans4;
      assert(_b == n);

      ++_a;
      ++ans4;
      // Here, parity is same
      ans4 += (n-_a)/2;
    }

    // cout << min(min(ans1, ans2),min(ans3,ans4)) << endl;
    cout << min(ans3,ans4) << endl;
  } else {
    cout << diff/2 << endl;
  }
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		String ans = "Yay!";
		if(e-a > k) {
			ans = ":(";
		}
		//for(int i = 0; i < n; i++) {
			
		//}
		System.out.println(ans);
		sc.close();
	}
	
}



Measured memory_bytes: 22996
n = int(input())
count = {}

for i in range(n):
    s = input()
    if s not in count:
        count[s] = 1
    else:
        count[s] += 1

maximum = 0
for v in count.values():
    maximum = max(v, maximum)

ans = []

for k, v in count.items():
    if v == maximum:
        ans.append(k)

ans.sort()
for s in ans:
    print(s)


Measured memory_bytes: 32096
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
int n,m,k,t;
string s;
int v[maxn];
int main()
{
	cin>>n>>k;
	FOR(i,1,k)
	{
		int d,x;cin>>d;
		FOR(i,1,d) v[x=read()]++;
	}
	int sum=0;
	FOR(i,1,n) if(v[i]==0) sum++;
	cout<<sum<<endl;
}

Measured memory_bytes: 3632
n = int(input())
v = list(map(int, input().split()))

from collections import defaultdict

d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(0, n, 2):
    d_even[v[i]] += 1
    d_odd[v[i+1]] += 1

d_even = sorted(d_even.items(), key=lambda x: x[1], reverse=True)
d_odd = sorted(d_odd.items(), key=lambda x: x[1], reverse=True)

if d_even[0][0] == d_odd[0][0]:
    d_even.append((0, 0))
    d_odd.append((0, 0))
    tmp = max(d_even[0][1] + d_odd[1][1], d_even[1][1] + d_odd[0][1])
    ans = n - tmp
else:
    ans = n - d_even[0][1] - d_odd[0][1]

print(ans)


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

int p[222222];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> p[i];
    int m = 0, l = 0;
    for(int i = 0; i < n; i++) {
        l += p[i];
        if(i >= k)
            l -= p[i - k];
        m = max(m, l);
    }
    cout.precision(18);
    cout << (k + m) / 2. << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int di(int k)
{
	int re=0;
	while(k>0)
	{
		re+=k%10;
		k=k/10;
	}
	return re;
}
int main()
{
	int n,ans=1000000;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		ans=min(ans,di(i)+di(n-i));
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define P pair<int,int>
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[114514],b[114514];
string ss[114514];
signed main(){
	ic(n) 
	c((n+1)/2)
}	


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define is_out_of_grid(x, y) x < 0 || y < 0 || x >= h || y >= w
//#define int long long
using namespace std;

int h, w;
vector<string> a;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		a.push_back(s);
	}
	queue<pair<int, int>> q;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (a[i][j] == '#')q.push({ i,j });
		}
	}
	q.push({ -1,-1 });
	int ans = 0;
	bool flag = true;
	while (true) {
		pair<int, int> p = q.front();
		q.pop();
		if (p.first == -1) {
			if (flag)break;
			flag = true;
			++ans;
			q.push({ -1,-1 });
		}
		else {
			for (int i = 0; i < 4; ++i) {
				int x = p.first + dx[i];
				int y = p.second + dy[i];
				if (is_out_of_grid(x, y))continue;
				if (a[x][y] == '.') {
					a[x][y] = '#';
					q.push({ x,y });
					flag = false;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9488
Uses math;
var i,count1,count2:integer;
    S:string; //count1:010101.._count2:101010
begin
read(S);i:=1;
while ord(S[i]) > 40 do
 begin
  if i mod 2 = 1 then begin
   if S[i]='0' then inc(count1) else inc(count2) end  
  else begin if S[i]='1' then inc(count1) else inc(count2) end;
  inc(i);
end;
write(min(count1,count2))
end.

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::map<std::string, int> m;
  rep(i,n) {
    std::string s; std::cin >> s;
    m[s]++;
  }
  std::cout << "AC x " << m["AC"] << std::endl;
  std::cout << "WA x " << m["WA"] << std::endl;
  std::cout << "TLE x " << m["TLE"] << std::endl;
  std::cout << "RE x " << m["RE"] << std::endl;
  return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "NO" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  998244353
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll dp[2020][2020];
ll L[2][2020][2020];
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<char> c(N*2);
    vector<ll> a(N*2);
    rep(i,N*2) cin>>c[i]>>a[i];
    ll pos[2][2020];
    rep(i,N*2) pos[c[i]=='W'][a[i]-1]=i;

    rep(i,2){
        rep(x,N){
            reps(y,x+1,N) if(pos[i][y]<pos[i][x]) ++L[i][x][N];
            repr(y,N-1,0) L[i][x][y]=L[i][x][y+1]+(pos[i^1][y]<pos[i][x]);
        }
    }

    rep(i,N+1) rep(j,N+1) dp[i][j]=INF2;
    dp[0][0]=0;
    rep(i,N+1){
        rep(j,N+1){
            if(j<N) mini(dp[i][j+1],dp[i][j]+L[1][j][i]);
            if(i<N) mini(dp[i+1][j],dp[i][j]+L[0][i][j]);
        }
    }

    cout<< dp[N][N] <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 95616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy
 
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
class Matrix():
    def __init__(self, A):
        self.A = A
        self.row = len(A)
        self.col = len(A[0])
 
    def __iter__(self):
        return self.A.__iter__()
 
    def __getitem__(self, i):
        return self.A.__getitem__(i)
 
    def __add__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] + bb[i][j] for j in range(self.col)] for i in range(self.row)])
 
    def __sub__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] - bb[i][j] for j in range(self.col)] for i in range(self.row)])
 
    def __mul__(self, B):
        aa = self.A
        bb = B.A
        a = []
        for i in range(self.row):
            ai = aa[i]
            r = []
            for j in range(B.col):
                r.append(sum([ai[k] * bb[k][j] for k in range(self.col)]))
            a.append(r)
        return Matrix(a)
 
    def __truediv__(self, x):
        pass
 
    def lu(self):
        size = self.row
        T = copy.deepcopy(self.A)
        L = [[0]*size for _ in range(size)]
        U = [[0]*size for _ in range(size)]
        for i in range(size):
            for j in range(i,size):
                L[j][i] = T[j][i]
            for j in range(i,size):
                U[i][j] = T[i][j] / T[i][i]
            for j in range(i+1,size):
                for k in range(i+1,size):
                    T[j][k] -= L[j][i] * U[i][k]
 
        return Matrix(L),Matrix(U)
 
    def __str__(self):
        return self.A.__str__()
 
def solve_se(A, b):
    n = A.row
    L,U = A.lu()
    y = []
    for i in range(n):
        t = b[i]
        for k in range(i):
            t -= L[i][k] * y[k]
        y.append(t / L[i][i])
 
    x = [0] * n
    for i in range(n-1,-1,-1):
        t = y[i]
        for k in range(i+1,n):
            t -= U[i][k] * x[k]
        x[i] = t
    return x
 
 
def main():
    sa = [s for s in sys.stdin.read().split('\n') if s]
    r = []
    for s in sa:
        a,b,c,d,e,f = [int(c) for c in s.split()]
        A = Matrix([[a,b],[d,e]])
        B = [c,f]
        x = solve_se(A,B)
        r.append(' '.join(map(lambda t: '{:01.3f}'.format(1.0*t), x)))
 
    return '\n'.join(r)
 
print(main())


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

int main() {

  int H, W;
  cin >> H >> W;
  vector<vector<int>> data(H, vector<int>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }

  int count = 0;

  for (int i = 0; i < H-1; i++) {
    for (int j = i+1; j < H; j++) {
      int dis = 0;
      for (int k = 0; k < W; k++) {
          int m = data.at(i).at(k)-data.at(j).at(k);
          dis += m*m;
      }
      for (int l = 0; l < 160; l++)
          if(dis==l*l) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int dp[2][410][410];
signed main(){
	int a,b,c,ans=INF;
	cin>>a>>b>>c;
	f(i,410){
		f(j,410){
			dp[0][i][j]=INF;
			dp[1][i][j]=INF;
		}
	}
	dp[0][0][0]=0;
	dp[1][0][0]=0;
	f(i,a){
		int x,y,z;
		cin>>x>>y>>z;
		f(j,410){
			f(k,410){
				if(j>=x&&k>=y)dp[(i+1)%2][j][k]=min(dp[i%2][j][k],dp[i%2][j-x][k-y]+z);
				else dp[(i+1)%2][j][k]=dp[i%2][j][k];
			}
		}
	}
	for(int i=1;i*max(b,c)<410;i++){
		ans=min(ans,dp[a%2][i*b][i*c]);
	}
	if(ans==INF) puts("-1");
	else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, M; cin >> N >> M;
    if(2*N >= M){cout << M/2;}
    else{
    ll p = M/2 - N - 50;
        while(2*p < M - 2*N){
            p++;
        }
        cout << (M-p)/2;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int maxn[500005][20][2];
int a[500005];

void upDate(int& u,int &v,int x,int y){
    int b[5];
    b[0] = u, b[1] = v, b[2] = x, b[3] = y;
    std::sort(b,b+4);
    u = b[3], v = b[2];
}

int max(int a,int b){ return a>b?a:b; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < (1<<n); i++) scanf("%d",&a[i]);
    for(int i = 0; i < (1<<n); i++){
        maxn[i][0][0] = a[i], maxn[i][0][1] = 0;
        for(int j = 1; j <= n; j++){
            maxn[i][j][0] = maxn[i][j-1][0], maxn[i][j][1] = maxn[i][j-1][1];
            if(i&(1<<(j-1))){
                int last = i^(1<<(j-1));
                upDate(maxn[i][j][0],maxn[i][j][1],maxn[last][j-1][0],maxn[last][j-1][1]);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i < (1<<n); i++){ 
        ans = max(ans,maxn[i][n][0]+maxn[i][n][1]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 45284
def main():
    N, M = map(int, input().split())

    def judge(r, c):
        if r >= N or c >= M:
            return 0

        if ~memo[r][c]:
            return 0

        ux = (r == 0)  # 上がない
        bx = (r == N - 1)  # 下がない
        lx = (c == 0)  # 左がない
        rx = (c == M - 1)  # 右がない

        ret = 9  # マスと周囲がすべて存在するときの反転回数
        ret -= (ux + bx + lx + rx) * 3 - (ux & lx) - (ux & rx) - (bx & lx) - (bx & rx)
        return ret & 1  # 奇数回反転->裏向き

    memo = [[-1] * 2 for _ in range(2)]
    # gridの左上の2x2マスの反転判定

    for r in range(2):
        for c in range(2):
            memo[r][c] = judge(r=r, c=c)

    ans = memo[0][0] + memo[1][0] * (N - 2) + memo[0][1] * (M - 2) + memo[1][1] * (N - 2) * (M - 2)

    # print(*memo, sep='\n')
    print(ans)


if __name__ == '__main__':
    main()

# (0,0)
# (1...N-2,0)
# (N-1,0)

# (0,1...M-2)
# (1...N-2,1...M-2)
# (N-1,1...M-2)

# (0,M-1)
# (1...N-2,M-1)
# (N-1,M-1)


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

int main(){
int A, B;
  cin >> A >> B;
  if((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0)) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

}

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

int main() {
	string s;
  	cin >> s;
  	int t = 0;
  	for(int i = 0; i < s.size(); i++) t += s[i] - '0';
   	if(t % 9) cout << "No";
  	else cout << "Yes";
}

Measured memory_bytes: 3752
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sc second
#define st first
#define pii pair<int, int>
#define arr array
#define task "A"
#define task_check "A"

const int maxn = 5e5 + 5;
const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;

using namespace std;

/// Count : 1

int n, m;
ll a[maxn];

int main()
{
    /*if(fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }*/
    ll n, x, t;
    cin >> n >> x >> t;
    cout << (n/x + (n%x!=0))*t;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int n, x;
int main() {
	scanf("%d", &n);
	int ret = -2099999999, p = 2099999999;
	for(int i = 0; i < n; i++) {
		scanf("%d", &x);
		ret = max(ret, x - p);
		p = min(p, x);
	}
	printf("%d\n", ret);
	return 0;
}

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

using namespace std;

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

    int h, n, sum = 0;
    cin >> h >> n;

    while (n--) {
        int x;
        cin >> x;
        sum += x;
    }

    cout << (sum < h ? "No\n" : "Yes\n");

    return 0;
}

Measured memory_bytes: 384
n = int(input())

# i = format(n, 'b')[::-1].find('1')
ans = 0
k = 1
while True:
  n //=2
  ans += k
  k *= 2
  if n == 1:
    print(ans+k)
    break
  elif n < 1:
    print(ans)
    break 

Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	sum := make([]int, N)
	for i := 0; i < N; i++ {
		w := sc.NextInt()
		sum[i] = w
		if i > 0 {
			sum[i] += sum[i-1]
		}
	}
	ans := 100000000
	for i := 1; i < N-1; i++ {
		ans = min(ans, abs(sum[N-1]-sum[i]-sum[i]))
	}
	fmt.Println(ans)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func min64(x, y float64) float64 {
	if x < y {
		return x
	}
	return y
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 3e6 + 10;
const int MOD = 1000000007;

int fat[MAX];

int normalize(int x)
{
	x = x % MOD;
	if(x < 0) x += MOD;
	return x;
}

int add(int x, int y)
{
	return normalize(normalize(x) + normalize(y));
}

int mul(int x, int y)
{
	return normalize(normalize(x) * normalize(y));
}

int sub(int x, int y)
{
	return normalize(normalize(x) - normalize(y));
}

int expMod(int a, int e)
{
	int ans = 1;
	while(e)
	{
		if(e & 1) ans = mul(ans, a), e--;
		else a = mul(a, a), e /= 2;
	}
	return ans;
}

int inv(int x)
{
	return expMod(x, MOD - 2);
}

int nCk(int n, int k)
{
	return mul( fat[n] , mul( inv(fat[k]) , inv(fat[n - k]) ));
}

int32_t main()
{
	string s;
	int k;
	
	cin >> k >> s;
	
	int len_s = s.size();
	int len = len_s + k;
	
	fat[0] = 1;
	for(int i = 1; i <= len; i++)
		fat[i] = mul(fat[i - 1], i);
	
	int ans = 0;	
	for(int i = len_s; i <= len; i++)
		ans = add(ans, mul(mul(nCk(i - 1, len_s - 1), expMod(25, i - len_s)), expMod(26, len - i)));
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 20060
T = gets.to_i

def f(n)
  return $d if n == 1
  return $memo[n] if $memo[n]

  res = [n * $d]

  res << f(n / 2) + $a + (n % 2) * $d
  res << f(n / 2 + 1) + $a + $d if n % 2 != 0

  res << f(n / 3) + $b + (n % 3) * $d if n >= 3
  res << f(n / 3 + 1) + $b + (3 - n % 3) * $d if n % 3 != 0

  res << f(n / 5) + $c + (n % 5) * $d if n >= 5
  res << f(n / 5 + 1) + $c + (5 - n % 5) * $d if n % 5 != 0

  $memo[n] = res.min
end

T.times do
  n, $a, $b, $c, $d = gets.split.map(&:to_i)

  $memo = Hash.new
  puts f(n)
end


Measured memory_bytes: 16944
using System;
using System.Collections.Generic;

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] ps = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for(int i = 0; i < n; i++){
                ps[i] = int.Parse(words[i]);
            }
        }

        int answer = 0;
        for(int i = 1; i < n - 1; i++)
        {
            int a = ps[i - 1];
            int b = ps[i];
            int c = ps[i + 1];
            if((a < b && b < c)|| (a > b && b > c))
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    vector<ll> vec(n);
    REP(i, n) cin >> vec.at(i);
    vector<ll> sorted(vec.begin(), vec.end());
    sort(ALL(sorted));
    ll max = sorted.at(sorted.size()-1);
    ll second = sorted.at(sorted.size()-2);
    for (auto elem : vec) {
        if (elem == max) {
            cout << second << endl;
        } else {
            cout << max << endl;
        }
    }
    return 0;

}

Measured memory_bytes: 4736
import sys

N_MAX = 200000 + 5
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7

# ## COMBINATION (MOD) ## #

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD


def main():
    n, k = map(int, sys.stdin.readline().rstrip().split())

    k = min(n, k)

    ans = 0
    for m in range(k+1):
        empty = cmb(n, m)
        member = cmb(n - 1, n - m - 1)
        ans += (empty * member) % MOD
        ans %= MOD

    print(ans)


main()


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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;

  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - (i + j) >= 0 && S - (i + j) <= K) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}

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

bool solve(int *ans,int tmp,int n,int &total){
  static int coin[6]={500,100,50,10,5,1};

  for(int i=0;i<6;i++){
    tmp+=n/coin[i];
    n%=coin[i];
  }

  if (tmp < total){
    total=tmp;
    return true;
  }
  return false;
}


main(){
  int a,b,c,d;
  int n;
  int val[4]={10,50,100,500};
  int tc=0;
  while(cin>>n && n){
    if (tc)cout << endl;
    tc++;
    cin>>a>>b>>c>>d;
    int ans[4];
    int total = 1000000;

    rep(i,a+1){
      rep(j,b+1){
	rep(k,c+1){
	  rep(l,d+1){
	    int pay=i*val[0]+j*val[1]+k*val[2]+l*val[3];
	    if (pay >= n){
	      if (solve(ans,a-i+b-j+c-k+d-l,pay-n,total)){
		ans[0]=i;
		ans[1]=j;
		ans[2]=k;
		ans[3]=l;
	      }
	    }
	  }
	}
      }
    }

    rep(i,4){
      if (ans[i] != 0)
	cout <<val[i]<<" "<<ans[i]<<endl;
    }
  }
  return false;
}

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

int main() {
    int N, T, A, H;
    cin >> N >> T >> A;
    int diff=0, cc=1<<30;
    int ans;
    for (int i = 0; i < N; ++i) {
        cin >> H;
        diff = A*1000 -  (T*1000 - H*6);
        if (diff < 0) diff = -diff;
        if (cc > diff) cc = diff, ans = i+1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,k,aa[110000],cnt=0;
pair<int,string> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>n>>k;
    if(n>=10){
        cout<<k;
    }else{
        cout<<k+(10-n)*100;
    }
}

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

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

bool    comp0(vector<long> &A, vector<long> &B) {
        if (A.at(1) != B.at(1)) return A.at(1)<B.at(1);
        return A.at(2)<B.at(2);
}

string  s6(int n) {
        string S=to_string(n);
        S = "00000"+S;
        return S.substr(S.size()-6);
}

int     main() {
        int N, M;
        cin >>N >>M;
        vector<int> P(M);
        vector<long> Y(M);
        for (int i=0; i<M; i++) {
                cin >> P.at(i) >> Y.at(i);
        }
        vector<vector<long> > C(0);
        for (int i=0; i<M; i++) {
                C.push_back({i, P.at(i), Y.at(i), 0});
        }
        sort(C.begin(), C.end(), comp0);
        int j=0;
        int pp=0;
        for (int i=0; i<M; i++) {
                if (pp==C.at(i).at(1)) {
                        j++;
                        C.at(i).at(3)=j;
                } else {
                        j=1;
                        C.at(i).at(3)=j;
                        pp=C.at(i).at(1);
                }
        }
        sort(C.begin(), C.end());
        for (int i=0; i<M; i++) {
                cout << s6(C.at(i).at(1)) << s6(C.at(i).at(3)) << endl;
        }
        return 0;
}

Measured memory_bytes: 10416
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int H = stdIn.nextInt();
		int W = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		String x = "";
		String y = "";
		for(int i = 0; i < A; i++) {
			x += "0";
		}
		for(int i = 0; i < W-A; i++) {
			x += "1";
		}
		for(int i = 0; i < A; i++) {
			y += "1";
		}
		for(int i = 0; i < W-A; i++) {
			y += "0";
		}
		
		for(int i = 0; i < B; i++) {
			System.out.println(x);
		}
		for(int i = 0; i < H-B; i++) {
			System.out.println(y);
		}

	}

}

Measured memory_bytes: 31956
#include <iostream>

using namespace std;

int main()
{
    int n, m;
    int A[100][100];
    int b[100];
    int c[100] = {0};
    
    cin >> n >> m;
    
       for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> A[i][j];
        }
    }
    
    for(int j = 0; j < m; j++)
    {
        cin >> b[j];
    }
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            c[i] += A[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
   return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str,str1;
  cin>>str;
  cin>>str1;
  int p=0;
  for(int i=0 ; i<str.size() ; i++)
  {
    if(str[i]==str1[i])
      p++;
  }
  cout<<p;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main()
{
  //入力
  int n;
  cin >> n;
  int flag = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0 ) {
      if (a % 3 != 0 && a % 5 != 0) {
        flag += 1;
      }
    }
  }
  if(flag > 0) {
    cout << "DENIED" << endl;
  } else {
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
long long int  d[100000];
int vis[1000000];
const ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	int n,i,ss,s,m;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
	cin>>s;
	vis[s]=1;
	}
	d[0]=1;
	if(!vis[1])
	d[1]=1;
	for(i=2;i<=n;i++)
	{
		if(vis[i])
		continue;
		d[i]=(d[i-1]+d[i-2])%mod;
	}
    printf("%lld\n",d[n]);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
struct edge{
  int from,to,cost;
  bool operator < (const edge &p)const{
    return cost < p.cost;
  }
};

#define MAX 205
int pa[MAX];
int ra[MAX];

int n,m;
map< int , vector<int> > t;

vector< edge > G[MAX];
bool flg[MAX];

void uf_init(){
  for(int i=0;i<MAX;i++){
    pa[i]=i;
    ra[i]=0;
  }
}

void init(){
  t.clear();
  for(int i=0;i<MAX;i++){
    flg[i]=false;
    G[i].clear();
  }
}

int find(int x){
  if(pa[x]==x)return x;
  else return pa[x]=find(pa[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}

bool same(int x,int y){
  return (find(x)==find(y));
}


int main(){
  while(1){
    scanf("%d %d",&n,&m);    
    if(n==0&&m==0)break;
    uf_init();
    init();
    int a,b,c;
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      t[-a].push_back(i+1);
    }
    for(int i=0;i<m;i++){
      scanf("%d %d %d",&a,&b,&c);
      G[a].push_back((edge){a,b,c});
      G[b].push_back((edge){b,a,c});
    }

    int ans=0;
    vector<edge> E;
    map< int , vector<int> > :: iterator it,it2;    

    for(it=t.begin();it!=t.end();it++){
      int size=it->second.size();
      for(int i=0;i<size;i++){
        int v=it->second[i];
        flg[v]=true;
      }
      for(int i=0;i<size;i++){
        int v=it->second[i];
        for(int j=0;j<(int)G[v].size();j++){
          edge e=G[v][j];
          if(flg[e.to])E.push_back(e);
        }    
      }
      sort(E.begin(),E.end());

      for(int i=0;i<(int)E.size();i++){
        edge e=E[i];
        if(same(e.from,e.to))continue;
        unite(e.from,e.to);
        ans+=e.cost;
      }
      
      int cnt=0;
      for(int i=1;i<=n;i++){
        if(!flg[i])continue;
        if(find(i)==i)cnt++;
      }
      if(cnt!=1){
        uf_init();
        ans=0;
        E.clear();
        for(int i=1;i<=n;i++){
          if(!flg[i])continue;
          for(int j=0;j<(int)G[i].size();j++){
            edge e=G[i][j];
            if(flg[e.to])E.push_back(e);
          }
        }
      }else{
        E.clear();
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
  int A;//1円の枚数
  int N;//支払額
  
  cin >> N >> A;
  
  if ( N % 500 <= A ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
  
  
  
}

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

using namespace std;

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

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

    bool ok = false;
    rep(i, s.size()-1){
        if(s[i] == 'A' && s[i+1] == 'C'){
            ok = true;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	string s;
	int k;
	cin >> k >> s;
	if(sz(s) <= k)
	{
		cout << s;
		return 0;
	}
	cout << s.substr(0,k);
	cout <<"...";
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

Measured memory_bytes: 26068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;


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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> b;

  if (n % 2 == 0) {
    for (int i = n-1; i >= 0; i-=2) b.push_back(a[i]);
    for (int i = 0; i < n; i+=2) b.push_back(a[i]);
  } else {
    for (int i = n-1; i >= 0; i-=2) b.push_back(a[i]);
    for (int i = 1; i < n; i+=2) b.push_back(a[i]);
  }

  for (auto& v : b) cout << v << " "; cout << endl;

  return 0;
}


Measured memory_bytes: 5488
package main

import "fmt"

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

	ans := "No"
	for x := 0; x <= 25; x++ {
		for y := 0; y <= 14; y++ {
			if 4*x+7*y == n {
				ans = "Yes"
				break
			}
		}
	}
	fmt.Println(ans)
}


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

class mint {
  int value;
  static vector<int> *_fact;
  static vector<int> *_finv;

public:
  static const int MOD = 1e9 + 7;
  mint(long long x)
      : value((x % MOD + MOD) % MOD) {}
  mint operator+(mint y) const {
    return mint(value + y.value);
  }
  mint &operator+=(mint a) {
    return *this = *this + a;
  }
  mint operator*(mint y) const {
    return mint(long(value) * y.value);
  }
  mint &operator*=(mint a) {
    return *this = *this * a;
  }
  mint operator-() const {
    return *this * mint(-1);
  }
  mint operator-(mint y) const {
    return *this + (-y);
  }
  mint &operator-=(mint a) {
    return *this = *this - a;
  }
  operator int() const {
    return value;
  }
  static mint pow(mint a, int n) {
    if (n <= 0) {
      return 1;
    }
    mint half = mint::pow(a, n / 2);
    return n % 2 ? half * half * a : half * half;
  }
  mint inv() {
    return pow(value, MOD - 2);
  }
  static void init(int n) {
    _fact = new vector<int>(n + 1);
    _finv = new vector<int>(n + 1);
    (*_fact)[0] = (*_finv)[0] = 1;
    mint val = 1;
    for (int i = 1; i <= n; i++) {
      val *= i;
      (*_fact)[i] = val;
      (*_finv)[i] = val.inv();
    }
  }
  static mint fact(int n) {
    return (*_fact)[n];
  }
  static mint finv(int n) {
    return (*_finv)[n];
  }
  static mint comb(int n, int k) {
    return fact(n) * finv(k) * finv(n - k);
  }
};
vector<int> *mint::_fact;
vector<int> *mint::_finv;

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

  string S;
  cin >> S;

  int W = S.size();
  int L = W + K;

  mint::init(L);
  mint ans = 0;
  for (int i = W - 1; i < L; i++) {
    ans += mint::pow(25, i - (W - 1)) * mint::pow(26, L - 1 - i) * mint::comb(i, W - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 20064