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

int main(void)
{
    int n,k;
    scanf("%d %d",&n,&k);
    int sunuke[n+1];
    for(int i=0;i<n+1;i++){
        sunuke[i]=0;
    }

    for(int i=0;i<k;i++){
        int di;
        scanf("%d",&di);
        int a[di];
            for(int j=0;j<di;j++){
                int aj;
                scanf("%d",&aj);
                sunuke[--aj]++;
            }
    }

    int ans=0;
    for(int i=0;i<n;i++){
        if(sunuke[i]==0){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1732
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MAX_VAL = 12800
 
h, w = [int(item) for item in input().split()]
a = []
b = []
for i in range(h):
    line = [int(item) for item in input().split()] + [0]
    a.append(line)
a.append([0] * (w + 1))
for i in range(h):
    line = [int(item) for item in input().split()] + [0]
    b.append(line)
b.append([0] * (w + 1))
 
# dp[height][width] bitset
dp = [[0] * (w+1) for _ in range(h+1)] 
delta = abs(a[0][0] - b[0][0])
dp[0][0] |= 1 << (MAX_VAL + delta)
dp[0][0] |= 1 << (MAX_VAL - delta)
for i in range(h):
    for j in range(w):
        diffr = abs(a[i][j+1] - b[i][j+1])
        diffd = abs(a[i+1][j] - b[i+1][j])
        # Move right
        add_delta = dp[i][j] << diffr
        sub_delta = dp[i][j] >> diffr
        dp[i][j+1] |= add_delta | sub_delta
        # Move down
        add_delta = dp[i][j] << diffd
        sub_delta = dp[i][j] >> diffd
        dp[i+1][j] |= add_delta | sub_delta
ans = MAX_VAL
for i in range(MAX_VAL * 2):
    if dp[h-1][w-1] & (1 << i):
        ans = min(ans, abs(i - MAX_VAL))
print(ans)

Measured memory_bytes: 21620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int h, w;
    int n;
    cin >> h >> w;
    cin >> n;

    int p[100][100] = {};
    int k = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        for (int j = 0; j < a; j++) {
            int x = k % w;
            int y = k / w;
            if (y & 1) x = w - 1 - x;
            p[y][x] = i + 1;
            k++;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << p[i][j] << " \n"[j == w - 1];
        }
    }

    return 0;
}

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

int main () {
  int A, B;
  cin >> A >> B;
  
  int C = A - 1; //増える数
  int d = 1;
  while (A < B) {
    A += C;
    d++;
  }
  if (B != 1) {
    cout << d;
  } else {
    cout << 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
multiset<ll> st;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    while(N--) {
        ll a;
        cin >> a;
        st.insert(a);
    }
    while(M--) {
        auto itr = st.end();
        itr--;
        ll a = *itr;
        a /= 2;
        st.erase(itr);
        st.insert(a);
    }
    ll ans = 0;
    for(auto itr = st.begin(); itr != st.end(); itr++) ans += *itr;
    cout << ans << endl;
    return 0;
}


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

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

  vector<int> h(N);
  rep(i, N) {
    cin >> h[i];
  }

  vector<int> dp(N);
  dp[1] = abs(h[1] - h[0]);

  repi(i, 2, N) {
    vector<int> cost(2);
    cost[0] = abs(h[i] - h[i - 1]);
    cost[1] = abs(h[i] - h[i - 2]);
    dp[i] = min(dp[i - 1] + cost[0], dp[i - 2] + cost[1]);
  }

  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

k, a, b = map(int, input().split())
k += 1
cnt =  k - (a + 2)

if b - a > 2 and cnt >= 0:
    ans = b + (b - a)*(cnt//2) + cnt%2
else:
    ans = k

print(ans)


Measured memory_bytes: 10444
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
using namespace std;

class Edge{
public:
	int edge_dist;
	int cost;
	Edge() : edge_dist(0), cost(0) {}
	Edge(int _dist, int _cost) : edge_dist(_dist), cost(_cost) {}
};

bool operator==(const Edge &a, const Edge &b){
	return (a.cost == b.cost);
}
bool operator!=(const Edge &a, const Edge &b){
	return !(a == b);
}
bool operator<(const Edge &a, const Edge &b){
	return (a.cost < b.cost);
}
bool operator>=(const Edge &a, const Edge &b){
	return !(a < b);
}
bool operator>(const Edge &a, const Edge &b){
	return (a.cost > b.cost);
}
bool operator<=(const Edge &a, const Edge &b){
	return !(a > b);
}

int main(){
	int v, e, s, t, w, sum;
	vector< int > vlist; //??¢?´¢?????? -> 1 / else -> 0
	vector< vector< Edge > > edge;
	priority_queue< Edge, vector< Edge >, greater< Edge > > priq;
	
	while(cin >> v, v){
		cin >> e;
		
		vlist.resize(v);
		edge.resize(v);
		sum = 0;
		
		for(int i = 0; i < v; ++i){
			vlist[i] = 0;
			edge[i].erase(edge[i].begin(),edge[i].end());
		}
		
		for(int i = 0; i < e; ++i){
			scanf("%d,%d,%d", &s, &t, &w);
			w /= 100;
			
			edge[s].push_back(Edge(t, w - 1));
			edge[t].push_back(Edge(s, w - 1));
		}
		
		vlist[0] = 1;
		for(vector< Edge >::iterator it = edge[0].begin(); it != edge[0].end(); ++it){
			priq.push(*it);
		}
		
		while(!priq.empty()){
			
			Edge ed = priq.top();
			priq.pop();
			
			if(vlist[ed.edge_dist])continue;
			
			vlist[ed.edge_dist] = 1;
			sum += ed.cost;
			
			for(vector< Edge >::iterator it = edge[ed.edge_dist].begin(); it != edge[ed.edge_dist].end(); ++it){
				if(vlist[(*it).edge_dist] == 0){
					priq.push(*it);
				}
			}
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1476
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,x,t;
  	cin>>n>>x>>t;
  	int ans;
	  if(n%x==0)
  	{
  		ans=n/x;
  		ans*=t;
	}
	else
	{
		ans=n/x+1;
		ans=ans*t;
	}
  	cout<<ans<<endl;
}

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

#define ll long long
int main() {
  
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  ll N = 50; // 2^N > 10^12 を超える適当なN
  
  ll x = 2; // 2の累乗
  
  ans = (((B+1) / 2) - (A/2)) % 2; // 1の位
  
  for (int i = 1; i < N; i++) {
    ll a = 0, b = 0; 
    if (A % (x*2) >= x) {
      a = x - (A % x);
    }
    if (B % (x*2) >= x) {
      b = B % x + 1;
    }
    if ((a+b) % 2) {
      ans += x;
    }
    x *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch[110];
int main()
{
	bool flag1=0,flag2=0;
	int x,y;
	cin>>ch;
	int chlen=strlen(ch);
	for(int i=0;i<chlen;i++)
	{
		if(ch[i]=='C') flag1=1,x=i;
		if(ch[i]=='F') flag2=1,y=i;
	}
	if(flag1==1&&flag2==1&&x<y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,a1,b1=0;
    scanf("%d %d %d",&a,&b,&c);
    a1=a;
    b1=b;
    b=a1;
    a=c;
    c=b1;
    printf("%d %d %d",a,b,c);
    return 0;  
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={-1, 0, 1,0, 0};
int dx[]={0,1, 0, -1, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,m;
char c[200][200];

bool dfs(ll i ,ll j,ll d,ll gi,ll gj) {
    if(i == gi && j == gj) {
        return true;
    }

    for(int k = -1;k < 3;k++) {
        ll x = i + dx[(k + d + 4) % 4];
        ll y = j + dy[(k + d + 4) % 4];
        if(0 <= x && x < n && 0 <= y && y < m && c[x][y] == '.') {
            c[x][y] = '#';
            if(dfs(x,y,(k + d + 4) % 4,gi,gj)) 
                return true;
            //c[x][y] = '.';
        }
    }
    return false;
}
void out () {
    REP(i,n)
        cout << c[i] << endl;
    cout << "\n\n";
}

int main(){
    while(true) {
        cin >> n >> m;
        if(n == 0)
            break;
        REP(i,n) {
            REP(j,m) {
                cin >> c[i][j];
            }
        }
        bool f = dfs(0,0,1,n-1,0);
        //cout << f << endl;
        //out();
        f = (f && dfs(n-1,0,2,n-1,m-1));
        //cout << f << endl;
        //out();
        f = (f && dfs(n-1,m-1,3,0,m-1));
        //cout << f << endl;
        //out();
        f = (f && dfs(0,m-1,0,0,0));
        //cout << f << endl;
        //out();
        if(f)
            cout << "YES" << endl;
        else
            cout<< "NO" << endl;
    }
}




Measured memory_bytes: 3136
#include <stdio.h>
#include <string.h>

#define N_MAX ( 101 )

int main()
{
	int x = 0;
	int x_max = x;
	int len;
	char str_s[N_MAX] = {0};
	
	scanf( "%d", &len );
	scanf( "%s", str_s );
	len = strlen( str_s );
	
	int i;
	for( i = 0; (i < len) && (0 != str_s[i]); i++ )
	{
		if ( 'I' == str_s[i] )
		{
			x++;
		}
		else if ( 'D' == str_s[i] )
		{
			x--;
		}
		else
		{
			/* NOP */
		}
		
		if ( x_max < x )
		{
			x_max = x;
		}
	}
	
	printf( "%d\n", x_max );
	
	return 0;
}



Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int i=1;
		while(true) {
			int d=Integer.parseInt(in.next());
			if(d==0)break;
			out.printf("Case %d: %d\n", i,d);
			i++;
		}
		out.flush();
	}

}



Measured memory_bytes: 58812
#include <stdio.h>

int binarySearch(int *,int,int);

int main() {
  int i,n,q,S[1000000],T[1000000],ans=0;


  scanf("%d",&n);
  for(i=0;i<n ;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q; i++) scanf("%d",&T[i]);

  for(i=0; i<q; i++){
    ans += binarySearch(S,T[i],n);
  }
  printf("%d\n",ans);

  return 0;
}

int binarySearch(int *A, int key, int n){
  int left = 0;
  int right = n;
  int mid;

  while(left < right){
    mid = (left + right) / 2;
    if (A[mid] == key) return 1;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 3044
/*  -*- coding: utf-8 -*-
 *
 * 2940.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

/* typedef */

typedef pair<int,int> pii;
typedef queue<pii> qpii;

enum { YES, NO, NEAR };

/* global variables */

pii es[MAX_M];

/* subroutines */

int query(int a) {
  printf("%d\n", a + 1); fflush(stdout);

  char s[16];
  scanf("%s", s);

  if (s[0] == 'Y') return YES;
  if (s[1] == 'o') return NO;
  return NEAR;
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  qpii q;
  q.push(pii(0, n));

  int m = 0;
  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int ui = u.first, uj = u.second;
    int i0 = ui + 1, i2 = uj, i1 = (i0 + i2) / 2;

    for (int i = i0; i < i1; i++) es[m++] = pii(ui, i);
    if (i0 + 1 < i1) q.push(pii(i0, i1));
    if (i1 + 1 < i2) q.push(pii(i1, i2));
  }

  printf("%d\n", m);
  for (int i = 0; i < m; i++)
    printf("%d %d\n", es[i].first + 1, es[i].second + 1);
  fflush(stdout);

  while (k--) {
    qpii qq;
    qq.push(pii(0, n));

    while (! qq.empty()) {
      pii u = qq.front(); qq.pop();
      int ui = u.first, uj = u.second;
      int i0 = ui + 1, i2 = uj, i1 = (i0 + i2) / 2;

      int r = query(ui);
      if (r == YES) break;

      if (r == NEAR) qq.push(pii(i0, i1));
      else qq.push(pii(i1, i2));
    }
  }
  return 0;
}



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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n, k;
	cin >> n >> k;
	VI h(n);
	IN(n, h);

	int count = 0;
	FOR(0, n)
	{
		if (h[i] >= k)count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7)
N,Q = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N-1)]
PX = [list(map(int,input().split())) for _ in range(Q)]

X = {i+1:0 for i in range(N)}
for px in PX:
    X[px[0]] += px[1]

G = {i+1:[] for i in range(N)}
for ab in AB:
    G[ab[0]].append(ab[1])
    G[ab[1]].append(ab[0])

seen = [False]*N
W = [0]*N

def dfs(G, W, v, w):
    seen[v-1] = True
    W[v-1] = w+X[v]
    for nv in G[v]:
        if seen[nv-1]:
            continue
        dfs(G, W, nv, W[v-1])

dfs(G, W, 1, 0)

print(*W)

Measured memory_bytes: 334472
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,y;
  cin >> n >> y;
  y /= 1000;
  rep(i,n+1)rep(j,n-i+1){
    if(i+j*5+(n-i-j)*10==y){
      cout << n-i-j << " " << j << " " << i << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)


int main() {
    //freopen("in.txt", "r", stdin);
    int n; cin >> n;
    double p[n]; rep(i, n) cin >> p[i];

    double dp[n+1][n+1];
    for (int h = n; h >= 0; --h) {
        for (int t = n-h; t >= 0; --t) {
            int i = h+t;
            if (i == n) dp[h][t] = (h > t ? 1 : 0);
            else dp[h][t] = p[i] * dp[h+1][t] + (1-p[i]) * dp[h][t+1];
        }
    }
    cout << fixed << setprecision(10) << dp[0][0] << '\n';
}



Measured memory_bytes: 46336
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
#define M 1000000007
ll n,a[100005],s,b[100005],m,x;
int main(void){
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        s+=a[i];
    }
    if(s%((n+1)*n/2)){
        printf("NO\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        b[i]=a[(i+1)%n]-a[i];
        m=max(m,b[i]);
    }
    for(int i=0;i<n;i++){
        b[i]=-b[i]+m;
        if(b[i]%n){
            printf("NO\n");
            return 0;
        }
        x+=b[i]/n;
    }
    ll y=s/((n+1)*n/2);
    if(y<x||y%n!=x%n){
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

// 入力関数
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect(("failed to parse token"))
}

fn main() {
    let s:String = read();

    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll H, W;
vector<string> a(1000);
vector<vector <bool>> b(1000);
vector <ll> candY;
vector <ll> nxtCandY(0);
vector <ll> candX;
vector<ll> nxtCandX(0);

ll mycount;
bool progress;

void operate(ll y, ll x) {
  if (y < 0 || y >= H || x < 0 || x >= W)  return;
  if (b.at(y).at(x))  return;
  b.at(y).at(x) = true;
  progress = true;
  nxtCandY.push_back(y);
  nxtCandX.push_back(x);
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> H >> W;
  for (ll j = 0; j < H; j++) {
    string s;
    cin >> s;
    b.at(j).resize(1000);
    for (ll i = 0; i < W; i++) {
      if (s.at(i) == '#') {
	b.at(j).at(i) = true;
	candY.push_back(j);
	candX.push_back(i);
      }else {
	b.at(j).at(i) = false;
      }
    }
  }

  mycount = 0;
  while (1) {
    progress = false;
    for (ll t = 0; t < (ll)candY.size(); t++) {
      ll y = candY.at(t);
      ll x = candX.at(t);
      operate(y+1, x);
      operate(y-1, x);
      operate(y, x+1);
      operate(y, x-1);
    }
    if (!progress)  break;
    mycount++;
    candY = nxtCandY;
    candX = nxtCandX;
    nxtCandY.resize(0);
    nxtCandX.resize(0);
  }
  cout << mycount << endl;

  return 0;
}



Measured memory_bytes: 25684
import java.util.*;

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

        int n = sc.nextInt();

        String[] s = new String[n];
        int[] t = new int[n];

        for (int i=0; i<n; i++){
            s[i] = sc.next();
            t[i] = sc.nextInt();
        }

        String x = sc.next();

        int ans = 0;

        int tmp = 0;

        for (int i=0; i<n; i++){
            if (s[i].equals(x)){
                tmp = i;
                break;
            }
        }
        for (int i=tmp+1; i<n; i++){
            ans += t[i];
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 24148
while True:
    try:
        a, b, c, d, e, f = [int(i) for i in input().split()]

        detA = a * e - b * d
        detA1 = c * e - b * f
        detA2 = a * f - c * d

        print('{:.3f} {:.3f}'.format(detA1 / detA + 0, detA2 / detA + 0))
    except EOFError:
        break


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  vector<ll> l(n);
  rep(i, n) {
    if (i == 0) l[i] = a[i];
    else l[i] = gcd(l[i-1], a[i]);
  }

  vector<ll> r(n);
  for (int i=n-1; i>=0; i--) {
    if (i == n-1) r[i] = a[i];
    else r[i] = gcd(r[i+1], a[i]);
  }

  ll ans = 0;
  rep(i, n) {
    ll tmp = 0;
    if (i == 0) tmp = r[i+1];
    else if (i == n-1) tmp = l[i-1];
    else tmp = gcd(l[i-1], r[i+1]);
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  int ans=1001;
  int cnt =0;
  for(int i=0;i<s.size()-t.size()+1;i++){
    for(int j=0;j<t.size();j++){
      if(s.at(i+j)!=t.at(j)){
        cnt++;
      }
    }
    ans=min(ans,cnt);
    cnt=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let t: Vec<u64> = read_vec();
    let a: Vec<u64> = read_vec();

    if t[n - 1] != a[0] {
        println!("0");
        return;
    }

    let top = a[0];

    let mut l = 0;
    loop {
        if t[l] == top {
            break;
        }
        l += 1;
    }

    let mut r = n - 1;
    loop {
        if a[r] == top {
            break;
        }
        r -= 1;
    }

    if r < l {
        println!("0");
        return;
    }

    let mut ans = 1;

    if r - l > 1 {
        for _ in 0..r - l - 1 {
            ans = ans * top % 1000000007;
        }
    }

    for i in 1..l {
        if t[i] == t[i - 1] {
            ans = ans * t[i] % 1000000007;
        }
    }

    for i in (r + 1..n - 1).rev() {
        if a[i] == a[i + 1] {
            ans = ans * a[i] % 1000000007;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 11512
#include<stdio.h>
int main()
{
	int A,B,C,D,s1,s2;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	s1=A*B;
	s2=C*D;
	if(s1>s2)
	printf("%d",s1);
	else
	printf("%d",s2);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i > (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
// #define mp make_pair
#define pb push_back
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
long long Ceil(long long a, long long b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
float E = 0.00000000000001;
ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll q=power(x,y/2);
        q=q%p;
        return (q*q)%p;
    }
    ll q=power(x,y/2);
    q=q%p;
    return ((x%p)*((q*q)%p))%p; 
}
bool isPowerOfTwo (long long x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}  

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}
long long int mod(long long int a, long long int b) {
    long long int ret = a%b; return ret>=0? ret: ret+b; 
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        long long d,s,t;cin>>d>>s>>t;
        if(s*t >= d)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
using namespace std;
int a, b, c, x, y, s, mn;
int main() {
	cin>>a>>b>>c>>x>>y;
	mn = s = a*x + b*y;
	for(int i=1; i<=max(x, y); i++) {
		if(i<=min(x, y)) s -= a + b;
		else {
			if(x>y) s -= a;
			else s -= b;
		}
		s += c*2;
		mn = min(mn, s);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
X, K, D = [int(i) for i in input().split()]

X = abs(X)
Q, R = divmod(X, D)

if Q >= K:
    output = X - (K*D)
else :
    if (K - Q) % 2 == 1:
        output = abs(D - R)
    else :
        output = R
        
print(output)


Measured memory_bytes: 9080
import math
x = y = 0
angle = 90
while True:
    d, a = map(int, input().split(','))
    if d == a == 0:
        break
    x += d * math.cos(math.radians(angle))
    y += d * math.sin(math.radians(angle))
    angle -= a
print(int(x))
print(int(y))

Measured memory_bytes: 7976
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	string a_str;

	cin >> a_str;
	rep(i,a_str.size()) 
	{ 
		a_str[i] = a_str[i] - 3;
		if (a_str[i] < (int)'A') 
		{
			int diff;
			diff = 'A' - a_str[i];
			a_str[i] = (char) ('Z' - diff + 1);
			cout << (char) a_str[i];
		}
		else {
			cout << (char) a_str[i];
		}
	}
	cout << endl;
	

	return 0;
}

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

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

int main() {
    int n, l;
    cin >> n >> l;

    int sum = 0;
    int imin = 1000;
    for(int i = 1; i <= n; ++i){
        int t = l + i - 1;
        imin = std::min(imin, std::abs(t));
        sum += t;
    }

    if(sum < 0) sum += imin;
    else sum -= imin;

    cout << sum << endl;
}

Measured memory_bytes: 256
x = gets.chomp.to_i
if x <= 599
    print '8'
elsif x <= 799
    print '7'
elsif x <= 999
    print '6'
elsif x <= 1199
    print '5'
elsif x <= 1399
    print '4'
elsif x <= 1599
    print '3'
elsif x <= 1799
    print '2'
else
    print '1'
end

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
int a[N];
int main() {
	ios::sync_with_stdio(false);
	int h,n,x=0;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		x+=a[i];
	}
	if(x>=h)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;
class union_find{
    vector<long> parent, tree_size;
    public:
    union_find(long n) : parent(n), tree_size(n,1){
        for(int i=0;i<n;i++) parent.at(i)=i;
    }
    long find(long x){
        while(parent.at(x)!=x) x=parent.at(x)=parent.at(parent.at(x));
        return x;
    }
    bool marge(long a,long b){
        a=find(a);
        b=find(b);
        if(a==b) return false;
        if(tree_size.at(a)<tree_size.at(b)) swap(a,b);
        tree_size.at(a)+=tree_size.at(b);
        parent.at(b)=a;
        return true;
    }
};


int main(void){
    long N;
    cin>>N;
    vector<long> x(N),y(N);
    for(int i=0;i<N;i++){
        cin>>x.at(i)>>y.at(i);
    }
    
    union_find uf(N);
    vector<long> X(100005,-1),Y(100005,-1);
    for(int i=0;i<N;i++){
        if(X.at(x.at(i))>=0) uf.marge(X.at(x.at(i)),i);
        if(Y.at(y.at(i))>=0) uf.marge(Y.at(y.at(i)),i);
        
        X.at(x.at(i))=i;
        Y.at(y.at(i))=i;
    }
    
    
    vector<set<long>> setX(N),setY(N);
    for(int i=0;i<N;i++){
        long root=uf.find(i);
        setX.at(root).insert(x.at(i));
        setY.at(root).insert(y.at(i));
    }
    
    long ans=-N;
    for(int i=0;i<N;i++){
        ans+=setX.at(i).size()*setY.at(i).size();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19072
N = int(input())
P = list(map(float, input().split()))

dp = [[0.0] * (N+1) for _ in range(N+1)]

dp[0][0] = 1

for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j] * (1-P[i])
        dp[i+1][j+1] += dp[i][j] * P[i]

ans = 0.0
for i in range(N//2+1, N+1):
    ans += dp[N][i]

print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ll N;
    cin >> N;
    vecll a(N);
    for(auto& i : a) cin >> i;
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = 0;
    for(ll i = 0; i < N;  i++){
        if(i % 2 == 0) ans += a.at(i);
        else ans -= a.at(i);
    }
    cout << ans <<endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int m; cin >> m;
    vector<ll> d(m), c(m);
    for(int i = 0; i < m; i++)cin >> d[i] >> c[i];
    ll res = 0, ans = -1;
    for(int i = 0; i < m; i++) {
        res += c[i] * d[i];
        ans += c[i];
    }
    while(res > 9) {
        ans += res / 10;
        res = res / 10 + (res % 10);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  int k = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) == k) {
      k++;
    }
    else {
      ans++;
    }
  }
  if (ans == N) {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4032
#include <stdio.h>

int main() {
  char s[15]={'\0'};
  char ans[15]={'\0'};
  int i=0,p=0;

  scanf("%s",s);
  while(s[i]!='\0'){
    switch (s[i]) {
      case '0':
        ans[p++]='0';
        break;
      case '1':
        ans[p++]='1';
        break;
      case 'B':
        if(p>0) ans[--p]='\0';
        break;
      default:
        break;
    }
    i++;
  }
  printf("%s\n",ans);
  return 0;
}

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

namespace ABC130A
{
    class Program
    {
        static void Main(string[] args)
        {

            int x, a;

            var word = Console.ReadLine().Split(' ');
            x = int.Parse(word[0]);
            a = int.Parse(word[1]);

            if (x < a)
                Console.WriteLine("0");
            else if (a <= x)
                Console.WriteLine("10");

            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 13140
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;
bool my_compare(pair<string, ll> a, pair<string , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    ll maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    ll i;
    double h;
    ll n,x,m;
    ll a,b,d,c;
    //multiset<pair<string,ll>> s;
    cin>>n;
    vector<pair<string, ll> > pairs(n);
    vector<pair<string, ll> > moto(n);

    rep(i,n){
        cin>>str>>m;
        pairs[i]=make_pair(str,m);
        moto[i]=pairs[i];
    }
    sort(pairs.begin(), pairs.end(),my_compare);

    rep(i,n){
        rep(j,n){
            if(moto[j].first.compare(pairs[i].first)==0&&moto[j].second==pairs[i].second){
                cout<<j+1<<endl;
                break;
            }
        }
    }

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    vector<int>c;
    int d;vector<vector<int>>s;
    vector<int>last;
    auto calc=[&](int t,int day){
        int k=0;
        k+=s[day][t];
        for (int j = 0; j < 26; ++j){
            if(j==t)continue;
            else  k-=c[j]*(day+1-last[j]);
        }
        return k;
    };
    cin >>d;
    c.resize(26);
    for (int i = 0; i <26; ++i) cin >>c[i];
    s.assign(d,vector<int>(26));
    for (int i = 0; i < d; ++i)for (int j = 0; j < 26; ++j) cin >>s[i][j];
    int score=0;
    last.assign(26,0);
    vector<int>t(d);
    for (int day = 0; day < d; ++day) {
        int now=-INF;
        for (int i = 0; i < 26; ++i) {
//            if(day==4&&i==19){
//                cout <<now<<" "<<calc(i,day)<<" "<<endl;
//            }
           if(now<calc(i,day)){
               now=calc(i,day);
               t[day]=i+1;
           }
        }
        last[t[day]-1]=day+1;
        score+=now;
//        cout <<score<<endl;
    }
    for (int i = 0; i < d; ++i) {
        cout<<t[i]<<endl;
    }
//    for (int i = 0; i < 26; ++i) {
//        cout <<last[i]<<endl;
//    }
//    cout <<score<<endl;
    return 0;
}

Measured memory_bytes: 3716
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>

using namespace std;

typedef long long ll;

typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;

int occs[(int)1e6 + 5], tree[500005], n, ans[500005];

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
{

    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }

    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }

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

    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }

    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }

    return 0;
}



Measured memory_bytes: 25380
#include<iostream>
using namespace std;
int main(){
    int n,b;
    char a;
    bool S[13]={},H[13]={},C[13]={},D[13]={};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a == 'S'){
            S[b-1] = true;
        }
        else if(a == 'H'){
            H[b-1] = true;
        }
        else if(a == 'C'){
            C[b-1] = true;
        }
        else{
            D[b-1] = true;
        }
    }
    for(int j=0;j<13;j++){
        if(S[j]==false){
            cout << "S " << j+1 << endl;
        }
    }
    for(int k=0;k<13;k++){
        if(H[k]==false){
            cout << "H " << k+1 << endl;
        }
    }
    for(int l=0;l<13;l++){
        if(C[l]==false){
            cout << "C " << l+1 << endl;
        }
    }
    for(int m=0;m<13;m++){
        if(D[m]==false){
            cout << "D " << m+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var cols =inputs.split('/n')[0].split(' ').map(Number);
  var array = cols.sort(function(a,b){
    return a-b;
  })
  console.log(array.join(' '));


  
 
  
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7640
#include <stdio.h>

int dp[40010];

int main(){
	int n;
	scanf("%d",&n);
	dp[0]=1;
	while(n--){
		int t;
		scanf("%d",&t);
		for(int i=40000;i>=t;i--)dp[i]|=dp[i-t];
	}
	scanf("%d",&n);
	while(n--){
		int t;
		scanf("%d",&t);
		puts(dp[t]?"yes":"no");
	}
}


Measured memory_bytes: 2084
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	dict := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := readString()
		dict[s]++
	}

	max := 0
	maxKey := make([]string, 0)
	for k, v := range dict {
		if v > max {
			maxKey = make([]string, 0)
			maxKey = append(maxKey, k)
			max = v
		} else if v == max {
			maxKey = append(maxKey, k)
		}
	}
	sort.Strings(maxKey)
	for _, v := range maxKey {
		fmt.Println(v)
	}
}


Measured memory_bytes: 28544
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    bool fl;
    string ans="No";
    rep(i,n){
        fl=true;
        rep(j,n){
            //cout<<s[(i+j)%n];
            if (s[(i+j)%n]!=t[j]){
                fl=false;
            }
        }
        if(fl==true){
            ans="Yes";
        }
    }
    cout<<ans;
}






Measured memory_bytes: 256
/*input
7 5
1 2 3 4 5 6 7
3 0
4 0
1 2
1 3
5 6
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 100900
#define INF 0x3f3f3f3f

int n , m , x[MAX] , u[MAX];
vector<int> v[MAX];
void DFS(int now , vector<int> &sol){
	sol.pb(x[now]) , u[now] = 1;
	for(auto to : v[now]) if(u[to] == 0) DFS(to , sol);
}
int32_t main(){
	IOS;
	cin >> n >> m;
	if(m == n - 1) return cout << 0 << endl , 0;
	REP(i , 0 , n) cin >> x[i];
	REP(i , 0 , m){
		int a , b;
		cin >> a >> b;
		v[a].pb(b) , v[b].pb(a);
	}
	vector<int> all;
	int ans = 0 , siz = 0;
	REP(i , 0 , n) if(u[i] == 0){
		vector<int> sol;
		DFS(i , sol) , siz ++;
		sort(ALL(sol));
		ans += sol[0];
		REP(j , 1 , sol.size()) all.pb(sol[j]);
	}
	int need = (n - 1 - m) * 2 - siz;
	if(need > all.size()) return cout << "Impossible" << endl , 0;
	else {
		sort(ALL(all));
		REP(i , 0 , need) ans += all[i];
		cout << ans << endl;
	}
    return 0;
}

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

using namespace std;

#define REP(i, x, y) for (int i = x;i < y; i++)

const int8_t  INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF  = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
    ios::sync_with_stdio(0);
    int64_t n,ans=0;
    cin >> n;
    for (int i=1;i<=sqrt(n)+1;i++)
    {
        if (n%i==0)
        {
            if (n/i-1<=0) continue;
            if (n/(n/i-1)==n%(n/i-1))
            {
                ans+=n/i-1; 
                //cout << n/i-1 << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    int n; cin>>n;
    bool flag = true;
    while(n--){
        int c; cin>>c;
        if(c%2==0){
            if(c%3 && c%5) flag = false;
        }
    }
    if(flag) puts("APPROVED");
    else puts("DENIED");
    return 0;
}

Measured memory_bytes: 256
solve a b = [x | x <- [1..(min a b) + 1], mod a x == 0 && mod b x == 0]

parseInput input = map read $ words input :: [Int]

main = do
    line <- getLine
    let [a, b, k] = parseInput line
    let lst = reverse(solve a b)
    print $ lst !! (k - 1)


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,h;cin>>a>>b>>h;

  out((a+b)*h/2.0);


  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

// vector<vector<int>> data(3, vector<int>(4));

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

  int n;
  cin >> n;

  if(n>=30){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define reps(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) for(int i=0;i<int(b);i++)
#define first ff
#define second ss
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
#define M 998244353
int main()
{
    csl;
    int n,m;
    cin >> n >> m;
    int sum = 0;
    int a[m];
    rep(i,m)
    {
        cin >> a[i];
    }

    rep(i,m)
    {
        sum+=a[i];
    }

    int x = n-sum;
    if(x < 0)
        cout << -1 << endl;
    else
        cout << x << endl;
}


Measured memory_bytes: 3624
w=input()
l=[]
c=0
for i in w:
  l.append(i)
l.sort()
if len(l)<2:
  print('No')
  exit()
for k in range(len(l)-1):
  if l[k]==l[k+1]:
    c+=1
  elif c%2==1:
    c=0
    continue
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int N, K, p[1001];
  int i, j;
  int tmp, ans = 0;

  scanf("%d %d", &N, &K);
  for(i = 0; i < N; ++i){
    scanf("%d", &p[i]);
  }
  for(i = 0; i < N; ++i){
    for(j = i +1; j < N; ++j){
      if(p[i] > p[j]){
        tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  for(i = 0; i < K; ++i){
    ans = ans +p[i];
  }
  printf("%d", ans);
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int  b[10000009];
ll ans=0;
int main(){
	long double n,k;
    cin >> n >> k;
    long double count = 0;
    for (long double i = 1; i <= n; ++i)
    {
    	if(i < k)
    	{
    		count += (1/n) * pow(0.5,ceil(log2(k/i)));
    	}
    	else
    		count += (1/n);
    }
    cout << fixed << setprecision(10) << count;
    return 0;
}

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

int main()
{
    string s ;
    cin >> s ;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5))
    {
        cout << "Yes" << endl ;
    }
    else
    {
        cout << "No" << endl ;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  char s[1001],t[1001];
  scanf("%s", s);
  scanf("%s", t);
  int len;
  for(len=0; s[len]!='\0'; ++len);
  for (int i=0; i<len; i++) {
    bool same = true;
    for (int j=0; j<len; j++) {
      int pivot=j+i;
      if (pivot>=len) pivot -= len;
      if (s[j] != t[pivot]) same = false;
    }
    if (same) {
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");

  return 0;
}


Measured memory_bytes: 256