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

typedef long long ll;
const int mod = 1e9 + 7, N = 1e5 + 10;
ll h, w, a, b;
ll fac[N << 1], inv[N << 1];

ll quick_pow(ll a, ll b) {
    ll res = 1;
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    } return res;
}

ll C(ll n, ll m) {
    return (fac[n] * inv[m] % mod) * inv[n - m] % mod;
}

int main() {
    cin >> h >> w >> a >> b;

    fac[0] = inv[0] = 1;
    for (int i = 1; i <= h + w; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = quick_pow(fac[i], mod - 2);
        // printf("%lld %lld\n", fac[i], inv[i]);
    }
    ll tot = C(h + w - 2, h - 1);
    ll minus = 0;
    for (int i = 1; i <= b; i++)
        minus = (minus + C(h - a + i - 2, i - 1) * C(w + a - 1 - i, a - 1) % mod) % mod;
    printf("%lld\n", ((tot - minus) % mod + mod) % mod);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a)%2==0)
		printf("%lld\n",(b-a)/2);
	else
	{
		long long h1=a,h2=b;
		long long ans1=n-b;
		h1+=ans1;
		ans1++;
		h1++;
		ans1+=((n-h1)/2);
		long long ans2=a-1;
		h2-=ans2;
		ans2++;
		h2--;
		ans2+=((h2-1)/2);
		printf("%lld\n",min(ans1,ans2));
	}
} 


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    edge = [[] * N for _ in range(N)]
    new_edge = [[] * N for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append(v)
        
    S, T = map(int, input().split())
    S -= 1
    T -= 1
    d = [[float('inf')] * 3 for _ in range(N)]
    q = deque([])
    q.append((S,0))
    d[S][0] = 0
    while q:
        v,l = q.popleft()
        nl = (l + 1) % 3
        for nv in edge[v]:
            if d[nv][nl] != float('inf'):
                continue
            q.append((nv,nl))
            d[nv][nl] = d[v][l] + 1
    if d[T][0] == float('inf'):
        print(-1)
    else:
        print(d[T][0] // 3)
            



if __name__ == "__main__":
    main()

Measured memory_bytes: 83120
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Graph{
    struct Edge{
        int cost, from, dest;
        Edge(int cost, int dest): cost(cost), from(-1), dest(dest){ }
        Edge(int cost, int from, int dest): cost(cost), from(from), dest(dest){ }
        ostream& operator >> (ostream& out){
            return out << '(' << cost << ':' << from << ' ' << dest << ')';
        }
    };
    struct Node{
        vector<Edge> edges;
        ll height = 0;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    void addEdge(int from, int dest, int cost = 1){
        nodes[from].edges.emplace_back(cost, dest);
    }
    void addEdge2(int from, int dest, int cost = 1){
        addEdge(from, dest, cost);
        addEdge(dest, from, cost);
    }
    void dfs(int idx, ll height, int from = -1){
        nodes[idx].height = height;
        for(auto e : nodes[idx].edges){
            if(e.dest == from){ continue; }
            dfs(e.dest, height + e.cost, idx);
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.addEdge2(a, b, c);
    }
    int q, k;
    cin >> q >> k;
    k--;
    g.dfs(k, 0);
    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << g.nodes[x].height + g.nodes[y].height << '\n';
    }
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;


int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
  int n;
  cin>>n;
  int a=n/1000;
  int b=(n/100)%10;
  int c=(n/10)%10;
  int d=n%10;
 
  if((a==b&&b==c)||(b==c&&c==d)){
    c("Yes");
  }else{
    c("No");
  }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, w, a[N], b[N];
long long dp[100][N+1];
int main() {
    scanf("%d%d", &n, &w);
    for(int i=0; i<n; ++i)
        scanf("%d%d", a+i, b+i);
    long long ans = dp[0][a[0]] = b[0];
    for(int i=1; i<n; ++i){
        for(int j=0; j<=w; ++j){
            if( j-a[i] >= 0 )
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i]] + b[i]);
            else
                dp[i][j] = dp[i-1][j];
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 77568
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double pi = Math.PI;
//int b = sc.nextInt();
double area = r*r*pi;
double length = 2*r*pi;
System.out.printf("%f %f", area, length);
}
}


Measured memory_bytes: 28124
#include <iostream>

using namespace std;

int n,w,d,p[101],s[101],hnum=0,buf;
typedef struct{
  int x;
  int y;
}Hako;
Hako hako[101],wake1,wake2;


int main(){
	
	
	
	cin>>n;
	cin>>w;
	cin>>d;
	
	while(n!=0 || w!=0 || d!=0){
		for(int lop=0;lop<101;lop++){
			p[lop]=0;
			s[lop]=0;
			hako[lop].x=0;
			hako[lop].y=0;
		}
		
		for(int lop=0;lop<n;lop++){
			cin>>p[lop];
			cin>>s[lop];
		}
		hnum=0;
		hako[0].x=w;
		hako[0].y=d;
		
		for(int lop=0;lop<n;lop++){
			s[lop]%=(hako[p[lop]-1].x+hako[p[lop]-1].y)*2;
			if(s[lop]-hako[p[lop]-1].x<0){
				wake1.x=s[lop];
				wake1.y=hako[p[lop]-1].y;
				wake2.x=hako[p[lop]-1].x-s[lop];
				wake2.y=hako[p[lop]-1].y;
			}else if(s[lop]-hako[p[lop]-1].x-hako[p[lop]-1].y<0){
				wake1.x=hako[p[lop]-1].x;
				wake1.y=s[lop]-hako[p[lop]-1].x;
				wake2.x=hako[p[lop]-1].x;
				wake2.y=hako[p[lop]-1].y-(s[lop]-hako[p[lop]-1].x);
			}else if(s[lop]-hako[p[lop]-1].x-hako[p[lop]-1].x-hako[p[lop]-1].y<0){
				wake1.x=s[lop]-hako[p[lop]-1].x-hako[p[lop]-1].y;
				wake1.y=hako[p[lop]-1].y;
				wake2.x=hako[p[lop]-1].x-(s[lop]-hako[p[lop]-1].x-hako[p[lop]-1].y);
				wake2.y=hako[p[lop]-1].y;
			}else{
				wake1.x=hako[p[lop]-1].x;
				wake1.y=s[lop]-(hako[p[lop]-1].x*2)-hako[p[lop]-1].y;
				wake2.x=hako[p[lop]-1].x;
				wake2.y=hako[p[lop]-1].y-(s[lop]-(hako[p[lop]-1].x*2)-hako[p[lop]-1].y);
			}
			//cout<<p[lop]-1<<"aaa"<<hnum<<endl;
			for(int lop2=p[lop]-1;lop2<hnum;lop2++){
				hako[lop2].x=hako[lop2+1].x;
				hako[lop2].y=hako[lop2+1].y;
			}
			if(wake1.x*wake1.y<wake2.x*wake2.y){
				hako[hnum].x=wake1.x;
				hako[hnum].y=wake1.y;
				hako[hnum+1].x=wake2.x;
				hako[hnum+1].y=wake2.y;
			}else{
				hako[hnum].x=wake2.x;
				hako[hnum].y=wake2.y;
				hako[hnum+1].x=wake1.x;
				hako[hnum+1].y=wake1.y;
			}
			hnum++;
			
			/*hako[p[lop]-1].x=wake1.x;
			hako[p[lop]-1].y=wake1.y;
			for(int lop2=0;lop2<hnum+1;lop2++){
				if(hako[lop2].x==0){
					hako[lop2].x=wake2.x;
					hako[lop2].y=wake2.y;
				}
			}*/
			
			
		}
		
		for(int lop=0;lop<hnum+1;lop++){
			for(int lop2=0;lop2<hnum;lop2++){
				if(hako[lop2].x*hako[lop2].y>hako[lop2+1].x*hako[lop2+1].y){
					
					buf=hako[lop2].x;
					hako[lop2].x=hako[lop2+1].x;
					hako[lop2+1].x=buf;
					
					buf=hako[lop2].y;
					hako[lop2].y=hako[lop2+1].y;
					hako[lop2+1].y=buf;
				}
			}
		}
		
		cout<<hako[0].x*hako[0].y;
		for(int lop2=1;lop2<hnum+1;lop2++){
			cout<<' '<<hako[lop2].x*hako[lop2].y;
		}
		cout<<endl;
		
		cin>>n;
		cin>>w;
		cin>>d;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3004
#include <iostream>
using namespace std;
#define INF 1000000000
#define rep(i,a) for(i=0;i<a;++i)
int i;
int main(){
  int N;
  cin >> N;
  int a[110];
  rep(i,N) cin >> a[i];
  int max = 1;
  int min = INF;
  rep(i,N){
    if(a[i] > max) max = a[i];
    if(a[i] < min) min = a[i];
  }
  cout << max-min << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(), m = scan.nextInt();
        int i, j;
        int[][] A = new int[n][m];
        int[] b = new int[m];
        for(i = 0; i < n; i++){
            for(j = 0; j < m; j++){
                A[i][j] = scan.nextInt();
            }
        }
        for(j = 0; j < m; j++) b[j] = scan.nextInt();

        int sum;
        
        for(i = 0; i < n; i++){
            sum = 0;
            for(j = 0; j < m; j++){ sum += A[i][j] * b[j]; }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 40368
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    K = int(input())
    S = input()
    n = len(S)
    if n<=K:
        print(S)
    else:
        print(S[:K]+'...')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61680
#include <stdio.h>

int main(void){
    int N,i,j,count;
    while(scanf("%d",&N),N){
        j=1;
        count=0;
        for(i=2;j<=N;i++){
            j+=i;
            if((N-j)%i==0&&N-j>=0){
                count++;
                //printf("i:%d\n",i);
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int max_number = 0;
    int second = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] > max_number) {
            second = max_number;
            max_number = A[i];
        } else if (A[i] == max_number) {
            second = max_number;
        } else {
            second = max(second, A[i]);
        }
    }
    for (int i = 0; i < N; ++i) {
        if (A[i] == max_number) {
            cout << second;
        } else {
            cout << max_number;
        }
        cout << endl;
    }
    return 0;
}


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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    int cnt = 1;
    for (int i = 0; i < N - 1; i++) {
        if (vec.at(i) < vec.at(i + 1)) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int d,n,i,j,k,ret=0;
    int **x;
    double l1,l2;
    scanf("%d%d",&n,&d);

    x=(int**)malloc(n*sizeof(int*));
    for(i=0;i<n;i++)
    {
        x[i]=(int*)malloc(d*sizeof(int));
    }
    
    for(i=0; i<n; i++)
    {
        for(j=0;j<d;j++)
        {
            scanf("%d",&x[i][j]);
        }
    }

    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(l1=0,k=0;k<d;k++)
            {
                l1+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            l1=sqrt(l1);
            l2=(int)l1;
            if(l1==l2) ret++;
        }
    }

    printf("%d\n",ret);

    for(i=0;i<n;i++)
    {
        free(x[i]);
    }
    free(x);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int n = 0;
		int r = 0;
		int anser =0;

		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();
		r = scan.nextInt();

		if(n>=10) {
			anser = r;
		}else {
			anser = r + 100 * (10-n);
		}

		System.out.println(anser);
	}

}


Measured memory_bytes: 22612
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))+[0]
ans=c=0
for i in range(N+1):
    a=A[i]
    b=B[i]
    ans+=min(a,c)
    a=max(a-c,0)
    ans+=min(a,b)
    if a<b :c=b-a
    else :c=0
print(ans)

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void dfs(int a, vector<bool>& vis, const vector<vector<int>>& adj, int& sz) {
        vis[a] = 1;
        sz++;
        for (auto b: adj[a]) {
                if (!vis[b]) dfs(b, vis, adj,sz );
        }
}


void _main() {
        int n, m; cin >> n >> m;
        vector<vector<int>> adj(n + 1);
        while (m--) {
                int a, b; cin >> a >> b;
                adj[a].emplace_back(b);
                adj[b].emplace_back(a);
        }

        vector<bool> vis(n + 1);
        int ans = 1;
        for (int i = 1; i <= n; i++) {
                if (vis[i]) continue;
                int cnt = 0;
                dfs(i, vis, adj, cnt);
                ans = max(ans, cnt);
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 26604
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

count = Counter(A)
sm = {}
sm2 = {}
for key, value in count.items():
    sm[key] = value*(value-1)//2
    sm2[key] = (value-1)*(value-2)//2
total = sum(sm.values())

for num in A:
    print(total - sm[num] + sm2[num])


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

struct Tuple {
    double d;
    int h, w;

    Tuple(double d = 0.0, int h = 0, int w = 0) : d(d), h(h), w(w) {}

    bool operator < (const Tuple &t) const {
        if (d == t.d) {
            if (h == t.h) {
                return w < t.w;
            }
            else {
                return h < t.h;
            }
        }
        else {
            return d < t.d;
        }
    }

    bool operator == (const Tuple &t) const {
        return (d == t.d && h == t.h && w == t.w);
    }
};

int h, w, size_;
double d;
vector<Tuple> t;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int hh = 1; hh <= 150; ++hh) {
        for (int ww = hh + 1; ww <= 150; ++ww) {
            t.push_back({sqrt(hh * hh + ww * ww), hh, ww});
        }
    }

    sort(t.begin(), t.end());
    size_ = t.size();

    while (cin >> h >> w, h | w) {
        d = sqrt(h * h + w * w);

        for (int i = 0; i < size_; ++i) {
            if (Tuple(d, h, w) == t[i]) {
                cout << t[i+1].h << " " << t[i+1].w << endl;
                break;
            }
        }
    }

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

template<typename T, typename U>
struct segtree {
	ll n, H;
	
	vector<T> value;
	vector<U> prop;
	vector<bool> dirty;

	segtree<T,U>(vector<T> leaves): n(sz(leaves)) {
		H = 32 - __builtin_clz(2*n-1);

		value.resize(2*n);
		copy(all(leaves),begin(value)+n);
		FORD(i,1,n) value[i] = value[2*i] + value[2*i+1];
		
		dirty.resize(n,false);
		prop.resize(n);
	}

	void apply(ll i, U &upd) {
		value[i] = upd(value[i]);
		if (i < n) prop[i] = prop[i] + upd, dirty[i] = true;
	}

	void rebuild(ll i) {
		for (i /= 2; i; i /= 2) value[i] = prop[i](value[2*i] + value[2*i+1]);
	}

	void propagate(ll i) {
		FORD(h,1,H+1) if (dirty[i >> h]) {
			ll j = i >> h;
			apply(2*j,prop[j]), apply(2*j+1,prop[j]);
			prop[j] = U(), dirty[j] = false;
		}
	}

	void update(ll i, ll j, U upd) {
		if (i == j) return;
		i += n, j += n;
		propagate(i), propagate(j-1);
		for (ll l = i, r = j; l < r; l /= 2, r /= 2) {
			if (l & 1) apply(l++,upd);
			if (r & 1) apply(--r,upd);
		}
		rebuild(i), rebuild(j-1);
	}
	
	T query(ll i, ll j) {
		i += n, j += n;
		propagate(i), propagate(j-1);
		T resl, resr;
		for (; i < j; i /= 2, j /= 2) {
			if (i & 1) resl = resl + value[i++];
			if (j & 1) resr = value[--j] + resr;
		}
		return resl + resr;
	}
};

struct node {
	ll x = oo, i = oo;
	node operator+(node n) {
		return {min(x,n.x), min(i,n.i)};
	}
};

struct update {
	bool is_add = true;
	ll x = 0;
	node operator()(node n) {
		if (is_add) return {n.x+x, n.i};
		else return {x+n.i, n.i};
	}
	update operator+(update u) {
		if (u.is_add) return {is_add, x+u.x};
		else return u;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m >> n;

	vector<node> leaves(n);
	FOR(i,0,n) leaves[i] = {0,i};
	segtree<node,update> S(leaves);

	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--;
		
		ll val = a > 0 ? S.query(a-1, a).x : oo;

		S.update(0, a, {true,1});
		S.update(a, b, {false,val-a+2});
		S.update(b, n, {true,1});
		// FOR(i,0,n) cerr << S.query(i,i+1).x << " \n"[i+1==n];

		ll res = S.query(0, n).x;
		if (res >= oo/2) res = -1;
		cout << res << endl;

	}
}



Measured memory_bytes: 18764
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto hs = readln.split.to!(int[]);
    auto max_h = hs[0];
    int r;
    foreach (h; hs) {
        if (h >= max_h) {
            ++r;
            max_h = h;
        }
    }
    writeln(r);
}

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

int main()
{
    int n, w;
    cin >> n >> w;
    int a[n] = {};
    long long v[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i] >> v[i];
    }
    long long dp[n+1][w+1] = {};

    for(int i=0; i<n; i++){
        for(int j=0; j<=w; j++){
            if(j<a[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-a[i]]+v[i]);
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;

	X -= Z * 2;
	int n = Y + Z;
	int m = X / n + X % n / Y;

	cout << m << endl;
}

Measured memory_bytes: 3580
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	vector<int> demical(ll n, int k, int l = -1) {
		vector<int> rtn;
		if (l < 0) {
			while (n > 0) {
				rtn.push_back(n % k);
				n /= k;
			}
		} else {
			rtn.resize(l);
			REP(i, l) {
				rtn[i] = n % k;
				n /= k;
			}
		}
		return rtn;
	}

	void solve() {
		IOS;
		int n;
		cin >> n;
		vector<int> a(n);
		REP(i, n) {
			cin >> a[i];
		}
		set<int> st;
		int t = 1 << n;
		REP(i, t) {
			auto d = demical(i, 2, n);
			int tmp = 0;
			REP(j, n) {
				if (d[j]) {
					tmp += a[j];
				}
			}
			st.insert(tmp);
		}
		int q;
		cin >> q;
		REP(i, q) {
			int m;
			cin >> m;
			auto itr = st.find(m);
			if (itr == st.end()) {
				put("no");
			} else {
				put("yes");
			}
		}
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2-y2+y1<<' '<<y2+x2-x1<<' '<<x1-y2+y1<<' '<<y1+x2-x1<<endl;
}


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

int	abs(int x)
{
  if (x > 0) 
    return (x);
  else 
    return (-x);
}

int main()
{
  int n;
  int k;
  int x;
  int i;
  int amount;
  
  cin >> n >> k;
  
  amount = 0;
  while (i < n)
  {
    cin >> x;
    if(abs(x - 0) < abs(x - k))
      amount += abs(x - 0) * 2;
    else 
      amount += abs(x - k) * 2;
    i++;
  }
  
  cout << amount << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {
            int answer = int.MaxValue;
            int[] nt = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int n = nt[0];
            int t = nt[1];

            var cLine = new List<int>();
            var tLine = new List<int>();
            for (int i = 0; i < n; i++)
            {
                int[] ct = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                cLine.Add(ct[0]);
                tLine.Add(ct[1]);

            }
            for(int j = 0;j < n;j++)
            {

                if (tLine[j] > t)
                {
                    continue;
                }
                if (cLine[j] < answer)
                {
                    answer = cLine[j];
                }
            }
            if(answer == int.MaxValue)
            {
                Console.WriteLine("TLE");
            }
            else
            {
                Console.WriteLine(answer);
            }

            

            
            Console.ReadLine();

        }
    }
}


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

int main(){
    int N;
    cin >> N;
    int p[N+1];
    for(int i=1;i<=N;i++){
        int x; cin >> x;
        p[i]=x;
    }
    int ans=0;
    for(int i=1;i<N;i++){
        if(p[i]==i){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    for(int i=N;i>=2;i--){
        if(p[i]==i){
            swap(p[i],p[i-1]);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int a;
      int sum = 0;
      for(int i = 0;i<m;i++){
         a = sc.nextInt();
         sum += a;
      }
      if(n>=sum){
         System.out.println(n-sum);
      }else{
         System.out.println(-1);
      }
	}
}

Measured memory_bytes: 46076
def count_move(lst,i):
    
    count=0
    for k in range(i,len(lst)-1):
        if lst[k]>=lst[k+1]:
            count+=1
        else:break
    return count

n=int(input())
H=list(map(int,input().split()))

ans=0
i=0
while(i <= n-1):
    if count_move(H,i)>ans:
        ans = count_move(H,i)
    
    i += max(1,count_move(H,i))
    
print(ans)
    

Measured memory_bytes: 14252
#include <iostream>
#include <vector>

int partition(std::vector<int> &A,int p,int r){
  int x = A[r];
  int i = p-1;
  for( int j=p;j<r;++j ){
    if(A[j] <= x){
      i++;
      std::swap(A[i],A[j]);
    }
  }
  std::swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n;
  std::cin>>n;
  std::vector<int> array(n);
  for(auto &a:array){
    std::cin>>a;
  }
  int pivot = partition(array,0,n-1);
  
  for(int i=0;i<n;++i){
    if(i)std::cout<<" ";
    if(i==pivot)
      std::cout<<"["<<array[i]<<"]";
    else
      std::cout<<array[i];
  }
  std::cout<<std::endl;
  return 0;
}

Measured memory_bytes: 3092
N, M = map(int, input().split())
keys = []
for i in range(M):
  keys.append(list(map(int, input().split())))
  
passkeys = [1, N]
for i in range(M):
  passkeys[0] = max(passkeys[0], keys[i][0])
  passkeys[1] = min(passkeys[1], keys[i][1])
if passkeys[1] >= passkeys[0]:
  print(passkeys[1] - passkeys[0] + 1)
if passkeys[1] < passkeys[0]:
  print(0)

Measured memory_bytes: 27340
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t dfs(const vector<unordered_set<int64_t>>& friends, vector<int64_t>& g,
            int64_t r, int64_t v) {
    if (g[v] >= 0) {
        return 0;
    }

    g[v] = r;

    int64_t ret = 1;
    for (auto u : friends[v]) {
        ret += dfs(friends, g, r, u);
    }

    return ret;
}

int main() {
    int64_t n, m, k;
    cin >> n >> m >> k;

    vector<unordered_set<int64_t>> friends(n), blocks(n);
    for (auto i : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        friends[a].insert(b);
        friends[b].insert(a);
    }
    for (auto i : irange(0L, k)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        blocks[a].insert(b);
        blocks[b].insert(a);
    }

    vector<int64_t> g(n, -1), c(n);
    for (auto i : irange(0L, n)) {
        c[i] = dfs(friends, g, i, i);
    }

    const auto* delim = "";
    for (auto i : irange(0L, n)) {
        int64_t tmp = c[g[i]] - /* self */ 1 - friends[i].size();
        // 高々K回しか回らない
        for (auto v : blocks[i]) {
            if (g[i] == g[v]) {
                --tmp;
            }
        }
        cout << delim << tmp;
        delim = " ";
    }
    cout << endl;
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);

  for (int i = 0; i < n; i++)
    cin >> h[i];

  double mn = (1 << 21);
  int res   = 0;
  for (int i = 0; i < n; i++) {
    double tmp = abs(a - (t - h[i] * 0.006));
    if (mn > tmp) {
      mn  = tmp;
      res = i;
    }
  }
  cout << res + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int win = 0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='o'){
        win++;
      }
    }
    win+=15-s.length();
    System.out.println(win<8?"NO":"YES");
  }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void)
{
	int r,c,i,j,number[101][101]={0};

	scanf("%d %d",&r,&c);

	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			scanf("%d",&number[i][j]);

			number[i][c]+=number[i][j];
			number[r][j]+=number[i][j];
		}
		number[r][c]+=number[i][c];
	}
	for(i=0;i<=r;i++)
	{
		for(j=0;j<=c;j++)
		{
			printf("%d",number[i][j]);
			if(j!=c)
			{
				printf(" ");
			}	
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
while True:
  n = int(input())
  if n == 0:break
  base = ord("A")
  vote = [0] * 26
  clst = list(input().split())
  for i, v in enumerate(clst, start=1):
    vote[ord(v) - base] += 1
    first, second = 0, 0
    for v in vote:
      if v > first:
        first, second = v ,first
      elif v > second:
        second = v
    if first - second > n - i:
      print(chr(vote.index(first) + base), i)
      break
  else:
    print("TIE")
  


Measured memory_bytes: 5620
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=1000000007,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
int n,cnt[100100];
ll bin[100100];
char s[100100];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	int i;ll ans=0;
	bin[0]=1;
	for (i=1;i<=n;i++) bin[i]=(bin[i-1]<<1)%maxd;
	scanf("%s",s+1);
	ans=0;
	for (i=1;i<=n;i++) 
	{
		int j;ll tmp=1;
		cnt[s[i]-'a']++;
		for (j=0;j<26;j++)
		{
			if (j==s[i]-'a') continue;
			if (cnt[j]==1) tmp=(tmp<<1)%maxd;
			else if (cnt[j]>1) tmp=(tmp*(cnt[j]+1))%maxd;
		}
		//cout << tmp << endl;
		ans=(ans+tmp)%maxd;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1152
PROGRAM ATCODER

implicit none
integer(16) :: a,b,x

read(*,*) a,b,x

if(a == 0)then
  write(*,'(i0)') b/x+1
else
  write(*,'(i0)') (b/x+1)-((a-1)/x+1)
end if

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER

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

int main() {
	int n, d; cin >> n >> d;
	int a = n / (2*d+1);
	int b = n % (2*d+1);
	if(b == 0) cout << a << endl;
	else cout << a + 1 << endl;
}

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

using namespace std;

vector<string> nums;
set<string> a;
int n, k;
int main()
{
    while(cin >> n && n)
    {
        cin >> k;
        for(int i=0;i<n;++i)
        {
            string t;
            cin >> t;
            nums.push_back(t);
        }
        for(int w=0;w<n;++w){
            for(int x=0;x<n;++x){
                if(w==x) continue;
                if(k>2){
                    for(int y=0;y<n;++y){
                        if(y==x || y==w) continue;
                        if(k>3){
                            for(int z=0;z<n;++z){
                            if(z==y || z==x || z==w) continue;
                            a.insert(nums[w]+nums[x]+nums[y]+nums[z]);
                            }
                        }
                        else a.insert(nums[w]+nums[x]+nums[y]);
                    }
                }
                else a.insert(nums[w]+nums[x]);
            }
        }
        cout << a.size() << endl;
        nums.clear();
        a.clear();
    }
}

Measured memory_bytes: 1456
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


							  //���C�u�����\��
							  //�l�b�g���[�N�t���[�F�a�{p188�`
class NetworkFlow {
public:
	//�����F���_��
	NetworkFlow(int size) {
		G.resize(size);
		used.resize(size);
	}

	//from����to�֌������e��cap�̕ӂ��O���t�ɒǉ�����
	void add_edge(int from, int to, int cap) {
		Edge e1 = { to, cap, (int)G[to].size() };
		Edge e2 = { from, 0, (int)G[from].size() - 1 };
		G[from].push_back(e1);
		G[to].push_back(e2);
	}

	//s����t�ւ̍ő嗬�����߂�
	int max_flow(int s, int t) {
		int flow = 0;
		while (true) {
			fill(used.begin(), used.end(), false);
			int f = dfs(s, t, INF);
			if (f == 0)return flow;
			flow += f;
		}
	}


private:
	//�^�ƕϐ�
	struct Edge { int to, cap, rev; };//�ӂ�\���\���́i�s����A�e�ʁA�t�Ӂj
	vector<vector<Edge>> G;   //�O���t�̗אڃ��X�g�\��
	vector<bool> used;//DFS�Ŋ��ɒ��ׂ����̃t���O

					  //�֐�
					  //�����p�X��DFS�ŒT��
	int dfs(int v, int t, int f) {
		if (v == t)return f;
		used[v] = true;
		REP(i, (int)G[v].size()) {
			Edge& e = G[v][i];
			if (!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
};
using NF = NetworkFlow;

//�ϐ�
constexpr int ALNUM = 26;
int N;
vector<vector<int>> s(ALNUM, vector<int>(ALNUM, 0));
vector<bool> res(ALNUM, false);





//�T�u�֐�
//����
void input()
{
	cin >> N;
	REP(i, N) {
		string ts;
		cin >> ts;
		int from = ts.front() - 'a';
		int to = ts.back() - 'a';
		s[from][to]++;
	}
}


//�v�Z
void calc()
{
	REP(k, ALNUM) {
		int inAll = 0;
		int outAll = 0;
		REP(i, ALNUM) {
			//if (i == k)continue;
			outAll += s[k][i];
			inAll += s[i][k];
		}
		NetworkFlow nf(ALNUM + 1);
		REP(i, ALNUM)REP(j, ALNUM) {
			//if (i == j)continue;
			nf.add_edge(i, (j == k ? ALNUM : j), s[i][j]);
		}
		int roop = nf.max_flow(k, ALNUM);
		
		if (inAll != 0 && inAll >= outAll && outAll == roop)res[k] = true;
		//char t = 'a' + k;
		//string tmp;
		//tmp += t;
		//cout << tmp << " " << inAll << " " << roop << " " << outAll << endl;
		//cout << (in < out) << endl;
		//if (in > out)res[k] = true;
	}
}


//�o��
void output()
{
	REP(i, ALNUM)if (res[i]) {
		char t = 'a' + i;
		string tmp;
		tmp += t;
		cout << t << endl;
	}
}


//�f�o�b�O
void debug()
{
	int N;
	cin>>N;
}


//���C���֐�
int main()
{
	input();
	calc();
	output();
	//debug();
	
	return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] card = new String[3];
		Arrays.setAll(card, i -> sc.next());
		
		int[] idx = new int[3];
		
		int player = 0;
		while (true) {
			if (idx[player] == card[player].length()) break;
			
			player = card[player].charAt(idx[player]++) - 'a';
		}
		
		String winner = "" + (char) ('A' + player);
		System.out.println(winner);
		
		sc.close();
	}
}




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

const int MOD = (int)1e9+7;

int main(){
  long long N,A,B;
  cin >> N >> A >> B;

  if(B<A || (A!=B && N==1)){
    cout << 0 << endl;
    return 0;
  }
  long long mi=A*(N-1)+B;
  long long ma=A+B*(N-1);
  cout << ma-mi+1 << endl;

  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b == c + d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,m;
  cin >> n >> m;
  UnionFind tree(n);
  vector<ll>p(n);
  rep(i,n) cin >> p[i];
  rep(i,m){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    tree.merge(x,y);
  }
  ll ans=0;
  rep(i,n){
    if(tree.issame(i,p[i]-1))ans++;
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 2560
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
bool cmp(string a,string b)
{
	return a<b;
}
int n,m;
string s[105];
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	   cin>>s[i];
	sort(s,s+n+1,cmp);
	for (int i=1;i<=n;i++)
	   cout<<s[i];
    return 0;
}


Measured memory_bytes: 256
s = [i for i in list(input())]

def kaibun(t):
    c = 0
    for i in range(int((len(t) + 1) / 2)):
        if t[i] == t[len(t) - 1 - i]:
            c += 1
    
    if c == int((len(t) + 1) / 2):
        return True
    else:
        return False

f1 = kaibun(s)
f2 = kaibun(s[0:int((len(s) - 1) / 2)])
f3 = kaibun(s[int((len(s) + 1) / 2):len(s)])

if f1 and f2 and f3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

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

Measured memory_bytes: 572
n,k = map(int,input().split())
h = list(map(int, [input() for i in range(n)]))

dif = 1000000000
h_sort = sorted(h)
for i in range(n-k+1):
    dif = min(dif,h_sort[i+k-1]-h_sort[i])

print(dif)

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

int main(){
    string s;cin>>s;
    string flag = "Yes";
    vector <char> odds{'R', 'U', 'D'};
    vector <char> even{'L', 'U', 'D'};
    for (int i=0;i<s.size();i++){
        if (i % 2 == 0){
            if (find(odds.begin(), odds.end(), s[i]) == odds.end()){
                flag = "No";
                break;
            }
        } else {
            if (find(even.begin(), even.end(), s[i]) == even.end()){
                flag = "No";
                break;
            }
        }
    }
    cout << flag << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

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

}
double max(double a, double b) {

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

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

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

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

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

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

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

	if (b == 0) {

		return 1;

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

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

	}
	else {

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

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

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

		a *= i;
		a = a%p;

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

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

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

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

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

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

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

}
//????°???¬?????°

int main() {
	
	ll n, m, l, a[105][105], b[105][105], c[105][105];

	cin >> n >> m >> l;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {

			cin >> a[i][j];

		}
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= l; j++) {

			cin >> b[i][j];

		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= l; j++) {

			c[i][j] = 0;
			for (int k = 1; k <= m; k++) {

				c[i][j] += a[i][k] * b[k][j];

			}
			if (j != l)cout << c[i][j] << " ";

		}
		cout << c[i][l] << endl;
	}

	return 0;
}

Measured memory_bytes: 3296
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int judge(x) {
  double i = 3;
 
  if(x == 1) return 0;
  if(x%2 == 0 && x != 2)
    return 0;
  while(i <= sqrt((double)x)) {
    if((int)x%(int)i == 0) return 0;
    i++;
  }
  return 1;
}

int main() {
  int n, i;
  int s = 0;
  int *A;

  scanf("%d", &n);
  A = malloc(n*sizeof(int));

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

  for(i = 0; i < n; i++) {
    s += judge(A[i]);
  }

  printf("%d\n", s);

  return 0;
}

Measured memory_bytes: 628
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	int n;cin>>n;
	double ans=1;
	for(int i=0;ans<=n;i++){
		ans = pow(2,i);
	}
	cout << ans/2 << endl;
	return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      for (int j = 1; j <= cnt; j++) {
        cnt -= j;
        ans++;
      }
    }
  }
  if (n > 1) ans++;
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

#define _int64 long long

int main()
{
  int i;
  _int64 a,b,c,aa,bb,cc;
  scanf("%lld%lld%lld",&a,&b,&c);
  for (i=0;i<100000;i++)
  {
    if ((a%2!=0)||(b%2!=0)||(c%2!=0)) break;
    aa=b/2+c/2;
    bb=a/2+c/2;
    cc=a/2+b/2;
    a=aa;b=bb;c=cc;
  }
  if (i==100000) printf("-1\n");
  else printf("%d\n",i);
  return 0;
}

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

int main() {
  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0)
      break;
    vector<int> A(N), B(M);
    for (int i = 0; i < N; ++i)
      cin >> A[i];
    for (int i = 0; i < M; ++i)
      cin >> B[i];
    int a = 0, ans = 0;
    for (int i = 0; i < M; ++i) {
      a += B[i];
      if (a >= N - 1) {
        ans = i + 1;
        break;
      }
      a += A[a];
      if (a >= N - 1) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << endl;
  }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    char a;
    cin >> a;
    if (a <= 'Z')
    {
        cout << "A";
    }
    else
    {
        cout << "a";
    }
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3632