akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
string s;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int N = s.size();
  int ans = N;
  REP(i, N - 1){
    if(s[i] != s[i + 1]) ans = min(ans, max(i + 1, N - i - 1));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Dracarys ios_base::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()

inline void fileIO(bool &ptime){ 
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);ptime=true;
    #endif
}

clock_t start_time;
inline double getTime(){ return ((double)(clock()-start_time)/CLOCKS_PER_SEC); }


const int mxn = 2*1e5+5;
ll n;
inline void solve(ll tt){
    cin>>n;
    vector<array<ll,2>> edg;
    for (ll u,v,i=0;i<n-1;i++){
        cin>>u>>v;
        edg.pb({min(u,v),max(u,v)});
    }
    ll cnt=0;
    for (ll i=1;i<=n;i++){
        cnt+=(i*(i+1))/2;
    }
    for (auto &ed:edg){
        cnt-=((ed[0])*(n-ed[1]+1));
    }
    cout<<cnt<<"\n";
}

int main(){
        
    srand((unsigned)time(0));

    bool ptime=false;
    fileIO(ptime);
    start_time=clock();

    Dracarys

    ll tt=0,t=1;
    //cin>>t;

    while(t--){solve(++tt);}

    if (ptime)
    cerr<<getTime()<<endl;

    return 0;
}

Measured memory_bytes: 7488
N = int(input())
List = [int(input()) for i in range(N)]
count = 1
i = 0
while True:
  if List[i] == 2 or count == N:
    break
  else:
    count += 1
    i = List[i] -1

if count == N:
  print(-1)
else:
  print(count)

Measured memory_bytes: 49240
import string

N = int(input())
s = str(input())

alphabet = string.ascii_lowercase
num_list = []

for i in range(N):
    count_alphabet = [0 for k in range(len(alphabet))]
    first = s[i:]
    end = s[:i]
    for j in first:
        if j in end:
            count_alphabet[alphabet.index(j)] = 1
    num_list.append(count_alphabet.count(1))

print(max(num_list))

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
    cin>>s1>>s2;
    int ans = 0;
    for(int i=0;i<3;i++)
    {
        if(s1[i]==s2[i])
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N, K, = input().split()
    A = [int(i) for i in input().split()]
    N, K = int(N), int(K)

    for i in range(N-K):
        if A[i] < A[K+i]:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 94188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int a = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'a') {
            if (a+b < A+B) {
                a++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (S[i] == 'b') {
            if (a+b < A+B && b < B) {
                b++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 848
import java.util.*;

class Main{

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

	int n,m;
	int[] A = new int[100];
	int[] C = new int[100];
	int[] P = new int[100];
	int[] F = new int[100];

	while(true)
	    {
		n = in.nextInt();
		m = in.nextInt();
		if(n == 0 && m == 0)break;
		for(int i=0;i<3;i++)
		{
		    int ph;
		    ph = in.nextInt();
		    for(int j=0;j<ph;j++)
			{
			    int in2;
			    in2 = in.nextInt();
			    F[in2] = i;
			}
		    
		}

		P[n] = 2;
		A[n] = F[n];
		C[n] = 2 - F[n];


		for(int i=n;i>1;i--)
		    {
			//P[i]ÌÈºÌ®ÍvZÌÊÅÄ«½àÌ
			//àµãÉQÂÌRbvª éÆ«
			//»êð½Î¤ÉÁÄ¢­ÉÍWñ®©·
			//RÂRbvª éÍQUñ
			//PÂÌÍQñ
			//Í¢A ÆÍvZ
			//habukuyo
			//iRbvªQÂÈãÌÉpÂ\j
			P[i-1] = 3*P[i] + 2;
			if(F[i-1] == 0)
			    {
				A[i-1]=A[i]; //à¤ùÉAÉ éÌÅ»êÜÅÌñiA[i]jðãüµÄI¹
				C[i-1]=C[i]+2*P[i]+2;//CÌ»êÜÅÌñ(C[i])Æ¡CÉ éRbvðAÉ®©µÄßµÄ­éñi2*P[i]jÆÚIÌJbvÌÚ®ñ(2)ðÁ¦½àÌðãü
			    }
			else if(F[i-1] == 1)
			    {
				//®©µ½¢Jbvª^ñÉ éêÅ
				//©ÂAÉàÁÄ¢«½¢ÉÍA
				//AÉ éàÌð·×ÄCÉÚ®³¹
				//ÚIÌJbvðAÉÚ®³¹I¹
				//CÉÚ®³¹½ÌÍAÉß³È¢
				//tà¯¶æ¤É·é
				A[i-1] = C[i] + P[i] + 1;
				C[i-1] = A[i] + P[i] + 1;
			    }
			else if(F[i-1] == 2)
			    {
				A[i-1] = A[i] + 2*P[i] + 2;
				C[i-1] = C[i];
			    }
			
			
		    }
	
		int ans = Math.min(A[1],C[1]);
		if(m < ans) System.out.println("-1");
		else System.out.println(ans);	
		
		
	}
	
	
	
    }
    
    
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in<ll>();
	vector<int> C(1,1);
	int V=6;
	while(V<=N){
		C.push_back(V);
		V*=6;
	}
	V=9;
	while(V<=N){
		C.push_back(V);
		V*=9;
	}

	int M=C.size();
	vector<int> dp(N+1,1<<30);
	dp[0]=0;
	
	REP(i,M){
		REP(j,N+1){
			if(j-C[i]>=0) chmin(dp[j],dp[j-C[i]]+1);
		}
	}

	out(dp[N]);
	return 0;
}


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

#define LL long long
#define ULL unsigned long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 3e5 + 20;
const double pi = (double) acos(-1.0);

void work()
{
    string s;
    cin >>s;
    int a = (s[0] - '0') * 10 + s[1] - '0';
    int b = (s[2] - '0') * 10 + s[3] - '0';

    int flag = 0;
    if(1 <= a && a <= 12) flag++;
    if(1 <= b && b <= 12) flag++;

    if(flag == 0) cout <<"NA" <<endl;
    if(flag == 2) cout <<"AMBIGUOUS" <<endl;
    if(flag == 1)
    {
        if(1 <= a && a <= 12) cout <<"MMYY" <<endl;
        else cout <<"YYMM" <<endl;
    }
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

int main()
{
	int n; cin >> n;
	vector<int>A(n);
	for (int i = 0; i < n; i++)cin >> A[i];

	int type;
	if (A[1] > A[0])type = 1;
	else if (A[1] < A[0])type = 2;
	else type = 3;
	int cnt = 1;
	for (int i = 0; i < n-1; i++) {
		if (type == 1 && A[i] > A[i + 1]) {
			cnt++;
			type = 3;
		}
		else if (type == 2 && A[i] < A[i + 1]) {
			cnt++;
			type = 3;
		}
		else if (type == 3) {
			if (A[i+1] > A[i])type = 1;
			else if (A[i+1] < A[i])type = 2;
			else type = 3;
		}
	}
	
	cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 764
n = int(input())
D = [0] + sorted(list(map(int, input().split())))
E = [D[i] if i%2 else 24-D[i] for i in range(n+1)]
ans = float("inf")
for i in range(n):
  for j in range(i+1, n+1):
    k = (E[i]-E[j])%24
    ans = min(ans, min(k, 24-k))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v,vans;
vp p[100010];
string s;
ll solve(void){
    if(a>12)return b;
    if(a>5)return b/2;
    return 0;
}
int main(){
    cin>>a>>b;
    cout<<solve()<<endl;
}

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

int main(){
    int a,b,i;
    cin >> a >> b;
    string s;
    cin >> s;
    for(i=0;i<a+b+1;i++){
        if(i==a){
            if(s[i]!='-'){
                cout << "No" << endl;
                break;
            }
        }else{
            if(!(s[i]-'0'>=0 && s[i]-'0'<=9)){
                cout << "No" << endl;
                break;
            }
        }
    }
    if(i==a+b+1){
        cout << "Yes" << endl;
    }
    return 0;
}
    

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

cnt = Counter()
for line in stdin:
    blood = line.strip().split(',')[1]
    cnt[blood] += 1

for blood in ('A', 'B', 'AB', 'O'):
    print(cnt[blood])

Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i, n){
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;
using dou = double;

int main() {
    dou T, Y;
    cin >> T >> Y;
    cout << T / Y << setp(4) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_3_C-in10.txt"));
		// while (scan.hasNext()) {

		int n = scan.nextInt();
		Slist s = new Slist(n);
		for (int i = 0; i < n; i++)
			s.add(scan.nextInt());
		int q = scan.nextInt();
		int cnt = 0;
		for (int i = 0; i < q; i++)
			if (s.isExist(scan.nextInt()))
				cnt++;
		System.out.println(cnt);
		scan.close();
		System.exit(0);
	}
}

class Slist {
	List<Integer> list = new ArrayList<Integer>();
	boolean sorted = false;

	public Slist(int n) {
		// TODO Auto-generated constructor stub
	}

	public boolean isExist(int e) {
		if (!sorted) {
			Collections.sort(list, null);
			sorted = true;
		}
		return this.bsearch(e, 0, list.size() - 1);
	}

	private boolean bsearch(int e, int min, int max) {
		if (min > max)
			return false;
		int mid = (max + min) / 2;
		if (list.get(mid) > e)
			return bsearch(e, min, mid - 1);
		else if (list.get(mid) == e)
			return true;
		else
			return bsearch(e, mid + 1, max);
	}

	public void add(int e) {
		list.add(e);
	}

}

Measured memory_bytes: 41464
//abc052_b.cpp
//Sun Oct 21 19:57:36 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int num = 0;
	int ans = 0;
	for (int i=0;i<s.size();i++){
		if (s[i] == 'I'){
			num++;
		}else if (s[i] == 'D'){
			num--;
		}
		if (num > ans){
			ans = num;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N;cin>>N;
  std::vector<int> x(N),y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  typedef pair<int,int> P;
  map<P,int> m;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int a=x[i]-x[j];
      int b=y[i]-y[j];
      if(a<0){a*=-1;b*=-1;}
      if(a==0)b=abs(b);
      m[P(a,b)]++;
    }
  }
  int ma=0;
  for(auto p:m)ma=max(ma,p.second);
  cout<<N-ma<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

ll digit(ll a) {
    ll ret = 0;
    while(a > 0) {
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

int H,W;
int red[88][88];
int blue[88][88];
bool dp[88][88][12800]; //dp[i][j][k] = (i,j)までに偏りをkにすることが出来るかどうか

int main() {
    cin >> H >> W;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> red[i][j];
        }
    }
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> blue[i][j];
        }
    }
    for(int i = 0;i < 88;i++) {
        for(int j = 0;j < 88;j++) {
            for(int k = 0;k < 12800;k++) {
                dp[i][j][k] = false;
            }
        }
    }
    dp[0][0][abs(red[0][0] - blue[0][0])] = true;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            for(int k = 0;k < 12800;k++) {
                if(i > 0) {
                    dp[i][j][k + abs(red[i][j] - blue[i][j])] |= dp[i - 1][j][k];
                    dp[i][j][abs(k - abs(red[i][j] - blue[i][j]))] |= dp[i - 1][j][k];
                }
                if(j > 0) {
                    dp[i][j][k + abs(red[i][j] - blue[i][j])] |= dp[i][j - 1][k];
                    dp[i][j][abs(k - abs(red[i][j] - blue[i][j]))] |= dp[i][j - 1][k];
                }
            }
        }
    }
    for(int i = 0;i < 12800;i++) {
        if(dp[H - 1][W - 1][i] == true) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 100492
def gcd(a,b):
	x,y = min(a,b), max(a,b)
	while x*y>0:
		x,y = y%x,x
	return y

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
p,q=M//g,N//g
print((N//g)*M) if S[0::q]==T[0::p] else print('-1')

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

int main() {
    long n;
    cin >> n;

    vector<long> p(n);
    rep(i,n) {
        cin >> p.at(i);
    }

    long count=1;
    long min=p.at(0);
    for (long i=1; i<n; ++i) {
        if (min>p.at(i)) {
            min=p.at(i);
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}

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

int main() {
   int N;
   cin >> N;
   int A[N],B[N],C[N];
   for (int i=0; i<N; i++) {
      cin >> A[i];
   }
   for (int i=0; i<N; i++) {
      cin >> B[i];
   }
   for (int i=0; i<N; i++) {
      cin >> C[i];
   }
   sort(A,A+N);
   sort(B,B+N);
   sort(C,C+N);
   long long total=0;
   for (int i=0; i<N; i++) {
      long long counta=0,countc=0;
      counta=lower_bound(A,A+N,B[i])-A;
      if (B[i]<C[N-1]) countc=N-(upper_bound(C,C+N,B[i])-C);
      total+=counta*countc;
   }
   cout << total << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll s;
  cin >> s;
  ll a = sqrt(s), b = a;

  if (a * b < s) {
    a += 1;
  }
  if (a * b < s) {
    b += 1;
  }

  ll x1 = 0, y1 = 0, x2 = a, y2 = 0, x3 = a, y3 = b;
  if (a * b > s) {
    ll r = (a * b) - s;
    assert(r <= 1e9);
    y2 = 1;
    x3 = r;
  }
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl; 
}


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

using namespace std;

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

    if(N%2 == 1) cout << "No" << endl;

    else{
        int M = N/2;
        string a;
        cin >> a;
        bool flag = true;
        for(int i = 0; i < M;i++)
        {
            if(a.at(i) != a.at(i + M)){
                flag = false;
            }
        }

        if(flag) cout << "Yes" << endl; 
        else cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
package main

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

var S string

func main() {
	S = nextString()
	one := 0
	zero := 0
	for i := 0; i < len(S); i++ {
		if string(S[i]) == "1" {
			one += 1
		} else {
			zero += 1
		}
	}
	fmt.Printf("%v", MinIn2Values(one, zero)*2)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long n = sc.nextLong();
    long ans = 0;
    if(n >= (b - 1)) {
      ans = (a * (b - 1)) / b;
    } else {
      ans = (a * n) / b - a * (n / b); 
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35676
#include<stdio.h>
int g[20][20];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			g[i][j]=99999999;
	for(int i=0;i<b;i++){
		int c,d,e,f;
		scanf("%d,%d,%d,%d",&c,&d,&e,&f);
		g[c-1][d-1]=e;
		g[d-1][c-1]=f;
	}
	int c,d,e,f;
	scanf("%d,%d,%d,%d",&c,&d,&e,&f);
	for(int k=0;k<a;k++)
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				if(g[i][j]>g[i][k]+g[k][j])g[i][j]=g[i][k]+g[k][j];
	printf("%d\n",e-f-g[c-1][d-1]-g[d-1][c-1]);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n,a;
    string s;
    cin >> n >> a;
    if (n==a) cout << "Yes" << endl;
    else cout << "No"<< endl;
    
    return 0;
}


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

vector<long long> altura;

long long dp[100005];
int n, k;
long long solve(int atual){
    if(dp[atual] != -1) return dp[atual];
    if(atual == n-1) return 0;
    
    long long res = 1000000000000000000;
    for(int i = atual + 1; i <= atual + k; i++){
        if(i >= n) break;
        res = min(abs(altura[atual] - altura[i]) + solve(i), res);
    }
    dp[atual] = res;
    return dp[atual];
}

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        long long v;
        cin >> v;
        altura.push_back(v);
        dp[i] = -1;
    }
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 9716
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int K, A, B, C;
	int ans = 0;
	
	cin>>A>>B>>C>>K;
	
	ans += min(K, A);
	K -= min(K, A);
	
	K -= min(K, B);
	
	ans -= min(K, C);
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3216
import Data.Functor ((<$>))

grade :: Int -> Int -> Int -> String
grade m f r
  | m == -1 || f == -1 = "F"
  | m + f < 30         = "F"
  | m + f < 50         = if r >= 50 then "C" else "D"
  | m + f < 65         = "C"
  | m + f < 80         = "B"
  | otherwise          = "A"

main :: IO ()
main = do
  [m, f, r] <- map read . words <$> getLine
  if m == (-1) && f == (-1) && r == (-1)
    then return ()
    else putStrLn (grade m f r) >> main



Measured memory_bytes: 4112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  double p[N];
  REP(i,N)cin>>p[i];
  double dp[N+1][N+1];
  REP(i,N+1)REP(j,N+1)dp[i][j]=0.0;
  dp[0][0]=1.0;
  FOR(i,1,N+1)REP(j,N+1){
    dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
    if(j>0)dp[i][j]+=dp[i-1][j-1]*p[i-1];
  }
  double ans=0;
  FOR(i,N/2+1,N+1)ans+=dp[N][i];
  //固定小数点
  cout<<fixed;
  //桁数固定
  cout<<setprecision(12);
  cout<<ans<<endl;
  // REP(i,N+1){
  //   REP(j,N+1)cerr<<dp[i][j]<<" ";
  //   cerr<<endl;
  // }
  return 0;
}


Measured memory_bytes: 70528
module Main where

import Control.Applicative
import Control.Monad
import Data.Function
import Data.List
import Data.Maybe

getK :: Int -> Maybe Int
getK n = get 0
    where get k | ss < 2 * n = get (k + 1)
                | ss == 2 * n = Just k
                | otherwise = Nothing
                where ss = k * (k - 1)

solve :: Int -> Maybe [[Int]]
solve n = getK n >>= gen
    where gen k = Just . map (map snd) . groupBy ((==) `on` fst) $ sort vs
              where is = [i | i <- [1 .. k], j <- [i + 1 .. k]] :: [Int]
                    js = [j | i <- [1 .. k], j <- [i + 1 .. k]] :: [Int]
                    vs = (zip is [1 .. n]) ++ (zip js [1 .. n])

main :: IO ()
main = do
  n <- read <$> getLine
  case (solve n) of
    Just ss -> do putStrLn "Yes"
                  print $ length ss
                  forM_ ss $ \s -> do
                    putStrLn . unwords . map show $ (length s):s
    Nothing -> putStrLn "No"


Measured memory_bytes: 45564
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
const int MOD = 1e9 + 7;
void mod(int &x) { 
	if (x < 0) x += MOD;
	else if (x >= MOD) x -= MOD;
}
void mod(ll &x) { x %= (ll)MOD; }
const int mxN = 1e5 + 5;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef _DEBUG
	int tt = clock();
	// freopen("in.txt", "r", stdin);
#endif 
	int n, k;
	cin >> n >> k;
	vector<int> dp(k + 1);
	dp[0] = 1;
	for (Rint child = 0; child < n; ++child) {
		int up_to; cin >> up_to;
		//prefix sum
		vector<int> lz(k + 1);
		for (Rint used = k; used >= 0; --used) {
			int L = used + 1;
			int R = used + min(k - used, up_to);
			if (L <= R) {
				lz[L] += dp[used]; mod(lz[L]);
				if (R + 1 <= k) {
					lz[R+1] -= dp[used]; mod(lz[R+1]);
				}
			}
	
			//for (Rint i = L; i <= R; ++i) {
			//	dp[i] = mod(dp[i] + dp[used]);
			//}
		}
		int prefix_sum = 0;
		for (int i = 0; i <= k; ++i) {
			assert(dp[i] < MOD && dp[i] >= 0);
			prefix_sum += lz[i]; mod(prefix_sum);
			dp[i] += prefix_sum; mod(dp[i]);
		}
	}
	cout << dp[k] << endl;

#ifdef _DEBUG
	cerr << "\nTIME = " << clock() - tt << endl;
	tt = clock();
#endif

	return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << 'x';
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
a =list(map(int, input().split()))

cnt = 0
min_val = abs(a[0])
for it in a:
    if abs(it) < min_val:
        min_val = abs(it)
    
    if it < 0:
        cnt+=1
        
abs_list = list(map(abs, a))
if cnt%2 == 0:
    print(sum(abs_list))
else:
    print(sum(abs_list) - 2*min_val)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,A,B;
  cin>>N>>A>>B;
  ll x=A,y=B;
  A=min(x,y);
  B=max(x,y);
  if((B-A)%2==0){cout<<(B-A)/2<<endl;}
  else{
    ll wayto1=(A-1+B-1+1)/2;
    ll waytoN=(N-A+N-B+1)/2;
    cout<<min(wayto1,waytoN)<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

long long int gcd(long long int a, long long int b) {
  long long int r;
  if (a < b) {
    long long int tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(void) {
  long long int a,b,mgcd,ans = 0;
  
  scanf("%lld %lld",&a,&b);
  mgcd = gcd(a, b);
  for (long long int i = 2; i*i <= mgcd; i++) {
    if (mgcd%i == 0) {
      ans++;
      while (mgcd%i == 0) {
        mgcd /= i;
      }
    }
  }
  if(mgcd > 1) ans++;
  ans++;
  printf("%lld\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
def solve():
    from collections import deque
    h, w, k = map(int, input().split())
    maze = [input() for _ in range(h)]
    visited = [[-1]*w for j in range(h)]
    for i in range(h):
        if 'S' in maze[i]:
            sy, sx = i, maze[i].index('S')
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    r = 10**18
    while queue:
        y, x = queue.popleft()
        r = min(r, y, x, h-1-y, w-1-x)
        if visited[y][x] == k: continue
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if new_y < 0 or new_y >= h: continue
            if new_x < 0 or new_x >= w: continue
            if maze[new_y][new_x] == '.' and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    print(1 -(-r // k))
if __name__ == '__main__':
    solve()

Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
	int n;
	scanf("%d",&n);
	int a;
	unordered_map<int,int> m;
	for(int i=0;i<n;++i){
		scanf("%d",&a);
		++m[a];
	}
	printf("%d",m.size()-(m.size()+1)%2);
	return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0)
    {
        cout << b / x + 1 << endl;
    }
    else
    {
        cout << b / x - (a - 1) / x << endl;
    }
    return 0;
}

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

using namespace std;

#define N 1000

bool isprime[N];
int main(){
    vector<int> ans(N+1);
    for (int i = 1; i <= 500; i++) {
        for (int j = i; j <= 500; j++) {
            if (i==j) continue;
            int tmp = 0;
            for (int k = i; k <= j; k++) {
                tmp += k;
            }
            if (tmp <= N) {
                ans[tmp] += 1;
            }
        }
    }
    int n;
    while (cin >> n, n) {
        cout << ans[n] << endl;
    }
    /*
    for (int i = 0; i < N; i++) { isprime[i] = 1;}
    isprime[0] = isprime[1] = 0;
    isprime[2] = 1;
    for (int i = 2; i < N; i++) {
        if (!isprime[i]) continue;
        for (int j = 2*i; j < N; j += i) {
            isprime[j] = 0;
        }
    }
    vector<int> plist;
    for (int i = 2; i < N; i++) {
        if (isprime[i]) plist.push_back(i);
    }

    int n;
    while (cin >> n, n) {
        int res = 0;
        if (n%2) res++;
        vector<int> pn;
        while (n>=2) {
            for (int i = 0; i < plist.size(); i++) {
                if (!(n % plist[i])) { 
                    n /= plist[i]; 
                    pn.push_back(plist[i]);
                    i = 0;
                }
            }
        }
        int oddn = 0;
        for (int i = 0; i < pn.size(); i++) {
            if (pn[i]%2) oddn++;
        }
    }
    */
    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>
#define inf 10e8

int compare(const void *a, const void *b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  int i, j, n, k;
  scanf("%d%d", &n, &k);
  int a, cou[n + 1], in = inf, now = 0, ans = 0;
  for(i = 0; i <= n; ++i) cou[i] = inf;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(cou[a] == in) cou[a] = 1, now++;
    else cou[a]++;
  }
  qsort(cou, n + 1, sizeof(int), compare);
  for(i = 0; i < now - k; ++i) ans += cou[i];
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1660
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if((a-b)%2) puts("IMPOSSIBLE");
	else printf("%d\n", a - (a-b)/2);
	return 0;
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)




int main(){
    ll N;
    cin>>N;
  
  cout<<2*N*PI<<endl;
  return 0;
}



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

int m, n;
pair<int, int> sample[200], star[1000];
int main()
{
  while(cin >> m && m){
    for(int i = 0; i < m; i++)
      cin >> sample[i].first >> sample[i].second;

    cin >> n;
    for(int i = 0; i < n; i++)
      cin >> star[i].first >> star[i].second;

    sort(sample, sample + m);
    sort(star, star + n);

    for(int i = 0; i < n; i++){
      pair<int, int> vec = make_pair(star[i].first - sample[0].first, star[i].second - sample[0].second);
      int searching = 0;
      pair<int, int> target = make_pair(sample[0].first + vec.first, sample[0].second + vec.second);
      bool flag = false;
      for(int j = 0; j < n; j++){
	if(target == star[j]){
	  searching++;
	  if(searching == m){
	    flag = true;
	    break;
	  }
	  target = make_pair(sample[searching].first + vec.first, sample[searching].second + vec.second);
	}
	if(target < star[j])
	  break;
      }
      if(flag){
	cout << vec.first << " " << vec.second << endl;
	break;
      }
    }
  }
  return 0;
}

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



int main(){
    int N, K;cin >> N >> K;
    set<int> se;
    for(int i = 0;i < K;i++){
        int d;cin >> d;
        for(int j = 0;j < d;j++){
            int a;cin >> a;
            se.insert(a);
        }
    }
    cout<<N - se.size()<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;};
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(D[u]==0) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r,p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child;
      else T[sib].r = child;
      sib = child;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  calcDepth(root, 0);

  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using LL=long long;

int main(){
 int MOD=1000000007;
  int N;
  LL ans = 0;
  LL sum=0,suma;
  
  cin >> N;
  vector<LL>vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  
  for(int i=0;i<N-1;i++){
    sum-=vec.at(i);
    suma=sum%MOD;
    ans+=vec.at(i)*suma;
    ans=ans%MOD;
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 4804
#include <iostream>
#include <array>
#include <cmath>
#include <vector>

constexpr int kMax = 1e+8;
constexpr int kSqrtMax = 1e+4;
std::array<bool, kSqrtMax+1> primes;

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

    std::fill(primes.begin(), primes.end(), true);
    int n;
    std::cin >> n;
    primes.at(1) = false;
    for(int i=2; i<static_cast<int>(primes.size()); ++i){
        if(!primes.at(i))
            continue;
        int p = i + i;
        while(p < static_cast<int>(primes.size())){
            primes.at(p) = false;
            p += i;
        }
    }
    std::vector<int> prime_numbers;
    prime_numbers.reserve(1e+2);
    for(int i=2; i<=kSqrtMax; ++i)
        if(primes.at(i))
            prime_numbers.push_back(i);
    
    int sum = 0;
    for(int i=0; i<n; ++i){
        int temp;
        std::cin >> temp;

        bool is_prime = true;
        for(int p : prime_numbers){
            if(p > std::sqrt(temp))
                break;
            if(temp % p == 0){
                is_prime = false;
                break;
            }
        }
        if(is_prime)
            sum += 1;
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

int main(){
  rep(i,365) cout << i%26+1 << endl;
  return 0;
}


Measured memory_bytes: 3668
n = int(input())
h = list(map(int, input().split()))[::-1]
if n ==1:
    print('Yes')
else:
    for i in range(1,n):
        if h[i] > (h[i - 1] + 1):
            print('No')
            break
        elif h[i] == (h[i - 1] + 1):
            h[i] = h[i - 1]
    else:
        print('Yes')


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

int main() {
    int H;
    int W;
    char **s;
    bool judge = true;
    scanf("%d%d", &H, &W);
    s = new char*[H];
    for(int i = 0;i < H;i++) {
        s[i] = new char[W];
    }
    scanf("%*c");
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            scanf("%c", &s[i][j]);
        }
        scanf("%*c");
    }

    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if(s[i][j] == '.') {
                continue;
            }
            int count = 1;
            if(i != 0) {
                count += s[i - 1][j] == '#' ? 1 : 0;
            }
            if(j != 0) {
                count += s[i][j - 1] == '#' ? 1 : 0;
            }
            if(i != H - 1) {
                count += s[i + 1][j] == '#' ? 1: 0;
            }
            if(j != W - 1) {
                count += s[i][j + 1] == '#' ? 1: 0;
            }
            judge = judge && 1 < count;
        }
    }

    if(judge) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

int main(void){
  char s[101], t[101];
  char buf[203];

  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%s %s", s, t);
  printf("%s%s\n", t, s);

  return 0;
}


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

using namespace std;
using ll = long long;

template<class M> class DualSegmentTree {
public:
	using T = typename M::value_type;
private:
	ll m;
	ll n;
	vector<T> data;

	void rec(ll l, ll r, ll node, ll node_l, ll node_r, const T& val) {
		if(node_r <= l || node_l >= r)return;
		if(node_l >= l && node_r <= r){data[node] = M::upd(data[node], val); return;}
		ll mid = (node_l + node_r) / 2;
		rec(l, r, node * 2, node_l, mid, val);
		rec(l, r, node * 2 + 1, mid, node_r,val);
	}

public:
	DualSegmentTree(vector<T> a) {
		m = a.size();
		for(n = 1; n < (ll)a.size(); n <<= 1);
		data.resize(n<<1, M::id);
		for(ll i = 0; i < (ll)a.size(); i++)data[i + n] = a[i];
	}
 
	void update(ll l, ll r, T val) {
		rec(l, r, 1, 0, n, val);
	}
 
	T get(ll index) {
		T ret = data[index += n];
		while(index /= 2) {
			ret = M::op(ret, data[index]);
		}
		return ret;
	}
 
	T operator[] (ll i){
		return data[i + n];
	}
};

//区間chmin・一点取得
template<class T> class RchMinQ {
public:
	using value_type = T;
	static T op(T l, T r){return min(l, r);}
	static T upd(T node, T val){return min(node, val);}
	static constexpr T id = 1e9;
};template <class T> constexpr T RchMinQ<T>::id;

/*********************************/
template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(ll i = 0; i < (ll)arr.size(); i++)os << arr[i] << (i == (ll)arr.size() - 1 ? "]" : ",");os << endl;return os;}
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A,B>& p){os << "{" << p.first << "," << p.second << "}";return os; }
#define prvec(v) cerr<<#v<<": [";for(ll __i = 0;__i < (ll)(v).size(); __i++)cerr<<((v)[__i])<<(__i+1==(ll)(v).size()?"]\n":",");
#define print(x) cerr<<#x<<": "<<(x)<<endl
/*********************************/

int main()
{
	ll n, Q; cin >> n >> Q;
	DualSegmentTree<RchMinQ<ll>> vert(vector<ll>(n, n - 1));
	DualSegmentTree<RchMinQ<ll>> side(vector<ll>(n, n - 1));
	ll sum = 0;


	while(Q--) {
		ll h, w; cin >> h >> w; h--, w--;
		ll num;
		if(h == 0) {
			num = side.get(w);
			sum += num - 1;
			vert.update(0, num, w);
		} else {
			num = vert.get(w);
			sum += num - 1;
			side.update(0, num, w);
		}
	}


	cout << (ll)(n - 2) * (n - 2) - sum << endl;

}

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

int main(void) {
  int n;
  long long k;
  int a[200000], visited[200000];
  
  cin >> n >> k;
  
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    visited[i] = -1;
  }
  
  int loop = 0;
  int town = 0;
  int pre = 0;
  for(int i = 0; i < n; i++) {
    if(visited[town] >= 0) {
      loop = i - visited[town];
      pre = i;
      break;
    } else {
      visited[town] = i;
      town = a[town]-1;
    }
  }
  
  if(k > pre) {
    int rest = (k-pre) % loop;
    for(int i = 0; i < rest; i++) {
      town = a[town]-1;
    }
  } else {
    town = 0;
    for(int i = 0; i < k; i++) {
      town = a[town]-1;
    }
  }
  cout << town+1 << endl;
  
  return 0;
}

Measured memory_bytes: 5168
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def bs(a, v):
    ok = len(a)
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if a[mid] > v:
            ok = mid
        else:
            ng = mid
    return ok


def main():
    N = readi()
    A = sorted(readi(N))
    B = sorted(readi(N))
    C = sorted(readi(N))
    ab = [bs(B, a) for a in A]
    bc = [bs(C, b) for b in B]
    bcount = [N - bc[i] for i in range(N)]
    bcum = arr(N + 1)
    for i in range(N - 1, -1, -1):
        bcum[i] = bcum[i + 1] + bcount[i]
    ans = 0
    for i in range(N):
        ans += bcum[ab[i]]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 102492
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int> (W)), B(H, vector<int> (W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> A[i][j];
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> B[i][j];
    }
    vector<vector<int>> C(H,vector<int> (W));
    int M = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            C[i][j] = abs(A[i][j] - B[i][j]);
            M = max(M, C[i][j]);
        }
    }
    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(M * (H + W) + 1, false)));
    int t = M * (H + W) + 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i == 0 && j == 0) dp[i][j][C[i][j]] = true;
            else{
                for(int k = 0; k < t; k++){
                    if(j != 0 && dp[i][j - 1][k]){
                        dp[i][j][k + C[i][j]] = true;
                        dp[i][j][abs(k - C[i][j])] = true;
                    }
                    if(i != 0 && dp[i - 1][j][k]){
                        dp[i][j][k + C[i][j]] = true;
                        dp[i][j][abs(k - C[i][j])] = true;
                    }
                }
            }
        }
    }
    int ans = 1e9;
    for(int i = 0; i < t; i++){
        if(dp[H - 1][W - 1][i]) ans = min(ans, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13932