akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <map>
//#include "../cxx-prettyprint/prettyprint.hpp"
using std::vector;
using std::pair;

std::map<vector<pair<int, int>>, int> memo;

int get_minimum_multiplication(vector<pair<int, int>> matrix_sizes) {
    if (matrix_sizes.size() == 1) {
        return 0;
    } else if (matrix_sizes.size() == 2) {
        return matrix_sizes[0].first * matrix_sizes[0].second * matrix_sizes[1].second;
    } else if (memo.find(matrix_sizes) != memo.end()) {
        return memo[matrix_sizes];
    } else {
        int min_count = 0;
        for (int i = 1; i < matrix_sizes.size(); i ++) {
            vector<pair<int, int>> left, right;
            std::copy(matrix_sizes.begin(), matrix_sizes.begin() + i, std::back_inserter(left));
            std::copy(matrix_sizes.begin() + i, matrix_sizes.end(), std::back_inserter(right));
            int min_count_left = get_minimum_multiplication(left);
            int min_count_right = get_minimum_multiplication(right);
            int count = min_count_left +
                        min_count_right +
                        left.front().first * left.back().second * right.back().second;
            if (min_count == 0) {
                min_count = count;
            } else {
                min_count = std::min(min_count, count);
            }
        }
        memo[matrix_sizes] = min_count;
        return min_count;
    }
}

int main() {
    int n;
    std::cin >> n;
    vector<pair<int, int>> matrix_sizes(n);
    for (auto& size : matrix_sizes) {
        std::cin >> size.first >> size.second;
    }

    std::cout << get_minimum_multiplication(matrix_sizes) << std::endl;
}



Measured memory_bytes: 4680
import sys

import numpy as np


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def make_prime(U):
    is_prime = np.zeros(U, np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U ** 0.5) + 1
    for p in range(3, M, 2):
        if is_prime[p]:
            is_prime[p * p :: p + p] = 0
    return is_prime, is_prime.nonzero()[0]


def main():
    N = int(input())
    _, primes = make_prime(55556)

    r_5 = []
    for p in primes:
        if p % 5 == 1:
            r_5.append(p)
    # print(len(r_5))
    answer = r_5[:N]
    print(*answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}

Measured memory_bytes: 256
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a  

#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define vi              vector < int >
#define pb              push_back
#define mk              make_pair
#define fi              first
#define se              second
#define f               first
#define s               second
#define mod             1000000007 // 1e9 + 7
#define inf             1000000007 // 1e9 + 7
#define MAX             10000007   // 1e7 + 7
#define test            int t; cin>>t; while(t--)
#define eps             1e-6
#define forn(i, n)      for (int i = 0; i < int(n); i++)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define basic           ll NN; cin >> NN; vector < int >  a(NN); for(ll i = 0;i < NN;i++) cin >> a[i];

// int fact[1000007]={0};
// int spf[(int)(1e6)];
// bool prime[(int)((1e7) + 20)];
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
// void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int xyp(int x,int y){int res=1;while(y>0){if(y%2==1) res=(res*x)%mod;x=(x*x)%mod;y/=2;}return res%mod;}
// int inv(int x){return xyp(x,mod - 2);}
// void init() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[r],mod-2)))%mod; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res; }
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
// int add(int a, int b){return (a%mod + b%mod)%mod;}
// int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
// int mul(int a, int b){return ((a%mod)*(b%mod))%mod;}
// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int32_t main()
{
	fast_io
	int n;
	cin >> n;
	vector < int > dp(n + 1, 0), v(n);
	for(auto &z : v)
		cin >> z;
	dp[1] = 0;
	dp[2] = abs(v[1] - v[0]);
	for(int i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(v[i - 1] - v[i - 2]), dp[i - 2] + abs(v[i - 1] - v[i - 3]));
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
n = int(input())
b = list(map(int,input().split()))
l = []
while not b==[]:
    k=0
    for i in range(len(b)-1,-1,-1):
        if i+1==b[i]:
            l.append(b[i])
            del b[i]
            k=1
            break
    if not k:
        print(-1)
        exit()
l.reverse()
for l_ in l:
    print(l_)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
vector<int>v(maxn),adj[maxn];

void solve(){
    // int n;
    // cin >> n;
    // FOR(i,1,n+1)cin >> v[i];
    // FOR(i,1,n){
    //     int u,v;
    //     cin >> u >> v;
    //     adj[u].pb(v);
    //     adj[v].pb(u);
    // }
    int n,ans = 0;
    cin >> n;
    vector<int>a(n+5);
    map<int,int>cnt;
    FOR(i,1,n+1){
        cin >> a[i];
        ans += cnt[i-a[i]];
        cnt[a[i]+i]++;
    }
    cout << ans;
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 33848
// Cについて全探索できそうな雰囲気（最大でCなので）
// いやでもC*Nでもたかが知れてるのでは？
// -> 2WAくらう
package main
import "fmt"

type ST struct{
	s, t int
}

func main(){
	var N, C int
	fmt.Scan(&N, &C)
	ans := 0
	T := make([][]int, C)
	for i:=0; i<C; i++{
		T[i] = make([]int, 2*int(1e5)+10)
	}
	for i:=0; i<N; i++{
		var s, t, c int
		fmt.Scan(&s, &t, &c)
		T[c-1][s*2] = 1
		T[c-1][t*2+1] = -1
	}
	for i:=0; i<C; i++{
		for j:=1; j<=2*int(1e5); j++{
			T[i][j]+=T[i][j-1]
		}
	}
		
	for j:=0; j<=2*int(1e5); j++{
		tmp := 0
		for i:=0; i<C; i++{
			tmp += min(1 ,T[i][j])	// ????????????????????????
		}
		ans = max(ans, tmp)
	}
	fmt.Println(ans)
}

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

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

Measured memory_bytes: 59588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
 
public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(in.readLine());
    int S = Integer.parseInt(st.nextToken());
    int W = Integer.parseInt(st.nextToken());
    System.out.println(S>W?"safe":"unsafe");
  }
}

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

bool a[1300000] = { false };

int main(){
	for (int i = 2; i < 1300000; i++) {
		if (!a[i]) {
			for (int j = i * 2; j < 1300000; j += i) {
				a[j] = true;
			}
		}
	}
	int k, f, l;
	while (cin >> k && k != 0) {
		for (int i = k;;i++) {
			if (!a[i]) {
				l = i;
				break;
			}
		}
		for (int i = k;;i--) {
			if (!a[i]) {
				f = i;
				break;
			}
		}
		cout << l - f << endl;
	}

	return 0;
}

Measured memory_bytes: 4312
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int Mod=998244353;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}string s;map<string,int>F;
inline void Merge(string&x,string y){for(int i=0,l=x.size();i<l;i++)if(y[i]=='0')x[i]='0';}
int DFS(string s){
	if(s.empty())return 1;if(F.count(s))return F[s];
	int n=s.length(),tmp=1ll*(1+(s[0]=='1'))*DFS(s.substr(1,n))%Mod;
	for(int i=1;2*i<=n;i++){
		string t=s.substr(0,i);
		for(int j=2;i*j<=n;j++){
			Merge(t,s.substr(i*(j-1),i*j)),tmp=(tmp+1ll*DFS(t)*DFS(s.substr(i*j,n)))%Mod;
		}
	}return F[s]=tmp;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	cin>>s;cout<<DFS(s)<<'\n';
	return 0;
}




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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

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

  int n, m; cin >> n >> m;
   vector<bool> red(n, 0);
   red[0] = true;
   vi cnt(n, 1);

   REP(i, m) {
     int x, y; cin >> x >> y;
     x--; y--;
     red[y] = red[x] | red[y];
     if(cnt[x] == 1) red[x] = false;
     cnt[y]++;
     cnt[x]--;
   }

   int ans = 0;
   REP(i, n) {
     ans += red[i];
   }
   cout << ans << endl;

}
























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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

bool check_row(int A[3][3]) {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (A[i][j] != -1) {
                goto next;
            }
        }
        return true;
next:;
    }
    return false;
}

bool check_col(int A[3][3]) {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (A[j][i] != -1) {
                goto next;
            }
        }
        return true;
next:;
    }
    return false;
}

bool check_diag(int A[3][3]) {
    return (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) ||
           (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1);
}

int main() {
    int A[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (A[j][k] == b) {
                    A[j][k] = -1;
                }
            }
        }
    }

    if (check_row(A) || check_col(A) || check_diag(A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n;
    cin>> n;
    vll v(n);
    rep(i, 0, n)
        cin>> v[i];
    sort(all(v));
    ll ans = v.back(), nn = n - 2;
    per(i, 0, n - 1){
        if(nn <= 0)
            break;
        if(nn > 1){
            ans += 2 * v[i];
            nn -= 2;
        }
        else{
            ans += v[i];
            nn -= 1;
        }
    }
    cout<< ans<< "\n";
    return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,arr[111],ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
    for(int i=2;i<=n;i++) if(arr[i] == arr[i-1]) ans++,arr[i]=-1;
    printf("%d",ans);
}


Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
	int a[9];
	for (int i =0; i < 9; ++i){
		cin >> a[i];
	}

	int n;
	cin >> n;

	int b;
	for (int i =0; i < n; ++i){
			cin >> b;
			for (int j = 0; j < 9; ++j){
				if (b == a[j]){
					a[j] = 0;
				}
			}
	}


	int total = 0;

	for (int i =0; i < 3; ++i){
		total= a[i*3]+a[i*3+1]+a[i*3+2];
		if (total == 0){
			break;
		}
		total = 0;
		total = a[i]+a[i+3]+a[i+6];
		if (total == 0){
			break;
		}

	}


	if (total == 0){
		cout << "Yes" << endl;
		return 0;
	}

	total = a[0] + a[4] + a[8];

	if (total == 0){
			cout << "Yes" << endl;
			return 0;
		}


	total = a[2] + a[4] + a[6];
		if (total == 0){
				cout << "Yes" << endl;
				return 0;
			}
			else{
				cout << "No" << endl;
				return 0;
			}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
	int n;
	cin >> n;
	int sum=0,max=0;
	REP(i,n){
		int p;
		cin >> p;
		sum += p;
		if(max<p) max = p;
	}
	cout << sum-max/2 << endl;
}

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

vector<ll> a(100005);
vector<ll> b(100005);
vector<ll> ovr,udr;

int main(){
  ll n;
  cin >> n;
  
  for(ll i=0; i<n; i++) cin >> a[i];
  for(ll i=0; i<n; i++) cin >> b[i];
  
  for(ll i=0; i<n; i++){
    if(a[i] >= b[i])
      ovr.push_back(a[i] - b[i]);
    else
      udr.push_back(b[i] - a[i]);
  }
  
  ll sum_m = 0;
  for(auto p: udr) sum_m += p;
  
  sort(ovr.begin(), ovr.end(), greater<ll>());
  
  ll sum_p = 0;
  ll j = 0;
  while(sum_p < sum_m && j < ovr.size()){
    sum_p += ovr[j++];
  }
  
  if(sum_p < sum_m){
    cout << -1 << endl;
    return 0;
  }
  
  cout << udr.size() + j << endl;
}

Measured memory_bytes: 2936
require 'set'

n, k = gets.strip.split.map(&:to_i)
td = readlines.map {|line| line.strip.split.map(&:to_i) }.sort_by(&:last).reverse

selected = td.take(k)
unselected = td[k...n]

selected_kind = Set.new
swapable = []

selected.each do|t, d|
  unless selected_kind.include?(t)
    selected_kind.add(t)
  else
    swapable.push([t,d])
  end
end

score = selected.map(&:last).inject(:+)
bonus = selected_kind.size**2
result = score + bonus

unselected.each do|t, d|
  next if selected_kind.include?(t)

  swap = swapable.pop
  break if swap.nil?

  selected_kind.add(t)
#p [score, bonus, swap, t, d]
  score = score - swap.last + d

  bonus = selected_kind.size**2
  current_result = score + bonus
  result = current_result if current_result > result
end

#p td
p result


Measured memory_bytes: 23504
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, P;
  cin >> N >> P;

  map<long long, long long> m;
  long long tmp = P;
  for (long long i = 2; i * i <= tmp; ++i) {
    long long c = 0;
    while (tmp % i == 0) {
      tmp /= i;
      ++c;
    }
    if (c > 0)
      m[i] = c;
  }
  if (tmp != 1)
    m[tmp] = 1;

  long long ret = 1;
  for (map<long long, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    if (i->second < N)
      continue;
    ret *= pow(i->first, i->second / N);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int ans=0;
  string s;
  cin >> s;
  Srep(3) if(s[i] == '1') ans++;
  cout << ans << endl;
}

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

#define ll long long int
#define MOD 2019
#define vi vector<int>

int main() {

    ll L, R;
    cin >> L >> R;

    vi v;

    R = min(L + MOD - 1, R);
    for (int i = L; i <= R; i++) {
        v.push_back(i%MOD);
    }

    int ans = MOD;
    for (int i = 0; i < v.size()-1; i++) {
        for (int j = i+1; j < v.size(); j++) {
            if (ans > (v[i]*v[j]) % MOD) {
                ans = (v[i]*v[j]) % MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,l,t=0;
string s;
int number(){
	int q=0;
	while(t<s.size()&&isdigit(s[t])){
		q*=10;
		q+=s[t]-'0';
		t++;
	}
	return q;
}
vvi f(){
	vvi w(n,vi(n));
	rep(i,n)rep(j,n)w[i][j]=i*n+j;
	while(t<s.size()){
		if(s[t]=='('){
			t++;
			vvi ne=f();
			t++;
			int co=number();
			while(co){
				if(co%2){
					vvi NE(n,vi(n));
					rep(i,n)rep(j,n)NE[i][j]=w[ne[i][j]/n][ne[i][j]%n];
					w=NE;
				}
				vvi NE(n,vi(n));
				rep(i,n)rep(j,n)NE[i][j]=ne[ne[i][j]/n][ne[i][j]%n];
				ne=NE;
				co/=2;
			}
		}else if(s[t]==')')break;
		else{
			char c=s[t];
			t++;
			int co=number()-1;
			int tmp;
			if(c=='U'){
				tmp=w[0][co];
				rep(i,n-1)w[i][co]=w[i+1][co];
				w[n-1][co]=tmp;
			}
			if(c=='D'){
				tmp=w[n-1][co];
				rep(i,n-1)w[n-1-i][co]=w[n-2-i][co];
				w[0][co]=tmp;
			}
			if(c=='L'){
				tmp=w[co][0];
				rep(i,n-1)w[co][i]=w[co][i+1];
				w[co][n-1]=tmp;
			}
			if(c=='R'){
				tmp=w[co][n-1];
				rep(i,n-1)w[co][n-1-i]=w[co][n-2-i];
				w[co][0]=tmp;
			}
		}
	}
	return w;
}
int main(){
	cin>>n>>l>>s;
	t=0;
	vvi out=f();
	rep(i,n)rep(j,n)cout<<out[i][j]+1<<" \n"[j==n-1];
}











Measured memory_bytes: 17308
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=1000005;
char s[N];
int n,top,q[N];
int cnt[3],id[3];
int pre[N],suf[N];
int b1,b2,c1,c2;
pii qq[N];
void work1(int i){
	if (b1<=c2) return;
	--cnt[id[1]]; --b1;
	suf[pre[i]]=suf[i];
	pre[suf[i]]=pre[i];
	qq[i]=pii(-2,0);
	if (qq[pre[i]]==pii(-1,1)&&qq[suf[i]]==pii(-1,1)){
		--cnt[id[0]];
		int x=pre[i];
		suf[pre[x]]=suf[x];
		pre[suf[x]]=pre[x];
		qq[x]=pii(-2,0);
	}
}
void work2(int i){
	if (c1<=b2) return;
	--cnt[id[2]]; --c1;
	suf[pre[i]]=suf[i];
	pre[suf[i]]=pre[i];
	qq[i]=pii(-2,0);
	if (qq[pre[i]]==pii(-1,1)&&qq[suf[i]]==pii(-1,1)){
		--cnt[id[0]];
		int x=pre[i];
		suf[pre[x]]=suf[x];
		pre[suf[x]]=pre[x];
		qq[x]=pii(-2,0);
	}
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	q[++*q]=s[1]-'A';
	For(i,2,n)
		if (s[i]!=s[i-1])
			q[++*q]=s[i]-'A';
	For(i,1,*q) ++cnt[q[i]];
	For(i,0,2) id[i]=i;
	if (cnt[id[0]]>cnt[id[1]]) swap(id[0],id[1]);
	if (cnt[id[0]]>cnt[id[2]]) swap(id[0],id[2]);
	if (cnt[id[1]]>cnt[id[2]]) swap(id[1],id[2]);
	qq[0].fi=-1;
	For(i,1,*q)
		if (q[i]==id[0])
			qq[++top]=pii(-1,1);
		else{
			if (qq[top].fi==-1)
				qq[++top]=pii(q[i],0);
			++qq[top].se;
		}
	b1=0,b2=0,c1=0,c2=0;
	For(i,1,top){
		if (qq[i].fi!=-1)
			if (qq[i].se>=2)
				++b2,++c2;
			else if (qq[i].fi==id[1])
				++b1,++b2;
			else if (qq[i].fi==id[2])
				++c1,++c2;
	}
	//printf("%d %d %d\n",id[0],id[1],id[2]);
	//printf("%d %d %d %d\n",b1,b2,c1,c2);
	qq[0]=pii(-2,0);
	For(i,1,top) pre[i]=i-1,suf[i]=i+1;
	suf[top]=0;
	if (qq[1  ]==pii(id[1],1)) work1(1);
	if (qq[top]==pii(id[1],1)) work1(top);
	For(i,2,top-1) if (qq[i]==pii(id[1],1)) work1(i);
	if (qq[1  ]==pii(id[2],1)) work2(1);
	if (qq[top]==pii(id[2],1)) work2(top);
	For(i,2,top-1) if (qq[i]==pii(id[2],1)) work2(i);
	//assert(cnt[id[1]]<=cnt[id[2]]);
	For(i,1,top){
		if (cnt[id[2]]>cnt[id[1]])
			if (qq[i].fi>=0&&(qq[i].se>1||(qq[i].se==1&&(!suf[i]||!pre[i]))))
				if (qq[i].fi==id[2]){
					qq[i].fi=id[1];
					--qq[i].se;
					--cnt[id[2]];
				}
		if (cnt[id[2]]>cnt[id[1]])
			if (qq[i].fi>=0&&(qq[i].se>1||(qq[i].se==1&&(!suf[i]||!pre[i]))))
				if ((qq[i].fi==id[2])^((qq[i].se+1)&1)){
					--qq[i].se;
					--cnt[id[2]];
				}
	}
	For(i,1,top) for (;;){
		if (cnt[id[1]]<=cnt[id[0]]) break;
		int low=(!pre[i]||!suf[i]?1:2);
		if (qq[i].fi<0||qq[i].se<=low) break;
		qq[i].se-=2; cnt[id[1]]--; cnt[id[2]]--;
	}
	//For(i,1,top)
	//	printf("%d %d\n",qq[i].fi,qq[i].se);
	//printf("%d %d %d\n",cnt[id[0]],cnt[id[1]],cnt[id[2]]);
	//assert(cnt[0]==cnt[1]&&cnt[0]==cnt[2]);
	For(i,1,top)
		if (qq[i].fi==-1)
			putchar('A'+id[0]);
		else if (qq[i].fi>=0){
			int x=qq[i].fi;
			For(j,1,qq[i].se){
				putchar('A'+x);
				x=id[1]+id[2]-x;
			}
		}
}

Measured memory_bytes: 21760
#include <stdio.h>

void sort(int n[]);

int main(void)
{
    int i;

    int in[5];
    for (i = 0; i < 5; i++) {
        scanf(" %d", &in[i]);
    }

    sort(in);

    for (i = 0; i < 5; i++) {
        if (i != 0) {
            printf(" ");
        }
        printf("%d", in[i]);
    }
    printf("\n");

    return 0;
}

void sort(int n[])
{
    int i, j;

    int tmp;
    for (i = 0; i < 4; i++) {
        for (j = i + 1; j < 5; j++) {
            if (n[i] < n[j]) {
                tmp = n[i];
                n[i] = n[j];
                n[j] = tmp;
            }
        }
    }
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int h, w;
    cin >> h >> w;
    vector<VI> a(h, VI(w));
    FOR(i, 0, h)FOR(j, 0, w)cin >> a[i][j];

    int cnt = 0;
    string ans = "\n";
    FOR(X, 0, w) {
        if (X % 2) {
            for (int Y = h - 1; Y >= 0; Y--) {
                if (a[Y][X] % 2) {
                    if (Y - 1 >= 0 && (a[Y - 1][X] % 2 || X + 1 == w)) {
                        a[Y][X]--;
                        a[Y - 1][X]++;
                        cnt++;
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 1) + " ";
                        ans += to_string(Y) + " ";
                        ans += to_string(X + 1) + "\n";
                    }
                    else if (X + 1 < w) {
                        a[Y][X]--;
                        a[Y][X + 1]++;
                        cnt++;
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 1) + " ";
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 2) + "\n";
                    }
                }
            }
        }
        else {
            FOR(Y, 0, h) {
                if (a[Y][X] % 2) {
                    if (Y + 1 < h && (a[Y + 1][X] % 2 || X + 1 == w)) {
                        a[Y][X]--;
                        a[Y + 1][X]++;
                        cnt++;
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 1) + " ";
                        ans += to_string(Y + 2) + " ";
                        ans += to_string(X + 1) + "\n";
                    }
                    else if (X + 1 < w) {
                        a[Y][X]--;
                        a[Y][X + 1]++;
                        cnt++;
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 1) + " ";
                        ans += to_string(Y + 1) + " ";
                        ans += to_string(X + 2) + "\n";
                    }
                }
            }
        }
    }

    cout << cnt << ans;
}


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

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

  int count = 1;
  char prev = S[0];
  for (int i = 1; i < N; i++) {
    if (prev != S[i]) {
      count++;
      prev = S[i];
    }
  }

  cout << count << endl;
} 

Measured memory_bytes: 512
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
map<ll, ll> mp;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < M; i++) {
		scanf("%lld %lld", &A, &B);
		mp[A]++;
		mp[B]++;
	}	
	for(int i = 1; i <= N; i++) {
		printf("%lld\n", mp[i]);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct bipartite_matching
{
	const static int MAX_V=2100;
	int V;
	vector<int> G[MAX_V];
	int match[MAX_V];
	bool used[MAX_V];
	void add_edge(int u,int v)
	{
		G[u].pb(v);
		G[v].pb(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int i=0;i<G[v].size();i++)
		{
			int u=G[v][i],w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int matching()
	{
		int res=0;
		memset(match,-1,sizeof(match));
		for(int v=0;v<V;v++)
		{
			if(match[v]<0)
			{
				memset(used,0,sizeof(used));
				if(dfs(v))res++;
			}
		}
		return res;
	}
};
int d[105][105];
int p[1050],t[1050];
int N,M,L;
int main()
{
	while(1)
	{
		cin >> N >> M >> L;
		if(N==0&&M==0&&L==0)break;
		bipartite_matching bm;
		bm.V = 2*L;
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<N;j++)
			{
				d[i][j]=INF;
				if(i==j)d[i][j]=0;
			}
		}
		for(int i=0;i<M;i++)
		{
			int u,v,dist;
			cin >> u >> v >> dist;
			d[u][v]=dist;
			d[v][u]=dist;
		}
		for(int k=0;k<N;k++)
		{
			for(int i=0;i<N;i++)
			{
				for(int j=0;j<N;j++)
				{
					d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
				}
			}
		}	
		for(int i=0;i<L;i++)cin >> p[i] >> t[i];
		for(int i=0;i<L;i++)
		{
			for(int j=0;j<L;j++)
			{
				if(t[i]<t[j]&&d[p[i]][p[j]]<=t[j]-t[i])bm.add_edge(i,j+L);
			}
		}
		cout << L - bm.matching() << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "AC")
      a++;
    else if (S == "WA")
      b++;
    else if (S == "TLE")
      c++;
    else
      d++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    bool possible = true;
    int now = n;
    vector<int> way;
    while (now > 0) {
        bool move = false;
        for (int i = m; i > 0; i--) {
            if (now - i >= 0 && s[now - i] == '0') {
                move = true;
                now -= i;
                way.push_back(i);
                break;
            }
        }
        if (!move) {
            possible = false;
            break;
        }
    }

    if (!possible) {
        cout << -1 << endl;
        return 0;
    }
    reverse(way.begin(), way.end());
    for (int i = 0; i < way.size(); i++) {
        if (i > 0)cout << " ";
        cout << way[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1144
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];  //Aという配列を作成。N＋1個の配列がある。

//	いずれかのAに0が含まれる場合
		for(int i=0 ; i<N ; i++) {
			A[i]=sc.nextLong();  //入力された配列の読み込み
			if(A[i] == 0) {
				System.out.println(0);
				return;
			}
		}

//	Aへの入力の時点で結果が「-1」になる場合を判断
//	「-1」にならんかったら下の処理に続く
		long total = 1;  //計算結果を表す変数
		for(int i=0 ; i<N ; i++) {
			if(A[i] > 1000000000000000000L / total) {  //1000...を超える値が変わってくるからtotalで割ってる
				System.out.println(-1);
				return;
			}
			else {
				total *= A[i];
			}
		}

		System.out.print(total);

//	計算し終わった段階でtotalの表示をする
//
//		if(total <= 1000000000000000000L) {
//			System.out.print(total);
//		}
//		else {
//			System.out.print(-1);
//		}
	}
}

Measured memory_bytes: 61264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main (){
	std::map<std::string, int> s;

	s["SUN"] = 7;
	s["MON"] = 6;
	s["TUE"] = 5;
	s["WED"] = 4;
	s["THU"] = 3;
	s["FRI"] = 2;
	s["SAT"] = 1;

	std::string t;

	std::cin >> t;

	std::cout << s[t] << std::endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7
def prime_table(n):
  if n <= 1:
    return [],[],[]
  prime = [2]
  limit = int(n**0.5)
  data = [i+1 for i in range(2,n,2)]
  isprime = [0]*(n+1)
  isprime[2] = 1
  min_factor = [0 if i%2 != 0 else 2 for i in range(n+1)]
  while True:
    p = data[0]
    prime.append(p)
    isprime[p] = 1
    pdata,data = data,[]
    for e in pdata:
      if e%p != 0:
        data.append(e)
      else:
        min_factor[e] = p
    if limit <= p:
      for i in data:
        isprime[i] = 1
        min_factor[i] = i
      return prime + data,isprime,min_factor
def modinv(a,m=MOD):
  b,u,v = m,1,0
  while b:
    t = a//b
    a,u = a-t*b,u-t*v
    a,b,u,v = b,a,v,u
  u %= m
  if u < 0:
    u += m
  return u
ma = max(a)
data,isprime,min_factor = prime_table(ma)
prime = [0] * (ma+1)
for i in a:
  if i == 1:
    continue
  d = defaultdict(int)
  while isprime[i] == 0:
    d[min_factor[i]] += 1
    i = i // min_factor[i]
  d[i] += 1
  for j,k in d.items():
    prime[j] = max(prime[j],k)
lcm = 1
for i in range(ma+1):
  if prime[i] != 0:
    lcm = (lcm*pow(i,prime[i],MOD))%MOD
c = 0
for i in a:
  c += lcm*modinv(i,MOD)
  c %= MOD
print(c)

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	map<string,int> m;
	while(n--) {
		string s;
		cin >> s;
		++m[s];
	}
	cout << "AC x " << m["AC"] << '\n';
	cout << "WA x " << m["WA"] << '\n';
	cout << "TLE x " << m["TLE"] << '\n';
	cout << "RE x " << m["RE"];

	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
   cin.tie(0);  
   ios::sync_with_stdio(false);
   int n;
   int a[21],b[21],c[21];
   cin>>n;
   FOR(i,n){
     cin>>a[i];
     a[i]--;
   }
   FOR(i,n){
     cin>>b[i];
   }
   FOR(i,n-1){
     cin>>c[i];
   }
   int ans=0;
   FOR(i,n){
     ans+=b[a[i]];
     if(i!=0 && a[i]==a[i-1]+1){
       ans+=c[a[i-1]];
     }
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=str(input())
    while True:
        if s[0]!='A':
            print('WA')
            break


        if s[2:-1].count('C')!=1:
            print('WA')
            break
        else:
            s=s[0:s.index('C')]+s[s.index('C')+1:]
            if s==s.capitalize():
                print('AC')
                break
            else:
                print('WA')
                break





resolve()

Measured memory_bytes: 3060
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

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

int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int x, k, d; cin >> x >> k >> d;
    x = abs(x);
   	if (k >= x / d) {
   		int m = x % d, n = (k - x / d) & 1;
   		if (n == 1) {
   			cout << d - m << endl;
   		} else {
   			cout << m << endl;
   		}
   	} else {
   		int t = x - k * d;
   		cout << t << endl;
   	}

    return 0;
}


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


using namespace std;
const int N=1e5+55;
int dp[155][N];
int a[N];
int pre[N];
int m=1e9+7;


int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int j=0;j<=a[0];j++)
    {
        dp[0][j]=1;
    }
    for(int i=1;i<n;i++)
    {
        pre[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
            pre[j]=(dp[i-1][j]+pre[j-1])%m;
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=(m+pre[j]-(a[i]<j?pre[j-a[i]-1]:0))%m;
        }
    }
    cout<<dp[n-1][k]<<endl;
    return 0;
}


Measured memory_bytes: 40832
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var K = input[1];

            var i = 0;

            while (true)
            {
                if (Math.Pow(K, i) > N)
                {
                    Console.WriteLine(i);
                    return;
                }
                i++;
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 998244353;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };


int main () {
  int N,S;cin>>N>>S;
  vector<int> a(N);
  rep(i,N) cin>>a[i];
  vector<ll> F(S+1,0),pre(S+1,0);
  ll ans = 0;
  rep(i,N) {
    pre[0] += 1;
    F = pre;
    rep(j,S+1) {
      if(j+a[i] <= S){
	F[j+a[i]] += pre[j];
	F[j+a[i]] %= MOD;
      }
    }
    pre = F;
    ans = (ans + F[S]) % MOD;
  }
  cout << ans << endl; 
}

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

int main(){
 int n,q,a,b,c;
  cin >> n >> q;
  vector<int> v[n];
  
  while(q--){
    cin >> a >> b;
    if(!a){
      cin >> c;
      v[b].push_back(c);
    }
    else if(a==1){
      r(i,v[b].size()){
        if(i) cout<< " ";
        cout << v[b][i];
      }
      cout << endl;
    }
    else v[b].clear();
  }
}


Measured memory_bytes: 5780
class Circle(val x:Int,val y:Int,val r:Int)
{
    fun checkX(width:Int):Boolean{
        val left=x-r
        val right=x+r

        return left>=0 && left<=width && right>=0 && right<=width
    }

    fun checkY(height:Int):Boolean{
        val top=y+r
        val bottom=y-r

        return top>=0 && top<=height && bottom>=0 && bottom<=height
    }

    fun check(width:Int,height: Int)=if(checkX(width)&&checkY(height)) "Yes" else "No";
}



fun main(args:Array<String>) {

    val input = readLine() ?: "";

    val params = input.split(' ').map { it.toInt() }.toIntArray()

    val c = Circle(params[2], params[3], params[4])

    println(c.check(params[0], params[1]))

}




Measured memory_bytes: 33964
#include <iostream>

using namespace std;

#define ll long long int

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

  ll c = b*b-a*a;
  ll d = 2*(b-a);

  if(c%d) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  cout << c/d << endl;

  return 0;
}


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

int main() {
  string S, T; cin >> S >> T;
  bool ans = true;
  int Ssize = S.size();
  for (int i = 0; i < Ssize; i++) {
    if (S[i] == T[i]) continue;
    else {ans = false; break;}
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, a, b;
  cin >> n >> m;
  vector< vector<int> > v(n+1);
  for(int i=0;i<m;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool f = false;
  for(int i=0;i<v[1].size();i++){
    for(int j=0;j<v[v[1][i]].size();j++){
      if(v[v[1][i]][j] == n) f = true;
    }
  }
  cout << (f?"POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 12016
#include<bits/stdc++.h>
#include <iostream>
#include <list>
#define ll long long int
using namespace std;
int main()
{
    int a; cin>>a;
    int i,m;
    for(i=1;i<=9;i++)
    {
        if(a%i==0)
        {
            if(a/i<=9) {m=1;break;}
            else m=0;
        }
    }
    if(m)cout<<"Yes\n";
    else cout<<"No\n";
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>>
using namespace std;
int main() {
  char c;
  cin >>c;
  if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
    cout << "vowel" <<endl;
  }
  else {
    cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 256
def is_valid(m, a, b):
    for i in range(3):
        for j in range(3):
            if (m[i][j] != a[i] + b[j]):
                return 0
    return 1


m = []
for a0 in range(3):
    m.append(list(map(int, input().split())))

for a0 in range(101):
    b0 = m[0][0] - a0
    b1 = m[0][1] - a0
    b2 = m[0][2] - a0
    a1 = m[1][0] - b0
    a2 = m[2][0] - b0
    if (is_valid(m, [a0, a1, a2], [b0, b1, b2])):
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9136