akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,W;cin>>n>>W;
  int w[n],v[n];
  rep(i,n)cin>>w[i]>>v[i];
  int dp[n+1][(int)1e5+1];
  rep(i,n+1) rep(j,1e5+1)dp[i][j]=1e9+7;
  dp[0][0]=0;
  rep(i,n){
    rep(k,1e5+1){
      int j=1e5-k;
      if(j<v[i])dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
    }
  }
  int ans=0;
  rep(i,1e5+1){
    int j=1e5-i;
    if(dp[n][j]<=W){
      ans=j;break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 39680
#pragma region Macros
 
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;
 
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}
template <class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}
 
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif
 
#pragma endregion
 
void Main() {
    int K, N;
    cin >> K >> N;
    vi a(N);
    cin >> a;
 
    int diff = 0;
    a.push_back(a[0] + K);
    REP(i, N) {
        chmax(diff, a[i + 1] - a[i]);
    }
    cout << K - diff;
}
 
#pragma region main
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << std::fixed;
    cout.precision(20);
    Main();
    cout << flush;
}
#pragma endregion

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
    basic_ostream<charTDummy, traitsDummy> &(
      basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read();
  vi A;
  bool isOddNum = false;
  REP(i, N) {
    A.PB(read());
    if(A[i] % 2)
      isOddNum = true;
  }
  sort(ALL(A));
  A.erase(unique(ALL(A)), A.end());

  if(A.size() == 1) {
    print(A[0]);
    return 0;
  }

  int ans = A[0], i = 0;
  while (i != A.size()) {
    if(A[i] % ans != 0) {
      ans = A[i] % ans;
      A[i] = ans;
      i = -1;
    }
    i++;
  }

  print(ans);

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, k;
vector<int> v[101010];
int cnt[101010];
//union-find
struct UnionFind {
	vector<int> par, depth, sz;
	UnionFind(int n) : par(n+1), depth(n+1), sz(n+1){
		for(int i = 0; i <= n; i++){
			par[i] = i;
			depth[i] = 0;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		sz[x] += sz[y];
		sz[y] = sz[x];
		if(depth[x] < depth[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};
////
void solve(){
	cin >> n >> m >> k;
	UnionFind uf(n+1);
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
		uf.unite(a,b);
	}
	
	for(int i = 1; i <= n; i++){
		cnt[i] = uf.size(i)-1 - v[i].size();
	}
	for(int i = 0; i < k; i++){
		int c,d;
		cin >> c >> d;
		if(uf.same(c,d)){
			cnt[c]--;
			cnt[d]--;
		}
	}
	
	for(int i = 1; i <= n; i++){
		cout << cnt[i];
		if(i != n) cout << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 8312
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	char s[10];
	int n[10];
	int a,b;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


//	scanf("%d %d",&n,&k);
//	scanf_s("%d %d",&n,&k);

	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=1;i<=n;i++){
//		scanf("%c",&a,&b,&f);
		scanf_s("%c",&a,&b,&f);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=0;i<4;i++){
		n[i]=(int)(s[i]-48);
	}

	a=n[0]*10+n[1];
	b=n[2]*10+n[3];

	if(0<a&&a<=12){
		a=1;
	}else{
		a=0;
	}

	if(0<b&&b<=12){
		b=1;
	}else{
		b=0;
	}

	//	printf("計算部分終了\n");

	//出力
	if(a==1&&b==1){
		printf("AMBIGUOUS");
	}else if(a==1&&b==0){
		printf("MMYY");
	}else if(a==0&&b==1){
		printf("YYMM");
	}else{
		printf("NA");
	}

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U){
        pr(--A, B);
    }else{
        pr(A,--B);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

//Champernowne Constant
public class Main{

	void run(){
		int S = 125000;
		int[] a = new int[S];
		int s = 0;
		for(int i=0;i<S;i++){
			a[i] = s;
			int L = 1000*i, R = L+999;
			if((L+"").length()==(R+"").length())s+=1000*(L+"").length();
			else{
				for(int k=L;k<=R;k++)s+=(k+"").length();
			}
//			System.out.println("I:"+i+" A:"+a[i]);
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int N = sc.nextInt(), K = sc.nextInt();
			if((N|K)==0)break;
			int id = 0;
			for(int i=0;i+1<S;i++){
				if(a[i]<=N&&N<a[i+1]){
					id = i; break;
				}
			}
			N-=a[id];
			StringBuilder sb = new StringBuilder();
			for(int k=1000*id;sb.length()<=N+K;k++)sb.append(k);
			System.out.println(sb.substring(N, N+K));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <string>

using namespace std;
int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    if(S[K - 1] == 'A') {
        S[K - 1] = 'a';
    }
    if(S[K - 1] == 'B') {
        S[K - 1] = 'b';
    }
    if(S[K - 1] == 'C') {
        S[K - 1] = 'c';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
import sys

l = raw_input().split()
N = int(l[0])
B = [int(b) for b in raw_input().split()]

for i in range(N):
    if B[i] > i + 1:
        print(-1)
        exit()


ret = []
i = N
while i > 0:
    found = False
    for j in range(i):
        a = i - 1 - j
        # print(i, j, a, B[a])
        if B[a] - 1 >= a:
            # print('found', j)
            ret.append(B[a])
            del B[a]
            found = True
            break
    if not found:
        print(-1)
        exit()
    i -= 1

for i in range(N):
    print(ret[N - 1 - i])


Measured memory_bytes: 2568
#include<stdio.h>
#define N 2000
int solve(int, int);
int A[N];
int n;
int main()
{
  int m;
  int q;
  int i;
  int ans=0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m);
    ans = solve(m,0);
    if(ans==0) printf("no\n");
    else  printf("yes\n");
  }

  return 0;
}

int solve(int m, int i)
{
  int res;

  if(m==0) return 1;
  if(i>=n) return 0;

  res = solve(m,i+1) || solve(m-A[i],i+1);
  return res;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fr(i, a, b) for (ll i = a; i < b; i++)

int main() {
    ios::sync_with_stdio(false);
    #ifdef CODE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    while(n--) {
        ll x, y;
        cin >> x >> y;
        double dist = sqrt(x * x + y * y);
        if (dist <= d) ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3696
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	vector< pair<double,int> > v[3];

	for(int i=0;i<24;i++){
		int id;
		double tm;
		scanf("%d%lf",&id,&tm);
		v[i/8].push_back(make_pair(tm,id));
	}

	vector< pair<double,int> >	rem;
	for(int i=0;i<3;i++){
		sort(v[i].begin(),v[i].end());
		printf("%d %.2f\n",v[i][0].second,v[i][0].first);
		printf("%d %.2f\n",v[i][1].second,v[i][1].first);
		v[i].erase(v[i].begin());
		v[i].erase(v[i].begin());
		rem.insert(rem.begin(),v[i].begin(),v[i].end());
	}

	sort(rem.begin(),rem.end());
	printf("%d %.2f\n",rem[0].second,rem[0].first);
	printf("%d %.2f\n",rem[1].second,rem[1].first);

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int ren;
		switch (s) {
		case "RRR":
			ren = 3;
			break;
		case "RRS":
		case "SRR":
			ren = 2;
			break;
		case "SSS":
			ren = 0;
			break;
		default:
			ren = 1;
			break;
		}
		
		System.out.println(ren);
		sc.close();
	}
}




Measured memory_bytes: 26928
// 2011/08/25 Tazoe



#include <iostream>

#include <climits>
#include <stack>
#include <cmath>

using namespace std;



int main()

{

	while(true){

		int n;

		cin >> n;

		if(n==0)

			break;



		int B[1000][3];

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

			cin >> B[i][0] >> B[i][1] >> B[i][2];

/*

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

			cout << B[i][0] << ' ' << B[i][1] << ' ' << B[i][2] << endl;

*/

		double D[1000][1000];

		for(int i=0; i<n; i++){

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

				double dis = sqrt((B[i][1]-B[j][1])*(B[i][1]-B[j][1])+(B[i][2]-B[j][2])*(B[i][2]-B[j][2]));

				if(dis<=50.0)

					D[i][j] = dis;

				else

					D[i][j] = 100000.0;

			}

		}


		int P[1000][1000];

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

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

				P[i][j] = i;

/*
		for(int i=0; i<n; i++){

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

				if(D[i][j]==INT_MAX)

					cout << '-' << ' ';

				else

					cout << P[i][j] << ' ';

			}

			cout << endl;

		}

*/
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(D[i][j]>D[i][k]+D[k][j]){
						D[i][j] = D[i][k]+D[k][j];
						P[i][j] = P[k][j];
					}
				}
			}
		}
/*
		for(int i=0; i<n; i++){

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

				if(D[i][j]==INT_MAX)

					cout << '-' << ' ';

				else

					cout << P[i][j] << ' ';

			}

			cout << endl;

		}

*/
		int m;
		cin >> m;

		for(int i=0; i<m; i++){
			int s, g;
			cin >> s >> g;
			int S, G;
			for(int j=0; j<n; j++){
				if(B[j][0]==s)
					S = j;
				if(B[j][0]==g)
					G = j;
			}

			if(D[S][G]==100000.0){
				cout << "NA" << endl;
				continue;
			}

			stack<int> st;
			while(S!=G){
				st.push(G);
				G = P[S][G];
			}

			cout << B[S][0];
			while(!st.empty()){
				cout << ' ' << B[st.top()][0];
				st.pop();
			}
			cout << endl;
		}
	}



	return 0;

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	ll x;
	cin >> x;

	ll a = x / 100;
	ll b = x % 100;

	if (b <= a * 5) {
		out(1);
	}
	else {
		out(0);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
int place[100];
int i,N;
scanf("%d",&N);
for(i=0;i<N;i++)
scanf("%d",&place[i]);
int j,tmp;
for(i=0;i<N;i++)
for(j=i+1;j<N;j++)
if(place[i]>place[j])
{
tmp=place[i];
place[i]=place[j];
place[j]=tmp;
}
printf("%d",place[N-1]-place[0]);
return 0;
}

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

int main()
{
    ll n,sum=0;
    cin>>n;
    vector<ll>v;
    for(ll i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
            else
                sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
s=input()
n=len(s)
ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += (s[i] != s[-i-1])
else:
  for i in range((n-1)//2):
    ans += (s[i] != s[-i-1])
print(ans)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


a, b, x = MAP()

y = 2*x/a/b
h = x/a**2
left = b-h

if x <= a*a*b/2:
	print(degrees(atan(b/y)))
else:
	print(degrees(atan(2*left/a)))

Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
typedef long long int ll;
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

/////////////////////////////////////////////////////////////////////////////////////////////

#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main()
{
    string s; cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int a[110];
int f(int l,int r,int k){
	if(l==r)return 0;
	int m=1e9;
	for(int i=l;i<r;i++)m=min(m,a[i]);
	int ans=m-k;
	int pre=l-1;
	for(int i=l;i<r;i++)if(a[i]==m){
		ans+=f(pre+1,i,m);
		pre=i;
	}
	ans+=f(pre+1,r,m);
	return ans;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	printf("%d",f(0,n,0));
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  for (char c = 'a'; c <= 'z'; ++c)
    if (std::count(S.begin(), S.end(), c) == 0)
      return !printf("%c\n", c);

  puts("None");
}

Measured memory_bytes: 512
s = input().replace("BC","D")

def main():
    res = 0
    num = 0
    for i in s:
        if i == "B" or i == "C":
            num = 0
        elif i == "A":
            num += 1
        else:
            res += num
    
    print(res)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include <stdio.h>

int main()
{
	int i, N, T[100001], A[100002];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(T[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	long long ans = 1;
	for (i = 1, T[0] = 0, A[N+1] = 0; i <= N; i++) {
		if (T[i] < T[i-1] || A[i] < A[i+1]) {
			ans = 0;
			break;
		} else if (T[i] > T[i-1] || A[i] > A[i+1]) {
			if ((T[i] > T[i-1] && A[i] < T[i]) || (A[i] > A[i+1] && T[i] < A[i])) {
				ans = 0;
				break;
			}
		} else if (T[i] < A[i]) ans = ans * T[i] % 1000000007;
		else ans = ans * A[i] % 1000000007;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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


template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int inf= 1<<30;
const int maxn = 200005;

int main(){__
	string s,t;
	cin >> s >> t;
	int ans = inf;
	for(int i=0; i < s.size(); i++){
		if(i + (int)t.size()-1 >= (int)s.size()) break;
		int dif=0;
		for(int j=0; j < t.size(); j++){
			if(s[i+j] != t[j]) dif++;
		}
		ans = min(ans,dif);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;

vector<int> to[200019];
vector<int> ans;

void dfs(int v, int p=-1) {
  for (auto u : to[v]) {
    if (p == u) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main(){
  int n, q;
  cin >> n >> q;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i, n) cout << ans[i] << endl;
}



Measured memory_bytes: 23552
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 
int main (){ 
    int n;
    cin>>n;
    vector<double> v(n);
    double sum=0;
    rep(i,0,n){
        cin>>v[i];
        sum+=v[i];
    }
    double ave=sum/n;
    double minDiff=1000000,ans=0;
    rep(i,0,n){
        if(abs(ave-v[i])<minDiff){
            minDiff=abs(ave-v[i]);
            ans=i;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

struct unko{
    int x;
    int y;
    int depth;
};
int dist[60][60];
int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    for (int i = 0; i < h; i++)
    {
        cin>>s[i];
    }
    
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dist[i][j]=-1;
        }
        
    }
    dist[0][0]=0;

    int v_x[4]={0,0,-1,1};
    int v_y[4]={-1,1,0,0};
    queue<unko>q;
    q.push({0,0,0});
    int pre_ans=0;
    while(!q.empty()){
        unko u=q.front();q.pop();
        if(u.x==w-1 && u.y==h-1) {
            pre_ans=u.depth;
            //cerr<<"a"<<endl;
            break;
        }
        for (int i = 0; i < 4; i++)
        {
            unko next={u.x+v_x[i],u.y+v_y[i],u.depth+1};
            if(dist[next.y][next.x]==-1 
            && 0<=next.x && next.x<=w-1 && 0<=next.y && next.y<=h-1 && s[next.y][next.x]=='.' ){
            dist[next.y][next.x]=dist[u.y][u.x]+1;
            q.push(next);
            
        }
    }
    }
    int cnt=0;
    /*cerr<<pre_ans<<dist[h-1][w-1]<<endl;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cerr<<dist[i][j]<<" ";
        }
        cerr<<endl;
    }
    cerr<<endl;*/
    if(dist[h-1][w-1]==-1){
        cout<<-1<<endl;
        return 0;
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(s[i][j]=='.') cnt++;
        }
        
    }
    cout<<cnt-2-(dist[h-1][w-1]-1)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  ll l = 0;
  ll r = pow(10,10);
  while(1){
    if(r - l <= 1)break;
    ll mid = (l + r) / 2;
    ll now = 0;
    for(int i = 0;i < n;i++){
      ll must = a[i] / mid;
      if(a[i] % mid != 0)must++;//何本になるか
      now += must - 1;//切る回数
    }
    if(now <= k)r = mid;
    else l = mid;
  }
  cout << r << endl;
}

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int x,A,B,s,s1;
	cin>>x>>A>>B;
	s=x-A;
	s1=s%B;
	cout<<s1<<endl;
	return 0;
}


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

int day;
int c[27];
int d[366][26], ansday[366];

void read_input() {
        //freopen("b1.in", "r", stdin);
        cin >> day;
        for (int i= 0; i< 26; i++) {
                cin >> c[i];
        }
        for (int i= 0; i< day; i++) {
                for (int j= 0; j< 26; j++) {
                        cin >> d[i][j];
                }
        }
}

void read_ans() {
        for (int i= 0; i< day; i++) {
                int x; cin >> x;
                ansday[i]= x- 1;
        }
}

int simu() {
        int lastuse[27]= {};
        int finalscore= 0;
        for (int i= 0; i< day; i++) {
                int choose= ansday[i];
                int score= d[i][choose];
                lastuse[choose]= i+ 1;
                int dec= 0;
                for (int j= 0; j< 26; j++) {
                        dec+= c[j]* ((i+ 1)- lastuse[j]);
                }
                finalscore+= score- dec;
        }
        return finalscore;
}

void query() {
        int m; cin >> m;
        vector<pair<int, int>> vp;
        for (int i= 0; i< m; i++) {
                int a, b; cin >> a>> b;
                vp.push_back({a, b});
        }
        for (int i= 0; i< m; i++) {
                int wday= vp[i].first- 1;
                int wc= vp[i].second- 1;
                ansday[wday]= wc;
                simu();
        }
}

void sol() {
        int lastuse[27]= {};
        for (int i= 0; i< day; i++) {
                vector<pair<int, int>> r;
                for (int j= 0; j< 26; j++) {
                        int dec= 0;
                        for (int k= 0; k< 26; k++) {
                                if (k== j) continue;
                                dec+= c[k]* ((i+ 1)- lastuse[k]);
                        }
                        r.push_back( { (d[i][j]- dec), j } );
                }
                sort(all(r));
                reverse(all(r));
                ansday[i]= r[0].second;
                lastuse[r[0].second]= i;
        }

}

void pr() {
        for (int i= 0; i< day; i++) {
                cout << ansday[i]+ 1<< "\n";
        }
}

void rand_query() {
        sol();
        int cur= simu();
        //cout << cur<< "\n";
        srand(time(0));
        for (int i= 0; i< 200000; i++) {
                int wday= rand() % 365;
                int wc= rand() % 26;
                int old= ansday[wday];
                ansday[wday]= wc;
                int r= simu();
                if (r< cur) {
                        ansday[wday]= old;
                } else {
                        cur = r;
                }
        }
        //cout << cur<< "\n";
        pr();
}

void solve() {
        read_input();
        //sol();
        //read_ans();
        //simu();
        //query();
        rand_query();
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[1000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
    int n;
    int num,d1,d2;
    while(cin>>n,n){
        int max=0;
        int ans;
        for(int i=0;i<n;i++){
            cin>>num>>d1>>d2;    
            if(max<d1+d2){
                max=d1+d2;
                ans = num;
            }
        }
        cout << ans << " " << max << endl;
    }
    return 0;
}


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

int main(){
    string s;	cin >> s;
    int ptr = s.find(",", 0);
    s[ptr] = ' ';
    ptr = s.find(",", ptr+1);
    s[ptr] = ' ';
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int h,n;
  cin >> h >> n;
  int a[n], b[n];
  int ans = LLINF;
  priority_queue<P, vector<P>, greater<P> > q;
  int cost[10000]={};
  LOOP(i,n){
    cin >> a[i] >> b[i];

    q.push(P(b[i], a[i]));
  }
  while(!q.empty()){
    P p = q.top();
    int nh = p.second;
    int nm = p.first;
    q.pop();
    if(nh >= h){
      ans = min(ans, nm);
      cout << ans << endl; return 0;
      continue;
    }
    // cerr << nm << "*";

    if(cost[nh]!=0){
      if(nm >= cost[nh])continue;
    }



    cost[nh] = nm;
    LOOP(i,n){
      q.push(P(b[i] + nm, a[i] + nh));
      // cerr << b[i]+nm << ":" << a[i]+nh << ", ";
    }
    // cerr << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 33892
require 'ostruct'

class RingBuffer
  def initialize(cap)
    @cap = cap + 1
    @values = Array.new(@cap)
    @head = @tail = 0
  end

  def empty?
    @head == @tail
  end

  def full?
    @head == ((@tail + 1) % @cap)
  end

  def enq(value)
    raise 'buffer is full' if full?

    @values[@tail] = value
    @tail = (@tail + 1) % @cap
    nil
  end

  def deq
    raise 'buffer is empty' if empty?

    value = @values[@head]
    @head = (@head + 1) % @cap
    value
  end
end

n, q = gets.split.map(&:to_i)

buffer = RingBuffer.new(n)

while line = gets
  name, time = line.split
  buffer.enq(OpenStruct.new(name: name, time: time.to_i))
end

current_time = 0

until buffer.empty?
  process = buffer.deq

  elapsed_time = [process.time, q].min
  process.time -= elapsed_time
  current_time += elapsed_time

  if process.time > 0
    buffer.enq(process)
  else
    puts "#{process.name} #{current_time}"
  end
end

Measured memory_bytes: 136784
S = list(input()) #2^(lenS-1)通り

def plus(s,num,bef):#残りの文字列、何文字目か、これまで
    bef = list(bef)
    s = list(s)
    if len(s) == num:
        bef.append(int("".join(s)))
        return sum(bef)
    else:
        #+いれないとき
        ret = plus(s,num+1,bef)
        #+入れるとき
        bef.append(int("".join(s[:num])))
        ret += plus(s[num:],1,bef)
        return ret

print(plus(S,1,[]))

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a,b,tower=0;
    cin >> a >> b;
    for(int i=1;;i++){
        tower+=i;
        if(b-a==i){
            cout << tower-b;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll num1 = 0, num2 = 0;
    f(n){
        ll a, b;
        cin >> a >> b;
        ll l = 0, r = 1e18/max(a,b) + 5;
        while(l < r - 1){
            ll m = (l + r) >> 1;
            ll aa = a * m, bb = b * m;
            if(aa >= num1 && bb >= num2){
                r = m;
            }
            else{
                l = m;
            }
        }
        num1 = r * a;
        num2 = r * b;
    }
    cout << num1 + num2 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ull = unsigned long long;
vector<int> ki[200010];

int main(){
    int n,q, a,b;
    cin>>n>>q;
    vector<ull> val(n+1,0LL);
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        ki[a].emplace_back(b);
    }
    for(int i=0;i<q;i++){
        cin>>a>>b;
        val[a] += b;
    }
    for(int i=1;i<=n;i++){
        cout<<val[i]<<' ';
        for(int j=0;j<ki[i].size();j++){
            val[ ki[i][j] ]+=val[i];
        }
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i, 0, n){
        int d[26] = {};
        rep(j, 0, i){
            d[s[j] - 'a'] |= 1;
        }
        rep(j, i, n){
            d[s[j] - 'a'] |= 2;
        }
        int cnt = 0;
        rep(j, 0, 26) if(d[j] == 3) cnt++;
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  int cnt = 0, cnt_max = 0;

  cin >> n;

  rep(i,n) {
    int a,b;
    cin >> a >> b;
    if(a == b) cnt++;
    else {
      cnt_max = max(cnt_max,cnt);
      cnt = 0;
    }
  }

  cnt_max = max(cnt_max,cnt);

  cout << ((cnt_max >= 3)? "Yes":"No") << endl;
  
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC139();
}

void ABC139(){
    int i,n=0;
    string s,t;
    cin>>s>>t;
    for(i=0;i<=2;++i){
        if(s[i]==t[i])++n;
    }
    cout<<n<<endl;
}

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

long long Euclid(long long x, long long y) {
	long long tmp;

	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}

	if (!(x%y)) return y;
	return Euclid(y, x%y);
}

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

	cout << (A*B) / Euclid(A, B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n,k;
cin>>n>>k;
if(n%k){
cout<<"1"<<endl;
}
else{
    cout<<"0"<<endl;
}
}









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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n%2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    string x = s.substr(0, n/2);
    if (x+x == s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
  int a,b;
  cin>>a>>b;
  
  if(a<b)
  {
    int i;
    for(i=0;i<b;i++)
      cout<<a;
    if(i==b-1)
      cout<<endl;
  }
  else if(b<a)
  {
    int i;
    for(i=0;i<a;i++)
      cout<<b;
    if(i==a-1)
      cout<<endl;
  }
  else
  {
    int i;
    for(i=0;i<a;i++)
      cout<<a;
    if(i==a-1)
      cout<<endl;
  }
}

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

int main(){

  int n, m;
  while(cin >> m >> n, m||n){
    int d[101];
    for(int i = 0; i < n; i++) cin >> d[i];

    int l = 0, r = MAX;
    while(l < r){
      int mid = (l + r) / 2;
      bool judge = true;
      int sum = 0, cnt = 1;
      for(int i = 0; i < n; i++){
        if(sum + d[i] <= mid) sum += d[i];
        else {
          sum = d[i]; cnt++;
          if(sum > mid || cnt > m){
            judge = false; break;
          }
        }
      }
      if(judge) r = mid;
      else l = mid + 1;
    }
    cout << l << endl;
  }

}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
main()
{
	cin>>N;
	vector<pair<int,int> >A(N);
	for(int i=0;i<N;i++)
	{
		string s;cin>>s;
		int c=0,m=0;
		for(char x:s)
		{
			if(x==')')c--;
			else c++;
			if(m>c)m=c;
		}
		A[i]=make_pair(c,m);
	}
	sort(A.begin(),A.end(),[](pair<int,int>a,pair<int,int>b)
	{
		if(a.first>=0)
		{
			if(b.first>=0)
			{
				return a.second>b.second;
			}
			else return true;
		}
		else
		{
			if(b.first>=0)
			{
				return false;
			}
			else
			{
				return a.first-a.second>b.first-b.second;
			}
		}
	});
	int C=0;
	for(pair<int,int>p:A)
	{
		if(C+p.second<0)
		{
			cout<<"No"<<endl;
			return 0;
		}
		C+=p.first;
	}
	cout<<(C?"No":"Yes")<<endl;
}



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

int main(){
  int a, b; cin >> a >> b;
  for (int i = 1; i < 10000; i++) {
    int u = (i * (i+1)) / 2;
    int v = ((i+1) * (i+2)) / 2;
    if (u - a == v - b) {
      cout << u - a << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, k, *a = map(int, string.split())
    a, t, p = [_a - 1 for _a in a], [0] * n, 0
    for i, _ in enumerate(a, 1):
        t[a[p]] = i
        p = a[p]
        if i == k:
            return str(p + 1)
    k = (k - t[a[p]] + 1) % (t[p] - t[a[p]] + 1)
    for _ in range(k):
        p = a[p]
    return str(p + 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 33620