akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

const ll NMAX = ll(10e18) + 1;

int solve();

ll getNextGrad(const ll k, const ll a);

//	戻り値は一回処刑・釈放のプロセスを行った後に
//	targetとなるインデックスの値
ll binarySearch(const ll k, const ll target);

ll jsearch(const ll k, const ll low, const ll high, const ll target);

int main(void) {
	while (solve()) {}
	return 0;
}

/*********

	考察

	N = 4, k = 2の場合

	[1] 0, 1, 2, 3, 4, 5, 6, 7
	[ ] *     *     *     *
	[2] 1, 3, 5, 7, 9, ...
	[ ] *     *     *
	[3] 3, 7, 9, ...
	[ ] *,    *,
	[4] 7 

	一般化して考える
	[1] 0, 1, 2, ..., k, ..., 2k
	[ ] *,  ,  , ..., *, ..., **
		釈放・処刑されるのは
			0, k, 2k, ...

		インデックスの振り直し
		元々のインデックスがiなら
		新しいインデックスは
			i - ( (i / k) + 1 )
			a_[n+1] = a[n] - ( ( a[n]/k ) + 1 )

	[2] 1, 2, 3, ..., k-1, k+1, k+2, ..., 2k-1, 2k+1, 2k+2, 2k+3....
	[ ] 0, 1, 2, ..., k-2, k-1, k  , ..., 2k-3, 2k-2, 2k-1, 2k
		釈放・処刑されるのは
			1, k+2, 2k+3, ...
			->	新たなインデックスは
				
	[3] 2, 3, 4, ...., k-1, k+1, k+3, k+4, ..., 2k-1, 2k+1, 2k+2, 2k+4
	[ ] 0, 1, 2, ...., k-2, k-1, k
		釈放・処刑されるのは
			2, k+3, 

	//	解法：二分探索？

		インデックスi (0 <= i <= 10^18)を二分探索する
		N回目までに処刑されず、かつインデックスが0になればよい

		大小判定は？

		・N回目で生き残り、処刑も釈放もされない -> 大きすぎる
		・N回目までに釈放されてしまう -> 小さすぎる
		・N回目までに処刑される -> ？	：インデックスが大きくなるほどこのパターンが多すぎて二分探索はダメそう

	//	実験してみた
		k = 2のとき
		釈放されるのは
		63:31,15,7,3,1,0,f など
		-> 2の累乗数-1
		
		k = 3のとき

		61:40,26,17,11,7,4,2,1,0,f
		92:61,40,26,17,11,7,4,2,1,0,f
			21,14,9,6,4,3,2,1,1,

		数列が固定化してる -> OEIS案件？

		k = 4のとき
		63:　 47,35,26,19,14,10, (7,5), (3,2,1,0),f
		85:63,47,35,26,19,14,10, (7,5), (3,2,1,0),f
		
		=> kが決まれば釈放されるインデックスの数列は唯一つ決まる
		この数列の(後ろから)n番目が解になる

		ここで逆順に並べておく
		 0,1,2,3,5,6,10,14,19,26,35,47,63,85, X
		ここでXを求めたい

		言い換えれば、以下の式でa[n+1]を求めたい
		a[n]は与えられる
		a[n] = a[n+1] - ( ( a[n+1]/k ) + 1 )

		・単調増加性は担保されるけど、解が一つとは限らない
		-> 解-1,解+1を二分探索で求めてから解一つ一つを吟味すればよい？

		・計算量を考える
			M ;解の範囲の最大値
			二分探索でO( log(M) )
			N回繰り返すから O( N )
			解の吟味は(途中で処刑されるかどうか) O(N)
				->　一回目で処刑されなければ釈放まで生き残ることが保証される
					なぜならa[n]はその作り方から釈放されることが決まっているから
			だからa[n+1]の候補がkで割り切れるかどうかだけ調べておけば十分 -> O(1)

			全体の計算量は O( log(10^18) * 10^5 )で十分間に合いそう

**********/


int solve() {

	ll N, k;
	cin >> N >> k;

	ll next = 1;

	//	コーナーケース
	{
		if (N == 1)
		{
			next = 0;
		}
		else if (N == 2)
		{
			next = 1;
		}
	}
	for (int i = 0; i < N - 2; i++)
	{
		const ll m = binarySearch(k, next - 1);
		const ll M = binarySearch(k, next + 1);
		next = jsearch(k, m, M, next);
	}

	cout << next << endl;


	return 0;
}

ll binarySearch(const ll k, const ll target)
{
	//	[0, NMAX) の範囲に解が存在するはず
	ll low = 0,
		high = NMAX,
		mid = (low+high)/2;

	while (getNextGrad(k,mid) != target)
	{
		mid = (low + high) / 2;

		if (getNextGrad(k, mid) > target)
		{
			high = mid;
		}
		else
		{
			low = mid;
		}

	}

	return mid;
}

ll jsearch(const ll k, const ll low, const ll high, const ll target)
{
	for (ll i = low; i <= high; i++)
	{
		if (getNextGrad(k, i) != target) { continue; }
		if (i % k == 0) { continue; }
		return i;
	}
	return -114514;
}

ll getNextGrad(const ll k, const ll a)
{
	return (a - (a / k + 1));
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int k;
int h[100001];
int mem[100001];
int dp(int n)
{
	if(n<=0)
		return mod;
	else if (n==1)
		return 0;
	else if(mem[n]!=-1)
		return mem[n];
	int best=mod;
	int i;
	for(int i=1;i<=k;i++)
	{
		if(n-i>0)
		{
			best=min(best,dp(n-i)+abs(h[n]-h[n-i]));
		}
	}
	mem[n]=best;
	return best;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n>>k;
    int i;
    f1(i,1,n+1)
    cin>>h[i];
    memset(mem,-1,sizeof(mem));
    cout<<dp(n);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll M, K;
    cin >> M >> K;

    if((1 << M) <= K){
        cout << "-1" << endl;
        return 0;
    }

    if(M==1){
        if(K==0) cout << "0 0 1 1" <<endl;
        else     cout << "-1" << endl;
        return 0;
    }

    for(ll bit=0; bit < (1 << M); bit++){
        if(bit == K) continue;
        cout << bit << " ";
    }
    cout << K << " ";
    for(ll bit = (1 << M) - 1; bit >= 0; bit--){
        if(bit == K) continue;
        cout << bit << " ";
    }
    cout << K << endl;
    return 0;

}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  int i,n,m,sum,j,e;
  int ps[1000];
  do{
    scanf("%d %d",&n,&m);
    if(!n&&!m) break;
    for(i=0,e=n-1;i<e;i++) scanf("%d ",ps+i);
    scanf("%d",ps+i);
    qsort(ps,n,sizeof(int),cmp);
    for(sum=0,i=0,e=n%m;i<e;i++){
      sum+=ps[i];
    }
    while(i<n){
      for(j=1;j<m;j++){
	sum+=ps[j+i];
      }
      i+=m;
    }
    printf("%d\n",sum);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

ll gcd(ll A, ll B) {
    if (A<B) return gcd(B,A);
    if (B==0) return A;
    else return gcd(B, A%B);
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    ll G = gcd(A,B);
    int cnt = 0;
    ll x = 2;
    while (x*x <= G) {
        if (G%x == 0) cnt++;
        while (G%x == 0) G /= x;
        x++;
    }
    if (G != 1) cnt++; // G is prime
    cout << cnt+1 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
R = S.count('R')
accR = [0]

for Si in S:
    accR.append(accR[-1]+(1 if Si=='R' else 0))

ans = 10**18

for i in range(N+1):
    ans = min(ans, abs(i-R)+abs(i-accR[i]))

print(ans)

Measured memory_bytes: 85288
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long x = Math.Min(B - 1, N);
		Console.WriteLine(A * x / B - A * (x / B));
		
		
	}
	long A,B,N;
	public Sol(){
		var d = rla();
		A = d[0]; B = d[1]; N = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27564
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    a, b, c = map(int, input().split())
    if a == b == c:
        print('Yes')
    else:
        print('No')








if __name__ == '__main__':
    main()


Measured memory_bytes: 38508
s = str(input())
mm = [i for i in range(1,13)]

if int(s[0]+s[1]) in mm:
    if int(s[2]+s[3]) in mm:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif int(s[2]+s[3]) in mm:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	map<char, int> m;
	char c;
	while ((c = getchar()) != EOF){
		m[c]++;
	}

	for (char ch = 'a'; ch <= 'z'; ch++){
		cout << ch << ' ' << ':' << ' ' << m[ch] + m[ch-0x20] << endl;
	}
}



Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{
    long long int a,b,k;
    cin>>a>>b>>k;
    if(a<=k)
    {
        cout<<0<<" ";
        k-=a;
        if(b<=k)
            cout<<0<<endl;
        else
            cout<<b-k<<endl;

    }
    else
        cout<<a-k<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define ms(l,n,s) memset(l,n,s)
#define m(l,n) (l*)malloc(n*sizeof(l))
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(int i=m;i<n;i++)
void dfs(int**,int*,int*,int,int);
void print(int*,int*,int);
int ord=1;
int main(){
  int n,u,k,v;
  int **matrix;
  int *dis,*fin;
  scanf("%d",&n);
  matrix=m(int*,(n+1));
  dis=m(int,(n+1));
  fin=m(int,(n+1));
  ms(dis,0,((n+1)*sizeof(int)));
  ms(fin,0,((n+1)*sizeof(int)));
  *(dis+1)=ord;
  ord++;
  lpton(i,(n+1)){
    *(matrix+i)=m(int,(n+1));
    ms(*(matrix+i),0,((n+1)*sizeof(int)));
  }
  lpton(i,n){
    scanf("%d%d",&u,&k);
    lpton(j,k){
      scanf("%d",&v);
      *(*(matrix+u)+v)=1;
    }
}
  dfs(matrix,dis,fin,1,n);
  lpmn(i,1,(n+1))if(!*(dis+i)){
    *(dis+i)=ord++;
    dfs(matrix,dis,fin,i,n);
  }
  print(dis,fin,n);
  return 0;
}
void print(int *dis,int *fin,int n){
  lpmn(i,1,(n+1))printf("%d %d %d\n",i,*(dis+i),*(fin+i));
}
void dfs(int **mtx,int *dis,int *fin,int i,int n){
// if(ord>(n*2))return;
    lpmn(j,1,(n+1)){
      if(*(*(mtx+i)+j)){
        if(!*(dis+j)){
      *(dis+j)=ord++;
      dfs(mtx,dis,fin,j,n);
      }
    }
  }
  *(fin+i)=ord++;
}



Measured memory_bytes: 2088
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int N;
	long long answer = 0;
	scanf("%d", &N);
	int A[N];
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	sort(A, A+N);
	for (int i = 0; i < (N>>1) - 1; ++i) answer += (A[N-1 - i] - A[i])*2;
	if(N&1){
		answer += A[(N>>1)+1] - A[(N>>1)-1];
		answer += A[(N>>1)+1] - A[N>>1] < A[N>>1] - A[(N>>1)-1] ? A[N>>1] - A[(N>>1)-1] : (A[(N>>1)+1] - A[N>>1]);
	}else{
		answer += (A[N>>1] - A[(N>>1)-1]);
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL
signed main()
{
	int n,m;
	cin>>n>>m;
	if(n>m)swap(n,m);
	if(n==1)cout<<abs(m-2)<<endl;
	else if(n==2)cout<<0<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    map<int,int> mp;
    mp[0] = 1;
    int ans = 0;
    vi pref(n + 1);
    pref[0] = 0;
    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        --x;
        pref[i] += pref[i - 1];
        pref[i] += x;
        pref[i] %= k;
        if(i - k >= 0)
        {
            mp[pref[i - k]]--;
        }
        ans += mp[pref[i]];
        mp[pref[i]]++;
    }
    cout << ans;
}

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

using namespace std;

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

  int s = 0, t = 0;
  for (auto c : X) {
    if (c == 'S') s++;
    else {
      // Sがあれば,SとTを組み合わせて消滅させる
      if (s > 0) s--;
      else t++;
    }
  }
  cout << (s + t) << endl;

  return 0;
}


Measured memory_bytes: 640
int main(){
    int A,B,C;
int max;
int min;
  
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
 
 max = A;
  if( max < B ) {
    max = B;
  }
  if( max < C ) {
    max = C;
  }
  min = A;
  if( min > B ) {
    min = B;
  }
  if( min > C ) {
    min = C;
  }
    printf("%d\n",max-min); 

    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;



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

    vector<int> p(N);

    rep(i,N){
        cin >> p[i];
    }

    int count = 0;
    rep(i,N){
        if (p[i] != i+1){
            count++;
        }else{
            continue;
        }
    }

    if (count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



}

Measured memory_bytes: 256
D, G = (int(i) for i in input().split())
G = G // 100
P= [0] * D
C= [0] * D

for i in range(D):
    P[i], C[i] = (int(i) for i in input().split())
    C[i] = C[i] // 100

INF = int(1e9)
mem = [[0] * 1010 for _ in range(D+1)] #solve数での最大のスコア
used = [[0] * 1010 for _ in range(D+1)]

def dfs(idx, num):
    if num == 0:
        return 0
    
    if num < 0:
        return -INF

    if idx == D:
        return -INF

    if used[idx][num]:
        return mem[idx][num]
    
    used[idx][num] = 1
    p = P[idx]
    c = C[idx]
    res = -INF
    for i in range(p+1):
        score = (idx + 1) * i;
        if (i == p):
            score = score + c
        nnum = num - i
        res = max(res, score + dfs(idx+1, nnum))
    mem[idx][num] = res;
    return res

ans = INF
for i in range(1001):
    if dfs(0, i) >= G:
        ans = i
        break

print (ans)



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

int solve(int a1, int a2, int a3){
    int out = 0;
    out += abs(a2 - a1);
    out += abs(a3 - a2);
    return out;
}

int main(){
    int A1, A2, A3, min = 1000;
    cin >> A1 >> A2 >> A3;
    if(solve(A1, A2, A3) < min) min = solve(A1, A2, A3);
    if(solve(A1, A3, A2) < min) min = solve(A1, A3, A2);
    if(solve(A2, A1, A3) < min) min = solve(A2, A1, A3);
    if(solve(A2, A3, A1) < min) min = solve(A2, A3, A1);
    if(solve(A3, A2, A1) < min) min = solve(A3, A2, A1);
    if(solve(A3, A1, A2) < min) min = solve(A3, A1, A2);
    cout << min << endl;
    return 0;
}

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


int main(){
    int a[6],k;
    for(int i = 0;i < 5;i++){
        scanf("%d",a + i);
    }
    scanf("%d",&k);
    bool ans = true;
    for(int i = 0;i < 5;i++){
        for(int j = i + 1;j < 5;j++)
        {
            if(abs(a[i] -a[j]) > k){
                ans = false;
                break;
            }
        }
    }
    if(ans)printf("Yay!\n");
    else printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-5-20 20:37:22
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  ll K;
  cin >> K;
  if (K % 2 == 0)
  {
    cout << A[0] - A[1] << endl;
  }
  else
  {
    cout << A[1] - A[0] << endl;
  }
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <functional>
 
using namespace std;
using ll=long long int;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (m % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }
 
    vector<int> used(n, 0);
    vector<pair<int, int>> res;
    function<int(int)> dfs = [&](int v) {
        used[v] = 1;
        int out = 0;
        for (int u: g[v]) {
            if (used[u] == 1) continue;
            if (used[u] == 2 || !dfs(u)) {
                res.emplace_back(v, u);
                out++;
            } else {
                res.emplace_back(u, v);
            }
        }
        used[v] = 2;
        return out%2;
    };

    dfs(0);
    for (auto &e: res) {
        cout << e.first+1 << " " << e.second+1 << "\n";
    }
 
    return 0;
}


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

ll gcd(ll a, ll b) { return a % b ? gcd(b, a % b) : b; }

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool r = false;
    if (a - b >= 0 && d >= b) {
      a -= b;
      ll k = gcd(b, d);
      ll x = a <= c ? a + ((c - a) / k + 1) * k : c + (a - c - 1) % k + 1;
      r = x - b >= 0;
    }
    cout << (r ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
char s[305][305];
char s2[305][305];
int n;
bool check(){
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++) if(s2[i][j]!=s2[j][i]) return false;
	}
	return true;
}
int main(void){
    scanf("%d",&n);
    int i,j;
    for(i=0;i<n;i++) scanf("%s",s[i]);
    int ans=0;
    for(int k=0;k<n;k++){
		for(i=0;i<n;i++) for(j=0;j<n;j++) s2[i][j]=s[(i+k)%n][j];
		if(check()) ans+=n;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    X, Y = [int(i) for i in input().strip().split()]
    for i in range(X + 1):
        if i * 2 + (X - i) * 4 == Y:
            return "Yes"
    return "No"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9168
N, A, B = map(int, input().split())
S = input()

def solve(S):
    ans = []
    students = 0
    foreigners = 0
    for i in range(N):
        if S[i]=='a' and students<A+B:
            ans.append('Yes')
            students += 1
        elif S[i]=='b' and foreigners<B and students<A+B:
            ans.append('Yes')
            students += 1
            foreigners += 1
        else:
            ans.append('No')
    return ans
print(*solve(S),sep='\n')

Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n; string s; cin >> n >> s;
	if (n >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
	cin >> n;
}

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

using namespace std;
int n;
double solve(vector<double> p){
    vector<double> t(n+1,0);
    vector<vector<double>> dp(n+1,t);
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0)dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
            else{
                dp[i][j]=dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1.0-p[i-1]);
            }
        }
    }
    double ans =0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n][i];
    }return ans;
}

int main()
{
    cin>>n;
    vector<double> v(n);
    vector<double> dp(n+1,-1);
    for(int i=0;i<n;i++)cin>>v[i];
    cout<<fixed<<setprecision(10)<<solve(v)<<"\n";
    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
const int mod1 = 1000000007;
const int mod2 = 998244353;

int main()
{
	optimize

	lli k;
	cin>>k;

	int ans = 0;
	lli x = 7;
	forn(i, (int)1e7)
	{
		if(x%k == 0LL)
		{
			ans = 1;
			cout<<i+1<<endl;
			break;
		}
		x = (x*10+7)%k;
	}
	if(!ans)
		cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3632
M=999;main(n,i,j,k,a,b,c){
	double p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
		for(a=i=0;i<n;i++){
			for(b=k=0;k<M;k++){
				x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
				for(c=j=0;j<n;j++){
					if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
				}
				if(b<c)b=c;
			}
			if(a<b)a=b;
		}
	}
exit(0);}

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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}

int main(){
	ll n;
	cin >> n;
	ll result = 0;
	for(int i = 1; i <= n ;i++ )
	{
		ll y = n/i;
		result += ((y * (y+1))/2) * i;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

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

bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int a[100005],b[100005];
vector<int> to[100005];
int distu[100005];
int distv[100005];

int main(){
    int n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    rep(i,100000){
        distu[i]=-1;
        distv[i]=-1;
    }
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        to[a[i]].push_back(b[i]);
        to[b[i]].push_back(a[i]);
    }
    //bfs//根からの回数が必要
    distu[u]=0;
    qu.push(u);
    while(!qu.empty()){
        int k=qu.front();
        qu.pop();
        for(int p:to[k]){
            if(distu[p]==-1){
                distu[p]=distu[k]+1;
                qu.push(p);
            }
        }
    }
    distv[v]=0;
    qu.push(v);
    while(!qu.empty()){
        int k=qu.front();
        //cerr<<distv[k]<<endl;
        qu.pop();
        for(int p:to[k]){
            if(distv[p]==-1){
                distv[p]=distv[k]+1;
                qu.push(p);
            }
        }
    }
    int ans=0;
    //cerr<<endl;
    rep(i,n){
        if(distu[i]!=-1&&distu[i]<distv[i]){
            chmx(ans,distv[i]-1);
        }
    }
    /*
    rep(i,n){
        cerr<<distu[i]<<' '<<distv[i]<<endl;
    }
    */
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 10624
#include <iostream>

using namespace std;

void solve()
{
	int pos = 0;
	char a, b, temp;
	while(~scanf("%c,%c%c", &a, &b, &temp))
	{
		if(pos + 'A' == a)
		{
			pos = b - 'A';
		}
		else if(pos + 'A' == b)
		{
			pos = a - 'A';
		}
	}
	printf("%c\n", pos + 'A');
}

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

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
using namespace std;

class Point {
public:
    int x, y;
    Point(int a = 0, int b = 0)
    {
        int x = a;
        int y = b;
    };
    bool operator <(const Point& p) const {
        return y < p.y || (y == p.y && x < p.x);
    }
};

inline bool direct(Point& base, Point& a, Point& b) {
    return (a.x - base.x)*(b.y - base.y) - (a.y - base.y)*(b.x - base.x) < 0;
}


int main() {
    int n, i;
    int k = 2;
    Point* P;
    Point* H;
    scanf("%d", &n);
    P = new Point[n];
    for (i = 1; i <= n; ++i) {
        scanf("%d%d",&P[i - 1].x, &P[i - 1].y);
    }
    sort(P, P + n);
    H = new Point[2*n];
    H[0] = P[0];
    H[1] = P[1];
    for (i = 0; i < n - 2; ++i) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i + 2])) k--;
        H[k++] = P[i + 2];
    }
    H[k++] = P[n - 2];
    for (i = n; i > 2; i--) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i - 3])) k--;
        H[k++] = P[i - 3];
    }
    printf("%d\n", k - 1);
    for (i = 0; i < k - 1; ++i) {
        printf("%d %d\n", H[i].x, H[i].y);
    }
    return 0;
}

Measured memory_bytes: 3828
import math

def proc(s):
    r=int(s[0:2],16)
    g=int(s[2:4],16)
    b=int(s[4:6],16)
    return (r,g,b)

def dist(a,b):
    sum=0
    for i in xrange(3):
        sum+=(a[i]-b[i])**2
    return math.sqrt(sum)

colors={ 'black':'000000','blue':'0000ff','lime':'00ff00',
'aqua':'00ffff','red':'ff0000','fuchsia':'ff00ff',
'yellow':'ffff00','white':'ff''ff''ff'}


while True:
    try:
        s=raw_input()[1:]
        if s=="": break
        mind=255*255*255
        for i in colors:
            if dist(proc(s),proc(colors[i]))<mind:
                mind=dist(proc(s),proc(colors[i]))
                color=i
        print color
    except EOFError: break

Measured memory_bytes: 4396
while True:
  (n,x) = tuple(map(int,input().split()))
  if n == 0 and x == 0:
    break
  else:
    count = 0
    for i in range(1, n + 1):
      for j in range(1, i):
        r = x - i - j
        if 0 < r and r < j :
          count += 1
    print(count)




Measured memory_bytes: 5592
int_a = int(input())
int_b = int(input())
int_c = int(input())
int_x = int(input())

int_pattern = 0

for a in range(int_a + 1):
    for b in range(int_b + 1):
        for c in range(int_c + 1):
            if 500 * a + 100 * b + 50 * c == int_x:
                int_pattern = int_pattern + 1

print(int_pattern)





Measured memory_bytes: 3060
A,B = map(int,input().split())

score = 0
if A >= B:
    score= score + A
    A = A - 1    
else:
    score = score + B
    B = B - 1

if A >= B:
    score = score + A
    A = A - 1
else:
    score = score + B
    B = B - 1
    
print(score)

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

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

  int k = max(h, w);
  cout << ceil((double)n / k) << '\n';

  return 0;
}


Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int M = int.Parse(ipt[1]);
    int sum = 0;
    for (int i = N - 1; 0 < i; i--) {
      sum += i;
    }
    for (int i = M - 1; 0 < i; i--) {
      sum += i;
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int a[10];
	int b=0;
	for(int i=0;i<10;i++){
		cin >> a[i];
	}
	int mou1,mou2,mou3;
	mou1=a[0];
	for(int i=0;i<10;i++){
		
		if(mou1<a[i]){
			mou1=a[i];
			b=i;
		}
	}
	a[b]=0;
	mou2=a[0];
	for(int i=0;i<10;i++){
		
		if(mou2<a[i]){
			mou2=a[i];
			b=i;
				
		}
	}a[b]=0;
	mou3=a[0];
	for(int i=0;i<10;i++){
		
		if(mou3<a[i]){
			mou3=a[i];
			b=i;
				
		}
	}
	cout<<mou1<<"\n"<<mou2<<"\n"<<mou3<<"\n";

	return 0;

}

Measured memory_bytes: 1164
def solve(n, t)
  arr = (1..n).to_a
  ans = []
  arr_select = arr.dup
  (t+1).times do |i|
    next_array = []
    ans.each do |a|
      next_array << a[i-1]
    end
    next_array += arr_select.shift(t - i)
    ans << next_array
  end
  ans.map!{ |a| [t] + a }
  ans
end

n = gets.to_i
k = 1
ok = [[1,1]]
c = 2
while k <= 100000
  k += c
  ok << [k,c]
  c += 1
end

if ok.transpose[0].include?(n)
  k = ok.transpose[0].index(n)
  puts 'Yes'
  ans = solve(n, ok[k][1])
  puts ans.size
  puts ans.map{ |a| a.join(' ') }
else
  puts 'No'
end
  

Measured memory_bytes: 7120
# AtCoder Beginner Contest 095 C - Half and Half
import sys

A, B, C, X, Y = map(int, sys.stdin.readline().strip().split())

ans = A * X + B * Y
for z in range(2, 2 * 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

    price = A * x + B * y + C * z
    ans = min(price, ans)

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	
	int n,k;
	cin >> n >> k;
	ll a[n];
	ll rui[n+1]; 
	rep(i,n) {
		cin >> a[i];
		rui[i+1] = rui[i]+a[i];
	}
	int subnum=n*(n+1)/2;
	ll sub[subnum];
	int cnt=0;
	rep(i,n){
		for(int j=i+1;j<n+1;j++){
			sub[cnt++] = rui[j]-rui[i];
		}
	}
	ll ans=0;
	ll check=0;
	for(ll bit=(1LL<<40);bit>=1;bit>>=1){
		cnt=0;
		rep(i,subnum){
			if(((sub[i] & check) == check) && ((sub[i] & bit) == bit)) cnt++;
		}
		if(cnt>=k){
			ans += bit;
			check |= bit;
		}
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
int fun(int x, int y);
int main(void)
{
	int x,y;
	while(scanf("%d %d",&x,&y)){
		int num=0;
		if(x==0) break;
		if(x==1) x=13;
		if(x==2) x=14;
		num=fun(x,y);
		switch(num){
			case 0:
					puts("Saturday");
					break;
			case 1:
					puts("Sunday");
					break;
			case 2:
					puts("Monday");
					break;
			case 3:
					puts("Tuesday");
					break;
			case 4:
					puts("Wednesday");
					break;
			case 5:
					puts("Thursday");
					break;
			case 6:
					puts("Friday");
					break;
		}
	}
	return 0;
}

int fun(int x, int y){
	int num=0;
	if(x==13 || x==14){
		x=floor(26*(x+1)/10);
		num=(x+y+108)%7;		//ツェラーの公式より
	}
	else{
		x=floor(26*(x+1)/10);
		num=(x+y+110)%7;		//ツェラーの公式より
	}
	return num;
}

Measured memory_bytes: 584
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	int n;
	scanf("%d", &n);
	char s[120], t[120];
	scanf("%s%s", s, t);
	char newstr[250];
	int j=0;
	for(int i=0; i<=n; i++){
		newstr[j] = s[i]; j++;
		newstr[j] = t[i]; j++;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vl a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  ll sb = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] > b[i]) {
      sb += a[i] - b[i];
    } else {
      int d = b[i] - a[i];
      sb -= d / 2;
    }
  }
  if (sb <= 0) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m, x;
	cin >> n >> m >> x;
	vi cnt(105, 0);
	vi a(m);
	rep(i, m) cin >> a[i], cnt[a[i]]++;
	int ans = 0, ans1 = 0;
	repn(i, x, n + 1) ans += cnt[i];
	for(int i = 0; i <= x; i++) ans1 += cnt[i];
	cout << min(ans, ans1) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
  string S;
 long long N,a,b,c,d,ans,ans2,p;
cin>>S;
  N=S.size();
  ans=0;
  for(int i=0;i<N-1;i++){
 if(S[i]=='A'&&S[i+1]=='C'){
   cout<<"Yes"<<endl;
   return 0;
 }
  }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<limits.h>
using namespace std;

long long int getmaxdigit(long long int a,long long int b){
    long long int count1=0,count2=0;
    while(a!=0){
        a/=10;
        count1++;
    }
    while(b!=0){
        b/=10;
        count2++;
    }
    return max(count2,count1);
}


int main(){
    long long int n;
    cin>>n;
    long long int min=INT_MAX;
    for(long long int i=sqrt(n);i>=1;i--){
        if(n%i==0){
            long long int result=getmaxdigit(i,n/i);
            if(min>result){
                min=result;
            }
        }
    }
    cout<<min<<endl;
}

Measured memory_bytes: 3684
#include <iostream>

using namespace std;

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

int nextInt() { int d; cin >> d; return d; }

int main() {
  while (true) {
    int N = nextInt();
    int M = nextInt() - 1;
    int P = nextInt();

    if (N + M + P == -1) break;

    int sum = 0;
    int xm = 0;
    REP(i, N) {
      int x = nextInt();
      sum += x;
      if (i == M) xm = x;
    }
    if (xm == 0) {
      cout << 0 << endl;
    } else {
      cout << sum * (100 - P) / xm << endl;
    }
   
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

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

    int res = 0;
    int maxs = 0;
    bool flag = false;
    for (int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            if(flag == false){
                flag = true;
                res++;
                maxs = max(maxs, res);
            }else{
                res++;
                maxs = max(maxs, res);
            }
        }
        else{
            res = 0;
            flag = false;
        }
    }
    cout << maxs << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    s1 = set()
    sn = set()
    for i in range(M):
        a, b = inm()
        if a == 1:
            s1.add(b)
        if b == 1:
            s1.add(a)
        if a == N:
            sn.add(b)
        if b == N:
            sn.add(a)
    return bool(s1 & sn)


print("POSSIBLE" if solve() else "IMPOSSIBLE")


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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int x[n+1];
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }

    int s=0;//zongshu

    for(int i=1;i<=n;i++){
        s+=min(k-x[i],x[i]);
    }

    cout<<s*2;

    return 0;


}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long n,m,res,r,a,b,d,i;
    scanf("%lld%lld",&n,&m);
    {
    	if(n>m)
	    {
	        a=m;
	        b=n;
	    }
	    else
	    {
	        a=n;
	        b=m;
	    }
        while(a!=0)
        {
            res=b%a;
            b=a;
            a=res;
        }
        printf("%lld\n",b);
    }

    return 0;
}

Measured memory_bytes: 2752
N = int(input())
S = input()
total = [0] * (N + 1)
for i in range(N):
    if S[i] == 'W':
        total[i + 1] = total[i] + 1
    else:
        total[i + 1] = total[i]

min_num = min(total[i] + (N - i - 1) - (total[N] - total[i + 1]) for i in range(N))

print(min_num)


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

int main()
{
    double r,x,y,z;

    scanf("%lf",&r);
    x = 3.141592653589;

    y = r * r * x;//面積
    z = r * 2 * x;//円周

    printf("%f %f\n",y,z);
    return 0;
}


Measured memory_bytes: 3200
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N;
    long ans=0;
    long input;
    cin >> N;

    int flag=0;

    FOR(keta,1,9){
    // ketamade sakusei

    FOR(i,0,pow(3,keta)-1){
      ll tmp=0;
      ll tmpi=i;
      ll keisu=1;
      FOR(j,1,keta){
        if(tmpi%3==0){
          tmp=tmp+3*keisu;
        }else if(tmpi%3==1){
          tmp=tmp+5*keisu;
        }else if(tmpi%3==2){
          tmp=tmp+7*keisu;
        }
        tmpi=tmpi/3;
        keisu=keisu*10;
      }

      // tmp kansei
      if(tmp<=N){
        int flag3=0;
        int flag5=0;
        int flag7=0;
        FOR(jj,1,keta){
          if(tmp%10==3){
            flag3++;
          }
          if(tmp%10==5){
            flag5++;
          }
          if(tmp%10==7){
            flag7++;
          }
          tmp=tmp/10;
        }

      if(flag3>0&&flag5>0&&flag7>0){
        ans++;
      }

      }


    }


    }

  cout<<ans<<endl;

  return 0;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 120
#define INF 0x3f3f3f3f
#define  ll long long
const int Max=2e5+10;
using namespace std;
int a[Max];
int main()
{
    cin.sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    ll num=a[n];
    int m;
    if(n&1)
    {
        m=(n+1)/2;
        for(int i=n-1; i>m; i--)
            num+=2*a[i];
        num+=a[m];
    }
    else
    {
        m=n/2;
        for(int i=n-1; i>m; i--)
            num+=2*a[i];
    }
    cout<<num<<endl;
}


Measured memory_bytes: 4364
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int maxn = 1e5;
#define m(a,b) memset(a,b,sizeof(a));
int main(){
	map<char,int>mp;
	map<char,int>::iterator it;
	int n;
	cin >> n;
	for(int i = 0;i<n;i++){
		char a;
		cin >> a;
		mp[a]++;
	}
	int cont = 0;
	for(it = mp.begin();it!=mp.end();it++){
		cont++;
	}
	if(cont == 3) printf("Three\n");
	else printf("Four\n");
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int x[n], y[n];
  for (int i=0; i<n; i++) cin>>x[i]>>y[i];
  int nums[n];
  for (int i=0; i<n; i++) nums[i] = i;

  int cnt = 0;
  double sum = 0.0;
  do {
    double dist = 0;
    ++cnt;
    for (int i=0; i<n-1; i++) {
      int j = nums[i];
      int k = nums[i+1];
      dist += sqrt(pow(x[j]-x[k], 2) + pow(y[j]-y[k],2));
    }
    sum += dist;
  } while (next_permutation(nums, nums + n));
  printf("%.9lf\n", sum / cnt);
}

Measured memory_bytes: 256
/*******************­************\
 Name: MD ASHRAFUZZAMAN KHAN |
 School: COMILLA UNIVERSITY |
 CSE (5TH BATCH) |
 ********************­************/

#include <bits/stdc++.h>

#define ll long long int
#define inf 1<<30
#define Pi 2*acos(0,0)
#define pi acos(-1)
#define PI 3.1415926535897932384626433832795
#define mem(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sf scanf
#define MAX 50

///template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T ncr(T n,T r){return n*(n-1)/r;}

using namespace std;


int main()
{

   ios_base::sync_with_stdio(0);

    int n;
    cin>>n;
    map<int,int>mp;
    int a;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        mp[a]=1;
    }
    cout<<mp.size();
   ///cin.get(); cin.get();
   return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import math
n = int(input())
n_list = [list(map(int,input().split())) for i  in range(n)]
ans = 0
for i,j in permutations(n_list,2):
    #print(i,j)
    dum = (i[0]-j[0])**2 + (i[1]-j[1])**2
    #print(dum)
    ans += math.sqrt(dum)
print(ans/n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    rep1(i, n){
        cin >> a[i];
        a[i]--;
    }
    vector<ll> town(n+100, 0);
    rep2(i, 1, n+100){
        town[i] = a[town[i-1]];
    }
    ll num;
    vector<ll> visit(n+100, -1);
    rep1(i,n+100){
        if (visit[town[i]] > -1){
            num = i;
            break;
        }
        visit[town[i]] = i;
    }
    ll len = num - visit[town[num]];
    ll init = visit[town[num]];
    ll res = (k-init)%len;
    ll ans = town[min(k,res+init)];
    cout << ans+1 << endl;
}

Measured memory_bytes: 7984
#include <stdio.h>
 

int main(){
  int n = 0, k = 0;
  int a[ 101 ] = {0};
  int c = 100;
  scanf( "%d %d", &n, &k );
  c = n;
  int i = 1;
  for ( i = 1; i < k + 1; i++ ){
    int d = 0;
    scanf( "%d", &d );
    
    int j = 1;
    for ( j = 1; j < d + 1; j++ ){
      int ai = 0;
      scanf( "%d", &ai );
      a[ ai ]++;
      if ( a[ ai ] == 1 ){
        c--;
      }
    }
  }

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

  return 0;
  
}


Measured memory_bytes: 1736