akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    vector<string> words;
    bool ans = true;
    rep(i,n){
        string w;
        cin >> w;
        words.push_back(w);
        //これまでに出ていないか
        rep(j,i){
            if(words[j] == w){
                ans = false;
            }
        }
        //単語が重複していないか
        if(i == 0) continue;
        if(words[i-1][words[i-1].size()-1] != w[0]){
            ans = false;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}
/*

ルールを一つずつ確認すればオーケー
単語が重複していないかは、O(N^2)でやったが、
sortすればO(NlogN)で確認できる
今回は1 <= N <= 100なので十分間に合う

*/

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
#include <math.h>

using namespace std;

int main(){
	int n, d,count=0;
	cin >> n >> d;
	vector<vector<double>> data(n, vector<double>(2));
	for (int i = 0; i < n; i++)
		cin >> data[i][0] >> data[i][1];
	for (int i = 0; i < n; i++)
		if ((double)sqrt(data[i][0] * data[i][0] + data[i][1] * data[i][1]) <= d)
			count++;
	cout << count << endl;
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m), ans(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<m;i++){
        cin >> c[i] >> d[i];
    }
    for(int i=0;i<n;i++){
        int mini = INT_MAX;
        for(int j=0;j<m;j++){
            int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(dist < mini){
                mini = dist;
                ans[i] = j+1;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

long long k;

bool is_ok(long long m, const vector<long long> &a, const vector<long long> &f) {
    long long s = 0;
    for (int i = 0; i < (int)a.size(); i++) {
        s += max(0ll, (long long)ceil(((double)a.at(i) * f.at(i) - m) / f.at(i)));
        if (s > k) return false;
    }
    return true;
}

long long binary_search(const vector<long long> &a, const vector<long long> &f) {
    long long ng = -1;
    long long ok = 1000000000010ll;

    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;

        if (is_ok(mid, a, f)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    int n;
    cin >> n >> k;
    vector<long long> a(n), f(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> f.at(i);
    }

    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    long long ans = binary_search(a, f);
    cout << ans << endl;
} 

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    k --;
    vector<char> a(n);
    rep(i,n) cin>>a[i];
    a[k]=a[k]+('a'-'A');
    rep(i,n) cout<<a[i];
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) a[i] = in() + 1;
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];
    ll ans = 0;
    FOR(i,k,n) chmax(ans, s[i] - s[i - k]);
    printf("%.15f\n", 0.5 * ans);

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    cout << 180 * (N - 2) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

N,M = map(int,input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            check = True
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    pass
                else:
                    check = False
                    break
            if check:
                print('Yes')
                sys.exit()
print('No')

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

 using namespace std;
 typedef long long ll;

 int main() {
   string S;
   int Q;

   cin >> S >> Q;

   vector<int> T(Q + 1);
   int t1_count = 0, t2_count = 0;
   int F;
   string C, C1, C2;

   for (int i = 1; i <= Q; i++) {
     cin >> T.at(i);
     if (T.at(i) == 1) t1_count++;
     else {
       t2_count++;
       cin >> F >> C;
       if ((F + t1_count) % 2 == 1) C1 = C + C1;
       else C2 = C2 + C;
     }
    }

    S = C1 + S + C2;

    if (t1_count % 2 == 1) {
      for (int i = S.length() - 1; i >= 0; i--) cout << S.at(i);
      cout << endl;
    }

    else cout << S << endl;
  }


Measured memory_bytes: 2236
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int n=read();
	printf("%d\n",n/2-(n%2==0));
}

Measured memory_bytes: 3720
import Prelude

expire :: Int->Int->Int->String
expire x a b
	|b<=a 	= "delicious"
	|b>=a && b<=(a+x) = "safe"
	|otherwise = "dangerous"
 
main :: IO ()
main = do
    -- スペース区切り整数の入力
    [x, a, b] <- map read . words <$> getLine
    -- 出力
    putStrLn $ expire x a b



Measured memory_bytes: 508
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    

    string pos = "Possible";
    string imp = "Impossible";

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        long best = long.MaxValue;
        for (int i = 0; i < 2; i++)
        {
            long tmp = 0;
            long sum = 0;
            for (int j = 0; j < N; j++)
            {
                sum += A[j];
                if (j % 2 == i)
                {
                    if(sum < 1)
                    {
                        tmp += 1 - sum;
                        sum = 1;
                    }
                }
                else
                {
                    if(sum > -1)
                    {
                        tmp += sum - (-1);
                        sum = -1;
                    }
                }
            }
            best = Math.Min(best, tmp);
        }
        Console.WriteLine(best);
    }


        
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

Measured memory_bytes: 28896
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int n;
long long f[400];
int main()
{
	scanf("%d",&n);
	f[0]=2;
	for(int i=0;i<=n;i++)
	f[i]=f[i-1]*2+2;
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad

fl::Int->Int
fl n = if mod n 10 == 0 then n else (n + 10) - (mod n 10)

mod_size::Int->Int
mod_size n = if mod n 10 == 0 then 0 else 10 - (mod n 10)


solver::[Int]->Int
solver ls = (sum (map fl ls)) - (maximum (map mod_size ls))

main::IO()
main=do
  ls<-forM [1..5] (\_ -> return.read=<<getLine)
  print (solver ls)


Measured memory_bytes: 508
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int a[N];

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n;
    cin >> n;
    int x = 0;
    for (int i = 0; i < n; ++i) 
    {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < n; ++i) cout << (a[i] ^ x) << ' ';
    return 0;
}

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

using namespace std;
using ll = long long int;


int main() {
	ll m, n;
	cin>>m>>n;
	ll ans = m*n;
	if( m == 1 || n == 1 ) {
		cout<<1<<endl;
		return 0;
	}
	if( ans % 2 == 0) cout<<ans/2<<endl;
	else cout<<ans/2 + 1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N;
	cin >> N;
	vector<long long>A(N);
	vector<long long>B;
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
		if (B.empty()) {
			B.push_back(A.at(i));
		}
		else {
			long long num = 0;
			for (long j = 0; j < B.size(); j++) {
				if (B.at(j) == A.at(i)) {
					num++;
				}
			}
			if (num == 0) {
				B.push_back(A.at(i));
			}
		}
	}
	cout << B.size() << endl;
}



Measured memory_bytes: 4608
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

struct Card {
    char suit;
    char value;
};

void bubble_sort(vector<Card>& cs) {
    for (int i = 0; i < cs.size(); i++) {
        for (int j = cs.size() - 1; j > i; j--) {
            if (cs[j].value < cs[j - 1].value) {
                swap(cs[j], cs[j - 1]);
            }
        }
    }
}

void selection_sort(vector<Card>& cs) {
    for (int i = 0; i < cs.size(); i++) {
        int min_idx = i;
        for (int j = i; j < cs.size(); j++) {
            if (cs[j].value< cs[min_idx].value) {
                min_idx = j;
            }
        }
        swap(cs[i], cs[min_idx]);
    }
}

void create_order_table(const vector<Card>& cs, vector<vector<char>>& table) {
    table.resize(9, vector<char>(0));
    for (auto c : cs) {
        table[c.value - '1'].push_back(c.suit);
    }
}

bool equal_order_table(const vector<vector<char>>& table1, const vector<vector<char>>& table2) {
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < table1[i].size(); j++) {
            if (table1.at(i).at(j) != table2.at(i).at(j)) {
                return false;
            }
        }
    }
    return true;
}

void print_all(const vector<Card>& cs) {
    for (int i = 0; i < cs.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << cs[i].suit << cs[i].value;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<Card> cs(n);
    for (auto& c : cs) {
        string str;
        cin >> str;
        c.suit = str.at(0);
        c.value = str.at(1);
    }

    vector<vector<char>> input_orders;
    create_order_table(cs, input_orders);

    vector<Card> bubble_sorted_cs(cs);
    bubble_sort(bubble_sorted_cs);
    vector<vector<char>> bubble_sort_orders;
    create_order_table(bubble_sorted_cs, bubble_sort_orders);
    print_all(bubble_sorted_cs);
    if (equal_order_table(input_orders, bubble_sort_orders)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    vector<Card> selection_sorted_cs(cs);
    selection_sort(selection_sorted_cs);
    vector<vector<char>> selection_sort_orders;
    create_order_table(selection_sorted_cs, selection_sort_orders);
    print_all(selection_sorted_cs);
    if (equal_order_table(input_orders, selection_sort_orders)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}

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

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; i++) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[0] << ' ' << A[1] << ' ' << A[2] << endl;
}


Measured memory_bytes: 3132
import copy
H,W,K = map(int,input().split())
C = [list(input()) for _ in range(H)]
D = copy.deepcopy(C)
ans = 0
for i in range(2**H):#行
    for j in range(2**W):#列
        black = 0
        for k in range(H):#行
            if (i>>k)&1:#行に対して調べる
                for l in range(W):
                    C[k][l] = "a"
        for m in range(W):#列に対して調べる
            if (j>>m)&1:
                for n in range(H):
                    C[n][m] = "a"
        
        for x in range(H):
            for y in range(W):
                if(C[x][y] == "#"):
                    black += 1
        
        if(black == K):
            ans += 1
        C = copy.deepcopy(D)
print(ans)
                    



Measured memory_bytes: 9096
import collections

n=int(input())
v=list(map(int,input().split(' ')))

v_2=[]
v_1=[]
for i,t in enumerate(v):
  if i%2==0:
    v_2.append(t)
  else:
    v_1.append(t)

v_2=collections.Counter(v_2)
v_1=collections.Counter(v_1)

if v_2.most_common()[0][0] != v_1.most_common()[0][0]:
    print(len(v)-v_2.most_common()[0][1]-v_1.most_common()[0][1])
else:
    if v_2.most_common()[0][1] > v_1.most_common()[0][1]:
      print(len(v)-v_2.most_common()[0][1]-v_1.most_common()[1][1])
    elif v_2.most_common()[0][1] < v_1.most_common()[0][1]:
      print(len(v)-v_2.most_common()[1][1]-v_1.most_common()[0][1])
    else:
        if v_2.most_common()[0][1]==len(v)/2:
            print(int(len(v)/2))
        else:
            if v_2.most_common()[1][1]>=v_1.most_common()[1][1]:
                print(len(v)-v_2.most_common()[1][1]-v_1.most_common()[0][1])
            else:
                print(len(v)-v_2.most_common()[0][1]-v_1.most_common()[1][1])


Measured memory_bytes: 18656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc163/tasks/abc163_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const double pi = acos(-1);
template<class Type>
Type solve(Type res = Type()){
    double R; cin >> R;
    res = R*2*pi;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 3792
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
ans = 0

for i in range(1000):
    s = '0'*(3-len(str(i)))+str(i)
    now = 0
    
    for j in range(N):
        if S[j]==s[now]:
            now += 1
    
            if now==3:
                break
    
    if now==3:
        ans += 1

print(ans)

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

int main() {
    int x;
    cin >> x;
    pair<int64_t, int64_t> ans = {0, 0};
    for(int64_t a = 0; pow(a, 5) <= 1e15; a++){
        for(int64_t b = 0; pow(b, 5) <= 1e15; b++){
            if(pow(a, 5) - pow(b, 5) == x){
                ans = {a, b};
                break;
            }
            if(pow(a, 5) + pow(b, 5) == x){
                ans = {a, b*(-1)};
                break;
            }
        }
        if(ans.first != 0 && ans.second != 0) break;
    }
    cout << ans.first << " " << ans.second << endl;
    return 0;
}

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

using namespace std;
int a,b,c,d,x[1000],y[1000],pom;
int main()
{
    cin>>a>>b>>c>>d;
    for(int i=0;i<a;i++)
    {
     cin>>x[i];
    }
    sort(x,x+a);
    for(int i=0;i<b;i++)
    {
        cin>>y[i];
    }
    sort(y,y+b);
    pom=min(y[0],d);
    if(max(x[a-1],c)<pom)
    {
        cout<<"No War";
    }else
    {
        cout<<"War";
    }
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.ascii;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto s = readln.chomp;

    bool found = false;
    foreach (c; lowercase) {
        auto p = s.indexOf(c);
        if (p == -1) {
            writeln(c);
            found = true;
            break;
        }
    }

    if (!found)
        writeln("None");
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}
#define max(a, b) ((a) > (b) ? (a) : (b))

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int k, n;
    cin >> k >> n;
    vint as = vint();
    rep (i, n) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    as.push_back(as[0] + k);

    int mx = 0;
    rep(i, n) {
        mx = max(mx, as[i + 1] - as[i]);
    }
    cout << k - mx << endl;
    return 0;
}


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

void Main() {
  int n, r;
  cin >> n >> r;
  if (n < 10) cout << r + 100 * (10 - n) << endl;
  else cout << r << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string s;

int main(void){
    
    cin >> s;
    
    int ans = 0;
    for(int i = 0; i < s.size(); ++i) if(s[i] == '1') ++ans;
    printf("%d\n", ans);
    
    return 0;
}



Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    way = [[] for i in range(n+1)]
    for i in range(n-1):
        u,v,w = map(int,ipt().split())
        way[u].append((v,w))
        way[v].append((u,w))

    col = [-1]*(n+1)
    q = [(1,0)]
    col[1] = 0
    while q:
        qi,ci = q.pop()
#        print(qi,ci)
        for j,lj in way[qi]:
            if col[j] == -1:
                cj = (ci+lj)%2
                col[j] = cj
                q.append((j,cj))

    for i in col[1::]:
        print(i)

    return None

if __name__ == '__main__':
    main()


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

int main(){
    int N,M,A[1000],B,cnt[1000]={},latte=0,ans;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<M;i++){
        cin>>B;
        for(int j=0;j<N;j++){
            if(B>=A[j]){
                cnt[j]++;
                if(latte<cnt[j]){
                    latte=cnt[j];
                    ans=j+1;
                }
                break;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1152
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    case solve . U.toList $ U.reverse xs of
        Just (x, y) -> putStrLn.unwords.map show $ [x, y]
        Nothing -> print $ -1

solve :: [Int] -> Maybe (Int, Int)
solve (2:xs) = go 1 1 2 xs
  where
    go gl gr p (x:xs)
        | gl' <= gr'= go gl' gr' x xs
        | otherwise = Nothing
      where
        gll = gl * p
        glr = gl * p + p - 1
        gl' = div (gll + x - 1) x

        grl = gr * p
        grr = gr * p + p - 1
        gr' = div grr x
    go gl gr p [] = Just (p*gl, p*gr+p-1)
solve _ = Nothing


Measured memory_bytes: 4988
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int n,m;
const int N = 1e5+7;
int hu[N],size[N],p[N];
void make_set(int v)
{
	hu[v] = v;
	size[v] = 1;
}
int find_set(int v)
{
	if(v == hu[v])
	return v;
	return hu[v] = find_set(hu[v]);
}
void union_sets(int a,int b)
{
	a = find_set(a);
	b = find_set(b);
	if(a != b)
	{
		if(size[a] < size[b])
		swap(a,b);
		hu[b] = a;
		size[a] += size[b];
	}
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	#define int long long
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	cin >> p[i];
	for(int i = 0; i < n; i++)
	make_set(i+1);
   	for(int i = 0; i < m; i++)
   	{
   	    int u,v;
		cin >> u >> v;
		union_sets(u,v);	
	}
	int res = 0;
	for(int i = 0; i < n; i++)
	{
		if(find_set(p[i]) == find_set(i+1))
		res++;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, j;
    char a;
    scanf("%c",&a);
    if (a==97||a==101||a==105||a==111||a==117){
        printf("vowel");
    }else {
    printf("consonant");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(ALL(h));
    ll min = LLONG_MAX;

    for (ll i = 0; i <= n - k; i++)
    {
        ll temp = h[i + k - 1] - h[i];
        if (min > temp)
            min = temp;
    }

    cout << min << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
	long x;cin>>x;
  	
    for(long i = 0;;i++){
   		if(i*(i+1)/2>=x){
        	cout<<i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
    int N, X, T;
    cin >> N >> X >> T;
    
    if(N % X == 0 )cout << (N / X) * T<< endl;
    else cout << (N / X + 1)*T << endl; 
    
    return 0;
}


Measured memory_bytes: 3596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int room[2][100*100];
int start[2], goal[2];
int dz[] = {-1,1,-52,52};
int dz_[] = {1,-1,-52,52};

int toz(int x, int y){
  return x + y * 52;
}
int ptoz(int z0, int z1){
  return z0 + z1*3000;
}

bool search(){
  vector<bool> visited(3000*3000, false);
  queue<PII> q;
  q.push(MP(start[0], start[1]));
  visited[ptoz(start[0],start[1])] = true;

  while(!q.empty()){
	PII now = q.front(); q.pop();
	REP(i,4){
	  int z0 = now.first + dz[i];
	  int z1 = now.second + dz_[i];
	  if(!room[0][z0])
		z0 -= dz[i];
	  if(!room[1][z1])
		z1 -= dz_[i];

	  if(z0 == goal[0]){
		if(z1 == goal[1])
		  return true;
		else continue;
	  }
	  if(z1 == goal[1])
		continue;

	  if(!visited[ptoz(z0,z1)]){
		visited[ptoz(z0,z1)] = true;
		q.push(MP(z0,z1));
	  }
	}
  }

  return false;
}

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

  int W, H;
  while(cin>>W>>H, W){
	fill((int*)room, (int*)room+2*100*100, 0);
	REP(y,H){
	  REP(i,2){
		string t; cin >> t;
		REP(x,W){
		  int st = 0;
		  switch(t[x]){
		  case 'R':
		  case 'L':
			st = 1;
			start[i] = toz(x+1,y+1);
			break;
		  case '%':
			st = 1;
			goal[i] = toz(x+1,y+1);
			break;
		  case '.':
			st = 1;
			break;
		  }
		  room[i][toz(x+1,y+1)] = st;
		}
	  }
	}

	cout << (search()? "Yes": "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 2864
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws IOException
	{
		String A,B,C;
		int a,b,c;
		
		Scanner in = new Scanner(System.in);
		
		A = in.next();
		B = in.next();
		C = in.next();
		
		a = Integer.parseInt(A);
		b = Integer.parseInt(B);
		c = Integer.parseInt(C);
		
		if(a <= b && b <= c){
			System.out.println(a + " " + b + " " +c);
		}else if(a <= c && c <= b){
			System.out.println(a + " " + c + " " +b);
		}else if(b <= a && a <= c){
			System.out.println(b + " " + a + " " +c);
		}else if(b <= c && c <= a){
			System.out.println(b + " " + c + " " +a);
		}else if(c <= a && a <= b){
			System.out.println(c + " " + a + " " +b);
		}else if(c <= b && b <= a){
			System.out.println(c + " " + b + " " +a);
		}
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e6)+1
#define MOD 998244353

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(6);

    lli k,x;
    cin>>k>>x;

    for(int i = x-k+1;i<x+k;++i){
        if(i+1 >= x+k){
            cout<<i<<endl;
        }else{
            cout<<i<<" ";
        }

    }

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int r;
    cin>>r;
    out(r*r);
    return 0;
}


Measured memory_bytes: 256
#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 int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

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

int main() {
    ll N, K, ans;
    cin >> N >> K;
    ans = K * PowMod_RepeatSquaring(K-1, N-1, MOD);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][][][] dp = new int[4][4][4][n];
	    for (int a = 0; a < 4; a++) {
	        for (int b = 0; b < 4; b++) {
	            for (int c = 0; c < 4; c++) {
	                if (a == 0 && b == 1 && c == 2) {
	                    continue;
	                } else if (a == 1 && b == 0 && c == 2) {
	                    continue;
	                } else if (a == 0 && b == 2 && c == 1) {
	                    continue;
	                }
	                dp[a][b][c][2] = 1;
	            }
	        }
	    }
		for (int i = 3; i < n; i++) {
		    for (int a = 0; a < 4; a++) {
		        for (int b = 0; b < 4; b++) {
		            for (int c = 0; c < 4; c++) {
    		            for (int d = 0; d < 4; d++) {
    		                if (a == 0 && c == 1 && d == 2) {
    		                    continue;
    		                } else if (a == 0 && b == 1 && d == 2) {
    		                    continue;
    		                } else if (b == 0 && c == 1 && d == 2) {
    		                    continue;
    		                } else if (b == 1 && c == 0 && d == 2) {
    		                    continue;
    		                } else if (b == 0 && c == 2 && d == 1) {
    		                    continue;
    		                }
    		                dp[b][c][d][i] += dp[a][b][c][i - 1];
    		                dp[b][c][d][i] %= MOD;
    		            }
		            }
		        }
		    }
		}
		int count = 0;
	    for (int a = 0; a < 4; a++) {
	        for (int b = 0; b < 4; b++) {
	            for (int c = 0; c < 4; c++) {
	                count += dp[a][b][c][n - 1];
	                count %= MOD;
	            }
	        }
	    }
	    System.out.println(count);
   }
}




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

int main()
{
  string a,c;
  cin>>a>>c;
  int n=0;
  if(a[0]==c[0]) n++;
  if(a[1]==c[1]) n++;
  if(a[2]==c[2]) n++;
  
  cout<<n<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i).second >> a.at(i).first;
	}
	sort(a.begin(), a.end());
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a.at(i).second;
		if(sum<=a.at(i).first){

		}else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

}



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

Measured memory_bytes: 640
#include<iostream>

int main() {

	int a, b, c;
	std::cin >> a >> b >> c;

	int res = 0;
	for (int i = 1; i <= b; i++) {
		if ((i * a) % b == c)res++;
	}

	if (res)std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}

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

long f(long x, long y) {
  return max(to_string(x).size(), to_string(y).size());
}

int main() {
  long N;
  cin >> N;
  long ans = 1e9;
  for (long i = 1; i * i <= N; i++) {
    if (N % i == 0) ans = min(ans, f(i, N / i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  string s;
  cin >> n >> s;
  int pre = 0;
  int now_pre = 0;
  REP(i, n) {
    if (s[i] == ')') {
      if (now_pre > 0) {
        now_pre--;
      } else {
        pre++;
      }
    } else {
      now_pre++;
    }
  }
  string pre_str(pre, '(');
  string suf_str(now_pre, ')');
  s.insert(0, pre_str);
  s.insert(s.length(), suf_str);
  cout << s << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string commandText = Reader.ReadLine();
        int[] goal = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int[] move = commandText.Split('T').Select(a=>a.Length).ToArray();

        bool canReachX = CanReach(2, move[0], goal[0], move);
        this.dic = new Dictionary<int, Dictionary<int, bool>>();
        bool canReachY = CanReach(1, 0, goal[1], move);

        string ans = "No";
        if(canReachX&&canReachY) {
            ans = "Yes";
        }
        Console.WriteLine(ans);

    }

    private Dictionary<int, Dictionary<int, bool>> dic = new Dictionary<int, Dictionary<int, bool>>();

    private bool CanReach(int idx, int pos, int goal, int[] array) {
        if(idx>=array.Length) {
            if(pos == goal) {
                return true;
            }
            return false;
        }

        if(!dic.ContainsKey(idx)) {
            dic.Add(idx, new Dictionary<int, bool>());
        }
        if(dic[idx].ContainsKey(pos)) {
            return dic[idx][pos];
        }

        if (CanReach(idx + 2, pos + array[idx], goal, array)) {
            return true;
        }
        if(CanReach(idx+2, pos-array[idx], goal, array)) {
            return true;
        }
        dic[idx][pos] = false;
        return false;
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



FFTTFF
0 0




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 163516
s = gets.chomp
if f = (s[0] == 'A')
  t = s[2..-2]
  m = t.scan(/C/)
  if f = (m.size == 1)
    s.gsub!(/^(...*)C(.*.)$/, '\1\2')
    s = s[1..-1]
    f = (s == s.downcase)
  end
end

puts f ? 'AC' : 'WA'

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int n, k; string s;
	cin >> n >> s >> k;
	char c = s[k - 1];
	for (int i = 0; i < n; i++) {
		if (s[i] != c) {
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

R = s.count('R')
G = s.count('G')
B = s.count('B')
ans = R*G*B

for i in range(n):
    for d in range(n):
        if i+(2*d) >= n: break
        if s[i] != s[i+d] and s[i] != s[i+(2*d)] and s[i+d] != s[i+(2*d)]:
            ans -= 1
            
print(ans)

Measured memory_bytes: 9080
//
    //  main.cpp
    //  study_c++
    //
    //  Created by Hisaki Kobayashi on 2020/03/31.
    //  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
    //

    #include <iostream>
    #include <stdio.h>
    #include <string>
//    #include <bits/stdc++.h>
#include <bits/stdc++.h>

    using namespace std;

    int main(int argc, const char * argv[]) {
        char S[10];
        int i,j,k,sum,cnt=0,max=0,start;
        string str;
        cin >> str;
        
        int length = str.length();
        for(start=0;start<length;start++){
            for(i=start;i<length;i++){
                if(str.at(i)=='A' || str.at(i)=='C'||str.at(i)=='G'||str.at(i)=='T'){
                    cnt++;
                }
                else{
                    break;
                }
            }
            if(max<cnt)
                max=cnt;
            cnt=0;
        }
        cout << max << endl;
   }



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

/* 方針
体力aのモンスターがbのモンスターを攻撃したとき，
攻撃されたモンスターの体力はb-a
このとき，a,bの公約数xがあるとき，b-aもまたxの倍数
どのモンスター同士で戦っても，両者の体力は最終的にgcd(a,b)になる
これを1番目vs2番目，2番目vs3番目，...と順に行なうと，
最終的にN番目の体力がgcd(a[i])と等しくなる
最後にN番目が他を攻撃し続ければ，最後に生き残ったモンスターの体力がgになる
*/
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int g = a[0];
    for (int i = 1; i < n; i++)
    {
        g = gcd(g, a[i]);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n, sum = 0;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	int ans = sum, cur = 0;
	for(int i = 0; i < n; i++)
	{
		cur += arr[i];
		ans = min(ans, abs(cur - (sum - cur)));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    std::string S, T; std::cin >> S >> T;
    for(char c('a'); c <= 'z'; ++c){
        if(S + c == T){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3596