akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)

void solve() {
  int x, y;
  cin >> x >> y;
  bool ok = true;
  if (y&1) ok = false;
  if (y < 2*x || y > 4*x) ok = false;
  cout << (ok?"Yes\n":"No\n");
}
void solve(bool tests) {
  int t;
  cin >> t;
  while (t--) solve();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}

Measured memory_bytes: 3608
s = input()
t = input()

INF = 10**9
min_ans = INF
for i in range(len(s)-len(t)+1):
    c = 0
    for j in range(len(t)):
        si = s[i+j]
        ti = t[j]
        # print(i,j,si,ti)
        if si == ti:
            c += 1
    min_ans = min(min_ans, len(t)-c)
print(min_ans)


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
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; }

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

  string s;
  cin >> s;
  map<char, ll> mp;
  for(auto i : s) mp[i]++;
  cout << (max({mp['a'], mp['b'], mp['c']}) - min({mp['a'], mp['b'], mp['c']}) <= 1 ? "YES" : "NO") << endl;
  return 0;
}

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

const int N = 2e5;
int used[N];
int head[N];
vector<int> fr[N];
int n, m, a, b;

void dfs(int rt, int now){
	used[now] = 1;
	head[now] = rt;
	for(int i=0; i<fr[now].size(); i++){		
		if(used[fr[now][i]] == 0){
			dfs(rt, fr[now][i]);
		}		
	}
}

void Sovle(){
	for(int i=0; i<n; i++){
		if(used[i]==0)dfs(i,i);
	}
}

void Output(){
	cin>>m;
	for(int i=0; i<m; i++){
		cin>>a>>b;
		if(head[a]==head[b])cout<<"yes\n";
		else cout<<"no\n";
	}
}

void Input(){
	cin>>n>>m;
	for(int i=0; i<m; i++){
 		cin>>a>>b;
 		fr[a].push_back(b);
 		fr[b].push_back(a);
 	}	
}

int main(){
	Input();
	Sovle();
	Output();
	return 0;
}


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

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

	int n;
	cin >> n;
	string str;
	vector<string> s;
	for (int i = 0; i < n; i++) {
		cin >> str;
		s.push_back(str);
	}

	int m;
	cin >> m;
	vector<string> t;
	for (int i = 0; i < m; i++) {
		cin >> str;
		t.push_back(str);
	}

	int cnt[109] = {};
	int max = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				cnt[i]--;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) {
				cnt[i]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (max < cnt[i]) {
			max = cnt[i];
		}
	}
	cout << max << "\n";

	return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int, input().split())
H1=(360*H/12)+(30*M/60)
M1=360*M/60
o=abs(H1-M1)
c=math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(o)))
print(c)


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

int main(){
  int n, a;
  cin >> n;
  int cnt = 0;
  rep(i,n){
    cin >> a;
    if((i+1)%2 == 1 and a%2 == 1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
        cin >> data.at(i).at(j);
    }
  }
  vector<bool> rflg(H,0);
  vector<bool> cflg(W,0);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
        if(data.at(i).at(j) == '#'){
            rflg.at(i) = 1;
            cflg.at(j) = 1;
        }
    }
  }

  for (int i = 0; i < H; i++) {
    if(rflg.at(i) == 1){
        for (int j = 0; j < W; j++) {
            if(cflg.at(j) == 1){
                cout << data.at(i).at(j);
            }
            if(j == W - 1) {
                cout << endl; // 末尾なら改行
            }
        }
    }
  }
}


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

int main() {
  int N, K, A;
  cin>>N>>K;
  A=1;
  
  for (int i=0; i<N; i++){
    if (A<K)
      A*=2;
    else
      A+=K;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element

signed main()
{
	int A, P;
	cin >> A >> P;
	int sum = A * 3 + P;
	cout << (sum / 2) << endl;
}



Measured memory_bytes: 3600
s = input()
q = int(input())

top = ""
isReverse = False
for i in range(q):
  qq = input().split()
  if qq[0] == "1":
    isReverse = not isReverse
  else:
    if qq[1] == "1":
      if isReverse: s+= qq[2]
      else: top += qq[2]
    else:
      if isReverse: top += qq[2]
      else: s+= qq[2]
        
if isReverse: s = s[::-1] + top
else: s = top[::-1] + s
print(s)

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long 
int main()
{
    ll n;
    cin>> n;
    ld dp[n+1] = {0};
    dp[0] = 1;
    for(ll i = 0 ; i < n ; i++)
    {
        ld x;
        cin >> x;
        for(ll j = i+1 ; j >= 0 ; j--)
        {
            dp[j] = ((j == 0)?0:(dp[j-1]*x)) + dp[j]*(1-x); 
            //cout << dp[j] << endl;
        
        }
    }
    ld cost = 0;
    for(ll i = 0 ; i <= n ; i++)
    {
        if((i) > (n-i))
        {
           // cout << 'h';
            cost += dp[i];
        }
    }

    cout << setprecision(10) << cost;



}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
	int k,c,p;
	while(cin >> k){
		if(k == 0){break;}
		int x = 0;
		for(int i=0;i<k*(k-1)/2;++i){
			cin >> c;
			x += c;
		}
	cout << x/(k-1) << endl;
	}
	return 0;
}



Measured memory_bytes: 3004
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    int tmp,k;
    bool flag=false;
    vector<int> d;
    string out;
    cin>>tmp;
    d.push_back(tmp);
    cin>>tmp;
    d.push_back(tmp);
    cin>>tmp;
    d.push_back(tmp);
    cin>>tmp;
    d.push_back(tmp);
    cin>>tmp;
    d.push_back(tmp);
    cin>>k;

    out ="Yay!";
    for(int i=0;i<d.size();i++){
        for(int j=d.size()-1;j>i;j--){
            if(d[j]-d[i]<=k){
                continue;
            }else{
                flag=true;
                out=":(";
            }
        }
        if(flag)
            break;
    }




    cout<<out<<endl;

    return 0;
}

Measured memory_bytes: 256
import collections

n=int(input())
v=list(map(int,input().split()))
v1=collections.Counter(v[0::2]).most_common()
v2=collections.Counter(v[1::2]).most_common()
v1.append((0,0))
v2.append((0,0))

if v1[0][0]!=v2[0][0]:
    ans=len(v) - v1[0][1] - v2[0][1]
else:
    ans=min(len(v) - v1[0][1] - v2[1][1],len(v) - v1[1][1] - v2[0][1])

print(ans)


Measured memory_bytes: 20700
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    map<string, int> m;
    string labels[] = {
        "AC", "WA", "TLE", "RE"
    };

    for(auto l : labels)
    {
        m[l] = 0;
    }

    int n;
    cin >> n;


    rep(i, n)
    {
        string s;
        cin >> s;
        m[s]++;
    }

    for(auto l : labels)
    {
        printf("%s x %d\n", l.c_str(), m[l]);
    }
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int k;
    cin >> k;
    ll ten_ele=1;
    ll n=1;
    ll cnt=0;
    while (cnt<k) {
        ll m=n;
        ll s=0;
        while (m>0) {
            s+=m%10;
            m/=10;
        }
        // cout << s << ' ' << n << endl;
        if (ten_ele*s<n) {
            n-=ten_ele;
            ten_ele*=10;
        }
        else {
            cout << n << endl;
            ++cnt;
        }
        n+=ten_ele;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	int k,x;
	cin >> k >> x;
	if (500 * k >= x)PRIY;
	else PRIN;
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a/10==9||a%10==9){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-

import queue

def main():
     n = int(input())
     s = input()

     r_list = []
     g_list = []
     b_list = []

     ans = 0

     for i in range(n):
          if s[i] == 'R':
               r_list.append(i)
          elif s[i] == 'G':
               g_list.append(i)
          else:
               b_list.append(i)

     for i in range(n):
          if s[i] == 'R':
               ans += check(i, g_list, b_list)

          if s[i] == 'G':
               ans += check(i, r_list, b_list)

          if s[i] == 'B':
               ans += check(i, r_list, g_list)

     print(ans)

def check(spot, first, second):
     ret = 0
     small_first = []
     big_first = []
     small_second = []
     big_second = []

     for f in first:
          if f < spot: small_first.append(spot - f)
          else: big_first.append(f - spot)

     for s in second:
          if s < spot: small_second.append(spot - s)
          else: big_second.append(s - spot)

     return len(small_first) * len(big_second) + len(small_second) * len(big_first) - len(set(small_first) & set(big_second)) - len(set(small_second) & set(big_first))
     
if __name__ == "__main__":
    main()


Measured memory_bytes: 10068
#include <stdio.h>

int main()
{
  int i;
  int data_set;
  int number[10000];
  
  for (i = 0;;i++) {
    scanf("%d", &number[i]);
    if (!number[i]) break;
    data_set = i;
  }

  for (i = 0; i <= data_set; i++) {
    printf("Case %d: %d\n", i + 1, number[i]);
  }
  
  return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t){
        print("Yes");
    }else{
        print("No");
    }

}

Measured memory_bytes: 256
#include <iostream>
#define ALPHABET 26

int main(){
	char c;
	int n[ALPHABET]={};
	while(std::cin>>c){
		if('A'<=c&&c<='Z'){
			c+=0x20;
		}
		if('a'<=c&&c<='z'){
			n[c-0x61]++;
		}
	}
	for(int i=0;i<ALPHABET;i++){
		std::cout<<char('a'+i)<<" : "<<n[i]<<std::endl;
	}
}

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

def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        l,r = map(int,input().split())
        edge[l-1].append(r-1)
        edge[r-1].append(l-1)

    a = list(map(int,input().split()))
    a.sort(reverse = True)
    put = [-1 for _ in range(N)]
    put[0] = a[0]
    q = deque([0])
    i = 1
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if put[fol] != -1:
                continue
            else:
                put[fol] = a[i]
                i += 1
                q.append(fol)
    
    print(sum(a)-a[0])
    print(*put)
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 6252
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

// 最大公約数を求める
template<typename T> T gcd(T a, T b)
{
	return b ? gcd(b, a % b) : a;
}

// 最小公倍数を求める
template<typename T> T lcm(T a, T b)
{
	return a / gcd(a, b) * b;
}

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

	vector<ll> d(n);
	ll l = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> d.at(i);
		l = lcm(l, d.at(i));
	}

	double s = 0;
	for (int i = 0; i < n; i++)
	{
		s += (double)l / d.at(i);
	}
	cout << fixed << setprecision(15) << (double)l / s << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static int longestSub(String str1, String str2) {
		int[][] table = new int[str1.length()][str2.length()];
		for (int r = 0; r < table.length; r++) {
			for (int c = 0; c < table[r].length; c++) {
				if (str1.charAt(r) == str2.charAt(c)) {
					if (r == 0 || c == 0) table[r][c] = 1;
					else table[r][c] = table[r-1][c-1] + 1;
				}
				else {
					int upMax = 0;
					int leftMax = 0;
					if (r != 0) upMax = table[r-1][c];
					if (c != 0) leftMax = table[r][c-1];
					table[r][c] = Math.max(upMax, leftMax);
				}
			}
		}
		
		return table[str1.length()-1][str2.length()-1];
	}
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numPairs = scanner.nextInt();
		for (int i = 0; i < numPairs; i++) {
			System.out.println(longestSub(scanner.next(), scanner.next()));
		}
		scanner.close();
	}
}



Measured memory_bytes: 64572
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n);
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];

  int cur = a[0];
  int count = 1;
  bool f=false;
  while(cur != 2){
    if(count>=n) {f=true; break;}
    cur = a[cur-1];
    //cout << "cur:" <<cur <<"count:" << count << endl;
    count++;
  }

  if(f) cout << "-1" << endl;
  else cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int a,b,n;
  int i;
  int ans=0,ans1=0;
  while(1){
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> a >> b;
      if(a>b){
	ans=ans+a+b;
      }
      else if(a<b){
	ans1=ans1+a+b;
      }
      else{
	ans+=a;
	ans1+=b;
      }
    }
    cout << ans << ' ' << ans1 << endl;
    ans=0;
    ans1=0;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int K;
    cin>>K;
    vector<int> cost(K,INF);
    cost[1]=1;
    deque<int> q;
    q.push_front(1);
    while(!q.empty()) {
        int x=q.front(); q.pop_front();
        if(x%10!=9) {
            int y=(x+1)%K;
            if(chmin(cost[y],cost[x]+1)) {
                q.push_back(y);
            }
        }
        int z=x*10%K;
        if(chmin(cost[z],cost[x])) {
            q.push_front(z);
        }
    }
    cout<<cost[0]<<endl;
    return 0;
}



Measured memory_bytes: 1408
from collections import Counter
def solve(N, S):
    c = Counter(S)
    m = max(c.values())
    ans = []
    for x, y in c.items():
        if y == m:
            ans.append(x)
    ans.sort()
    for i in ans:
        print(i)


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    solve(N, S)

if __name__ == "__main__":
    main()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }
  bool j = true;
  rep(i, n) {
    if (a.at(i) % 2 == 0) {
      if ((a.at(i) % 3 != 0) && (a.at(i) % 5 != 0)) {
        cout << "DENIED" << endl;
        j = false;
        break;
      }
    }
  }
  if (j) {
    cout << "APPROVED" << endl;
  }
}
    
    
  

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


int main () {

string s;
cin >> s;

if(s=="Sunny")
{
	cout<< "Cloudy" << endl;
}
else if(s=="Cloudy")
{
	cout<< "Rainy" << endl;
}
else
{
	cout << "Sunny" << endl;
}
	return 0;
}








Measured memory_bytes: 2956
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  	cin >> n;
  	vector< int > a(n);
  	int b[n];
  	for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      b[i] = a[i];
    }
  	sort(a.begin() , a.end());
  	for(int i = 0 ; i < n ; i++){
      int pos = lower_bound(a.begin() , a.end() , b[i]) - a.begin();
      if(pos == (n - 1))	cout << a[pos - 1] << endl;
      else cout << a[n - 1 ] << endl;
    }
 	return 0; 
}

Measured memory_bytes: 3200
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int n,a,b;

int main(void){
	scanf("%d%d%d",&n,&a,&b);
	string str;
	cin >> str;
	for(int i=0;i<n;i++){
		if(str[i]=='a'){
			if(a+b>0){
				printf("Yes\n");
				if(a>0)a--;
				else b--;
			}else printf("No\n");
		}
		if(str[i]=='b'){
			if(b>0){
				printf("Yes\n");
				b--;
			}else printf("No\n");
		}
		if(str[i]=='c')printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              for(ll i=0;i<n;++i) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ld r;
	cin>>r;
	ld ans=2*3.1415926*r;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3804
//  ©   ___MRX___

#include <bits/stdc++.h>
    using namespace std;

#define ll long long int

int main()
{

    int a, b, rev_number, i, count = 0, temp;
    cin >> a >> b;

    for(i = a; i <= b; i++) {
        temp = i;
        rev_number = 0;
        while(temp) {
            rev_number = rev_number * 10 + temp % 10;
            temp /= 10;
        }
        if(i == rev_number) count++;
    }

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 3588
#define MOD 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#define has(set, x) set.find(x) != set.end()
#define nohas(set, x) set.find(x) == set.end()
#define inc(mpp, x) {if(has(mpp, x)) mpp[x]++; else mpp.insert(mp(x,1));}
#define decc(mpp, x) {if(has(mpp, x)) {if(mpp[x] > 1) mpp[x]--; else mpp.erase(x);}}
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define um unordered_map
#define us unordered_set
#include <iostream>
#include <list>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <bitset>
using namespace std;
const int INF = 1 << 29;
typedef long long ll;
typedef unsigned long long ull;
inline int two(int n) { return 1 << n; }
ll extgcd(ll a, ll b, ll& x, ll& y) { if (b == 0) { x = 1; y = 0; return a; } else { int g = extgcd(b, a%b, y, x); y -= a / b * x; return g; } }
ll modpow(ll a, ll b) { ll res = 1; a %= MOD; for (; b; b >>= 1) { if (b & 1)res = res * a%MOD; a = a * a%MOD; }return res; }
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};


int main() {
	fast;
	int r,g,b, k;
	cin >> r >> g >> b >> k;
	int cnt = 0;
	while (g <= r) {
		cnt++;
		g <<= 1;
	}
	while (b <= g) {
		cnt++;
		b <<= 1;
	}
	cout << (cnt <= k ? "Yes" : "No") << endl;
	return 0;
}

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

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

int main()
{
    long long X;
    cin >> X;
    long long ans = 0;
    if(X >= 500){
        ans += (1000 * (X / 500));
        X = X % 500;
        if(X >= 5){
            ans += (5 * (X / 5));
        }
    }
    else if(X >= 5){
        ans += (5 * (X / 5));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
string A;
int ap[26] = {};
 
signed main() {
    cin >> A;
    for (int i = 0; i < A.length(); i++) {
        ap[A[i] - 'a']++;
    }
    int ans = 0;
    for (int i = 0; i < 26; i++) {
        ans += ap[i] * (A.length() - ap[i]);
    }
    cout << ans / 2 + 1 << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) 
{
    int a, b;

    cin >> a >> b;

    if (a*b % 2 == 0) {
        cout << "Even";
    } else {
        cout << "Odd";
    }

    return 0;
}

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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;
	for (int i = a; i >= 0; i--) {
		for (int j = b; j >= 0; j--) {
			for (int k = c; k >= 0; k--) {
				if (x == 500 * i + 100 * j + 50 * k)cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef double dd;

template <class T> inline ll Size(const T& x) { return x.size(); }

string str;

void Solve(ll test_num) {
  (void) test_num;
  ll r0 = Size(str), r1 = r0;
  VERA(i, 0, Size(str)) {
    if (str[i] == '1') {
      r1 = min(r1, max(i, Size(str) - i - 1));
    } else {
      r0 = min(r0, max(i, Size(str) - i - 1));
    }
  }
  const ll res = max(r1, r0);
  cout << res << endl;
}

bool Input() {
  if (not(cin >> str))
    return false;
  return true;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll test = 1;
  while (Input()) {
    Solve(test++);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() /
                       static_cast<double>(chrono::system_clock::period::den)) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int a[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < 5; i++)
    {
        if (a[i] == 0)
        {
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 3580
#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 a,b;

bool check(int val){
	int sum = 0;
	string s = to_string(val);
	rep(i,s.size()){
		sum += s[i] - '0';
	}
	return a <= sum && sum <= b;
}
int main(){
	int n;
	cin >> n >> a >> b;
	int ans = 0;
	REP(i,n){
		if(check(i)) ans += i;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0){
            return 0;
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if((i + j) % 2 == 0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
    string s,t;
    cin>>s>>t;
    int cnt=0;

    rep(i,s.size()){
        if (s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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

int main()
{
	int A, B, C, K, tmp, ans;
	cin >> A >> B >> C >> K;

	if (A >= B && A >= C) {
		for (int i = 0; i < K; i++) {
			A = A * 2;
		}
		cout << A + B + C << endl;
	}

	else if (B >= A && B >= C) {
		for (int i = 0; i < K; i++) {
			B = B * 2;
		}
		cout << A + B + C << endl;
	}

	else if (C >= A && C >= B) {
		for (int i = 0; i < K; i++) {
			C = C * 2;
		}
		cout << A + B + C << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B, C; cin >> A >> B >> C;
    Out(max(C - (A - B), 0LL));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	if(a - b > 1)
		cout << a-1;
	else
		cout << min(a,b);
	return 0;
}

Measured memory_bytes: 3580
import std.stdio, std.string, std.conv;
void main() {
	string s = readln.chomp;
	readln;
	foreach (string l; lines(stdin)) {
		auto d = l.chomp.split;
		auto n = d[1..3].to!(int[]);
		if (d[0] == "print")
			s[n[0]..n[1]+1].writeln;
		if (d[0] == "reverse") {
			auto r = s[n[0]..n[1]+1].dup.reverse.to!string;
			s = s[0..n[0]] ~ r ~ s[n[1]+1..$];
		}
		if (d[0] == "replace")
			s = s[0..n[0]] ~ d[3] ~ s[n[1]+1..$];
	}
}

Measured memory_bytes: 2476
#include<iostream>
#include<cmath>
using namespace std;
long long x[30],y[30],n,m,sum=1,mod=1000000007;
int main() {cin >> n >> m; for (int i = 0; i < 30; i++) { x[i] = (m / (int)pow(2, i)) % 2; } y[0] = n;
for (int i = 1; i < 30; i++) { y[i] = (y[i - 1] * y[i - 1]) % mod; }
for (int i = 0; i < 30; i++) { if (x[i] == 1) { sum *= y[i]; sum %= mod; } }
cout << sum << endl;}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    ll ans = 0;

    for (int i = 0; i < (1 << (s.length()-1)); i++) { // パターンを生成
        ll val = 0;
        for(int j = 0; j < s.length(); j++){
            val *= 10;
            val += s[j] - '0';
            if(i >> j & 1) { // j文字右シフトして、1であれば
                ans += val;
//                cout << (i >> j & 1) << "(" << val << ") ";
                val = 0;
                continue;
            }
//            cout << (i >> j & 1) << "(" << val << ") ";
        }
        ans += val;
//        cout << "->" << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    if(a%2==b%2){
        cout<<(abs(a-b)/2)<<endl;
    }else{
        ll A,B;
        A=max(a,b);
        B=min(a,b);
        ll ans;
        if(n-B>=A-1){
            ans=B-1+1+((A-B-1)/2);
        }else{
            ans=n-A+1+((A-B-1)/2);
        }
        cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 123;
ll n, a, b, h[N];

bool check(ll x) {
	ll res = 0;
	for (int i = 0; i < n; i++) {
		ll cur = (h[i] - x * b);
		res += (max(0ll, cur) + a - 1) / a;
	}
	return res <= x;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> a >> b;
	a -= b;
	for (int i = 0; i < n; i++) cin >> h[i];
	int l = -1, r = 1e9 + 123;
	while (l < r - 1) {
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	cout << r;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int A, B, C, D;
  
  while(cin >> A >> B >> C >> D, A || B || C || D) {
    cout << max(0LL, (B * C - A + D - 1) / D) << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
S = input()
length = len(S)

match = True
if S[0] != "A":
    match = False
elif S[2:length-1].count("C") != 1:
    match = False

for i in S:
    if i not in ["A", "C"] and i.isupper():
        match = False

print("AC" if match else "WA")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            int num1 = i;
            int num2 = n - i;
            int sum = digsum(num1) + digsum(num2);
            min = Math.min(min, sum);
        }

        int result = min;

        // 出力
        System.out.println(result);
    }

    public static int digsum(int num) {
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    vector<int> ll(n+1,-1),rr(n+1,-1),uu(n+1,-1),vv(n+1,-1);
    for(auto& xx:x)
    cin>>xx;
    for(auto& xx:y)
    cin>>xx;
    int res=0;
    vector<int> hh(n+1,0);
    for(int k=1,i=0,j=0;k<=n;k++)
    {
        while(i<n and x[i]<k)
        ++i;
        if(i<n and x[i]==k)
        {
            int jj=i;
            while(jj<n and x[jj]==k)
            ++jj;
            tie(ll[k],rr[k])={i,jj};
            i=jj;
        }
        while(j<n and y[j]<k)
        ++j;
        if(j<n and y[j]==k)
        {
            int jj=j;
            while(jj<n and y[jj]==k)
            ++jj;
            tie(uu[k],vv[k])={j,jj};
            j=jj;
        }
        if(~ll[k] and ~uu[k])
        {
            ++res;
            if(rr[k]-ll[k]+vv[k]-uu[k]>n)
            {
                cout<<"No\n";
                return 0;
            }
            if(uu[k]<=ll[k])
            {
                if(vv[k]<=ll[k])
                {
                    ++hh[0];
                    --hh[ll[k]-vv[k]+1];
                    ++hh[rr[k]-uu[k]];
                    --hh[n];
                }
                else
                {
                    ++hh[rr[k]-uu[k]];
                    --hh[ll[k]+n-vv[k]+1];
                }
            }
            else
            {
                ++hh[max(0,rr[k]-uu[k])];
                --hh[ll[k]+n-vv[k]+1];
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        if(hh[i]==res)
        {
            cout<<"Yes\n";
            rotate(y.begin(),y.begin()+n-i,y.end());
            for(auto xx:y)
            cout<<xx<<" ";
            cout<<endl;
            return 0;
        }
        hh[i+1]+=hh[i];
    }
    return 0;
}


Measured memory_bytes: 8780
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	int id,score;
	char s[11];
};
node a[101];
int n;
bool cmp(const node &n1,const node &n2)
{
	if(strcmp(n1.s,n2.s)<0) return 1;
	else if(strcmp(n1.s,n2.s) == 0&&n1.score>n2.score) return 1;
	else return 0;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i].s>>a[i].score;
	for(int i=1;i<=n;i++) a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) cout<<a[i].id<<endl;
	return 0;
} 

Measured memory_bytes: 256
N,C = map(int, raw_input().split())
x = [0]*N
v = [0]*N
for i in range(N):
  x[i],v[i] = map(int, raw_input().split())

def solve():
  M = [0]*N
  m = 0
  c = 0
  for i in range(N):
    c += v[i]
    c -= (x[i] - (0 if i==0 else x[i-1]))*2
    m = max(m, c)
    M[i] = m
  a = M[N-1]
  c = 0
  for i in range(N)[::-1]:
    c += v[i]
    c -= (C if i==N-1 else x[i+1]) - x[i]
    a = max(a, c+(0 if i==0 else M[i-1]))
  return a

ans = solve()
for i in range(N):
  x[i] = C - x[i]
x = x[::-1]
v = v[::-1]
ans = max(ans, solve())
print ans


Measured memory_bytes: 16184
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var nmxy = toIntArr(input[0].split(' '));
	var xs = toIntArr(input[1].split(' ')).sort((a,b)=>a-b);
	var ys = toIntArr(input[2].split(' ')).sort((a,b)=>a-b);
	var x = max(nmxy[2],xs[nmxy[0]-1]);
	var y = min(nmxy[3],ys[0]);
	var ans = y-x>0? 'No War': 'War';
	console.log(ans);
	return 0;
}

Measured memory_bytes: 21956
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char s[20];
    int l,i,a[15],j=0;
    for(j=0;j<15;j++)
        a[j]=0;
    j=0;
    cin>>s;
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
            a[j]+=1;
        else
                j++;
    }
    sort(a,a+15);
    cout<<a[14];
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
min_d = 10 ** 7
for i in range(n):
  tp = t - h[i] * 0.006
  ab = abs(a - tp)
  min_d = min(min_d, ab)
  
  if min_d == ab:
    ans = i+1
print(ans)

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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

void Solve() {
	LL n, a, b;
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a < b)) { cout << 0 << endl; return ; }
	LL mn = b + (LL)(n - 1) * a, mx = a + (LL)(n - 1) * b;
	cout << mx - mn + 1 << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3648