akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL A(3*N); REP(i,3*N) cin >> A[i];
    VL dp(3*N+1,0);

    priority_queue<LL,vector<LL>,greater<LL>> que;
    LL sum = 0;
    REP(i,3*N){
        que.push(A[i]);
        sum += A[i];
        if(que.size()>N){
            sum -= que.top();
            que.pop();
        }
        dp[i] = sum;
    }
    priority_queue<LL> que2;
    sum = 0;
    for(int i = 3*N-1; i >= 0; i--){
        que2.push(A[i]);
        sum += A[i];
        if(que2.size() > N){
            sum -= que2.top();
            que2.pop();
        }
        if(i >= 1) dp[i-1] -= sum;
    }

    REP(i,3*N) dump(dp[i])
    LL ans = dp[N-1];
    for(int i = 0; i <= N; i++){
        ans = max(dp[i+N-1], ans);
    }
    cout << ans << endl;

}

Measured memory_bytes: 7284
from collections import Counter
n=int(input())
ls=[]
ans=0
for i in range(n):
    s=list(input())
    s.sort()
    ls.append("".join(s))
c=Counter(ls)
for i in c.values():
    if i>1:
        ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 19828
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            out.printf("ABC%d\n", n);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 23380
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    T = input()
    n = len(S)
    l = len(T)
    K = []
    for i in range(n-l+1):
        s = S[i:i+l]
        candidate = True
        for c1, c2 in zip(s, T):
            if c1 != '?' and c1 != c2:
                candidate = False
        if candidate:
            K.append(i)
    if len(K) == 0:
        print('UNRESTORABLE')
        return
    top = K[-1]
    f = S[:top].replace('?', 'a')
    t = S[top+l:].replace('?', 'a')
    print(f + T + t)
    pass

if __name__ == '__main__':
    main()


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

using namespace std;

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

typedef long long int ll;


int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string str;

	cin >> str;
	int maxCount = 0;
	for(int i=1 ; i<str.size() ; i++)
	{
		int present[26] = {};
		for(int j=0 ; j<=i-1 ; j++)
		{
			present[str[j]-'a'] = 1;
		}

		int present1[26] = {};
		for(int j=i ; j<str.size() ; j++)
		{
			present1[str[j]-'a'] = 1;
		}

		int count = 0;
		for(int j=0 ; j<26 ; j++)
		{
			if(present[j] == present1[j] && present[j] == 1)
				count++;
		}
		maxCount = max(maxCount , count);
	}
	cout << maxCount;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
LRC = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for l,r,c in LRC:
    l,r = l-1,r-1
    es[l].append((r,c))
for i in range(1,N):
    es[i].append((i-1,0))

import heapq
hq = [(0,0)]
INF = float('inf')
cost = [INF] * N
cost[0] = 0
while hq:
    d,v = heapq.heappop(hq)
    for to,c in es[v]:
        if cost[to] <= d+c: continue
        cost[to] = d+c
        heapq.heappush(hq, (d+c,to))

print(-1 if cost[-1]==INF else cost[-1])

Measured memory_bytes: 61108
a,b,k = map(int,input().split())
ans = []
ans.append(a)
ans.append(b)
for i in range(min(k,b-a)):
    ans.append(a+i)
    ans.append(b-i)
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)
# print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int str[101];
int main()
{
	int i,a,b,c;
	int n=0;
	scanf("%d %d %d",&a,&b,&c);
	str[a]++;
	str[b]++;
	str[c]++;
	for(i=0 ; i<101 ; i++)
	{
		if(str[i]>0) n++;
	}
	printf("%d",n);
	return 0;
}

Measured memory_bytes: 128
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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



int main() {
    int count = 0;

    string s;     // 置換対象の文字列
    cin >> s;
    int n=s.length();
REP(i,n)
{
    if(s[i]=='1') ++count;
}

cout<<2*min(count,n-count)<<endl;
    }


Measured memory_bytes: 512
import Control.Monad
cs = ['a' .. 'z']

solve :: [String]->Char->(Char,Int)
solve ss c = (c, minimum $ map (length . filter (== c)) ss)

unpack :: [(Char,Int)] -> String
unpack [] = []
unpack ((c,n):cs) = (unpack cs) `mappend` (replicate n c)

main = do
  n <- readLn
  ss <- replicateM n getLine
  let
    ts = (map (solve ss) cs)
    in putStrLn $ reverse $ unpack ts


Measured memory_bytes: 892
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
result=0
for i in range(2**n):
	flag=1
	for j in range (m):
		count=0
		for k in range (s[j][0]):
			if (i>>(s[j][k+1]-1))&1 ==1:
				count+=1
		if count%2!=p[j]:
			flag=0
	if flag==1:
		result+=1
print(result)

Measured memory_bytes: 41584
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
    ll n;
    cin>>n;
    ll count=0;

    //nが２で割り切れるときは5を数える
    if(n%2==0){
        for(int i=1;;i++){
            ll now=pow(5,i)*2;
            count+=n/(now);
            if(now>=n) break;
        }
        cout<<count<<endl;
    }else{
        cout<<0<<endl;
    }

    

    
}

Measured memory_bytes: 256
#085 C

N,Y = map(int, input().split())
A =10000
B =5000
C =1000

for i in range((N)+1):
    for j in range(N+1-i):
        k = N-(i+j)
        if i * A + j * B + k * C == Y and k >= 0:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
                
print("-1 -1 -1")

Measured memory_bytes: 3064
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    int t;
    Scanner sc=new Scanner(System.in);
    Set<String> st=new HashSet<>();
    t=sc.nextInt();
    for(int i=0;i<t;i++)
    {
          st.add(sc.next());}
    System.out.println(st.size());
  }}

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

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

    vector<int> city(N, 0);
    rep(i, M) {
        int city1, city2;
        cin >> city1 >> city2;
        city.at(city1 - 1)++;
        city.at(city2 - 1)++;
    }
    rep(i, N) {
        cout << city.at(i) << endl;
    }
}

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

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

    long long b_count = 0;
    long long ans = 0;
    rep(i,(int)S.size()){
        char c = S[i];
        if( c == 'B'){
            b_count += 1;
        }else{
            ans += b_count;
        }
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3696
#include <iostream>
#include <cmath>
#include <iomanip>

int main()
{
    using namespace std;
    double r;

    cin >> r;
    
    //double pi = 3.14159265;
    
    cout << fixed << setprecision(5)<<r*r*M_PI;
    cout << " " ;
    cout <<fixed << setprecision(5)<<2*r*M_PI<<endl;
    
    return 0;
}


Measured memory_bytes: 3276
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
		sc.close();
		Arrays.sort(a);
		long aa = 0 , bb = 0;
		int now = n - 1;
		while(now > 0 && a[now] != a[now - 1]) now--;
		aa = a[now];
		now -= 2;
		if(now == 0) ou.println(0);
		else{
			while(now > 0 && a[now] != a[now - 1]) now--;
			if(now >= 0) bb = a[now];
			ou.println(aa * bb);
		}
		ou.flush();
	}
}

Measured memory_bytes: 59788
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using Um = unordered_map<char,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;


#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> S(1LL<<N,0);
    for(ll i=0;i<(1LL<<N);++i)cin>>S[i];
    sort(S.rbegin(), S.rend());
    unordered_multiset<ll> selected;
    multiset<ll> notyet;
    selected.insert(S[0]);
    for(ll i=1;i<(1LL<<N);++i){
        notyet.insert(S[i]);
    }
    //for(auto p: selected)cout<<p<<" ";cout<<endl;
    for(ll i=0;i<N;++i){
        unordered_multiset<ll> select;
        for(auto p: selected){
            auto x=notyet.lower_bound(p);
            if(x==notyet.begin()){
                prt("No");
                return 0;
            }
            --x;
            select.insert(*x);
            notyet.erase(x);
        }
        for(auto p: select){
            selected.insert(p);
        }
        //for(auto p: selected)cout<<p<<" ";cout<<endl;
    }
    prt("Yes");

    return 0;
}



Measured memory_bytes: 26984
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back


signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(n), w(n);
    rep(i,n)cin>>w[i]>>v[i];
    
    map<int,int> dp;
    dp[0] = 0;
    
    rep(i,n){
        int V = v[i];
        int W = w[i];
        
        map<int,int> tmp = dp;
        
        for(auto it = dp.begin(); it!=dp.end(); it++){
            if(it->first+W<=m)tmp[it->first+W] = max(it->second + V, tmp[it->first+W]);
        }
        dp = tmp;
    }
    int ans = -1;
    for(auto it = dp.begin(); it!= dp.end(); it++){
        if(it->first>m)continue;
        ans = max(ans,it->second);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok=true;
    rp(i,a){
        if(s[i]-'0'<0||s[i]-'0'>9) ok=false;
    }
    if(s[a]!='-') ok=false;
    rp(i,b){
        if(s[i+a+1]-'0'<0||s[i+a+1]-'0'>9) ok=false;
    }
    Yes(ok);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};


void solve(long long K){
    vi a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    cout << a[K-1] << endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string a;
    cin >> a;
    if (a[0] == 'A'&&a[1] == 'C') {
        cout << "Yes" << endl;
        return 0;
    }
    if (a[1] == 'A'&&a[2] == 'C') {
        cout << "Yes" << endl;
        return 0;
    }
    if (a[2] == 'A'&&a[3] == 'C') {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define trace(x) cout << '>' << #x << ':' << x << "\n" 
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n" 
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n" 
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n" 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl '\n' 
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int N = 2e5 + 5;

int n,a[N],b[N];

int main()
{
    fastIO;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) cin >> b[i];
    reverse(b, b + n);

    int l = -1, r = -1, val = -1;
    for(int i = 0; i < n; ++i)
    {
        if(a[i] == b[i])
        {
            val = b[i];
            if(l == -1) l = i;
            r = i;
        }
    }
    //cout << l << " " << r << " " << val << endl;

    for(int i = 0; i < n; ++i)
    {
        if(a[i] != val && b[i] != val && l <= r && val != -1)
        {
            swap(b[i],b[l]);
            l++;
        }
    }


    if(l <= r && l != -1) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for(int i = 0; i < n; ++i) cout << b[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 5100
a, b, c, d = map(int, input().split())

aoki = c
takahashi = a

for i in range(101):
  if aoki - b > 0: #高橋の攻撃
    if takahashi - d <= 0: #青木の攻撃で高橋負け
      print("No")
      break
    else: #戦闘続く
      takahashi = takahashi - d
      aoki = aoki - b
      continue
  else: #高橋勝ち
    print("Yes")
    break

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n,tmp;
  vector<int> a;
  float sum;
  float as = 101;
  float fl = 0;
  int ans = 0;
  
  cin >> n;
  REP(i,n){
     cin >> tmp;
     a.pb(tmp);
    }
    REP(j, a.size()) sum += a[j];
    sum /= n;
    REP(k, n){
      fl = abs(sum - a[k]);
      if(fl < as){ 
      as = fl;
      ans = k;
        }
      }   
      cout << ans << endl;
      return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll X , K , D ;

    cin >> X >> K >> D ;
    X = abs(X);
    if(abs(X) / D  >= K){
        cout << abs (X -  D * K) << endl;
    }else{
        K -= abs (X) / D ;
        ll absd = abs(X - D * (abs (X  ) / D) ) ;
        if(K%2 == 0){
            cout << absd << endl;
        }else{
            cout << abs(D - absd) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3616
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;


#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int ) 1e5 + 10 , mod = ( int )1e9 + 7 ;

int n , sum = 0 , resx , resy , m ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m ; 
	for ( int j = 0 ; j < n ; ++j ) {
		int x ;
		cin >> x ;
		resx += (j * x % mod) - sum ;
		while ( resx < 0 )
			resx += mod ;
		resx %= mod ; 
		sum += x ;
		sum %= mod ; 
	}
	sum = 0 ;
	for ( int j = 0 ; j < m ; ++j ) {
		int x ;
		cin >> x ;
		resy += (j * x % mod) - sum ;
		while ( resy < 0 )
			resy += mod ;
		resy %= mod ; 
		sum += x ;
		sum %= mod ; 
	}
	cout << resx * resy % mod << '\n' ; 
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

ll lcmll(ll a, ll b)
{
    return a * b / (gcdll(a, b));
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

    ll l = gcdll(n, m), res = n * m / l;
    n /= l;
    m /= l;

    rep(i, 0, l)
    {
        if (s[i * n] != t[i * m])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

int x, y;

int main() {
    cin >> x >> y;
    if (x % y == 0) {
        puts("-1");
    } else {
        for (LL i = 2; ; ++i) {
            if (i * x % y) {
                printf("%lld\n", i * x);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d[500];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>d[i];
    }
    long long sum=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

int main() {
	int a, b,num,keta[4],count;
	cin >> a >> b;
	count = 0;

	for (int i = a; i <= b; i++) {
		num = i;
		keta[0] = num / 10000;
		num %= 10000;
		keta[1] = num / 1000;
		num %= 1000;
		keta[2] = num / 100;
		num %= 100;
		keta[3] = num / 10;
		num %= 10;

		
		if (keta[0] == num && keta[1] == keta[3]) {
			count++;
		}
	}
	
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
from math import gcd

def mod_prod(X,M):
    c=1
    for x in X:
        c*=x
        c%=M
    return c

N=int(input())
A=list(map(int,input().split()))
Mod=10**9+7

E=[0]*N
a=1
for i in range(N):
    E[i]=A[i]//gcd(a,A[i])
    a*=E[i]

P=mod_prod(E,Mod)

Q=0
for a in A:
    Q+=pow(a,Mod-2,Mod)
    Q%=Mod
print((P*Q)%Mod)

Measured memory_bytes: 74540
#include<stdio.h>
int main()
{int n,i,x[100];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&x[i]);}
for(i=n;i>0;i--){
printf("%d",x[i-1]);
if(i!=1)printf(" ");}
puts(""); return 0;}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    //vector<ll>a(N);
    ll cnt4=0,cnt2=0;
    rep(i,N){
        ll a;
        cin>>a;
        if(a%4==0){
            cnt4++;
        }else if(a%2==0){
            cnt2++;
        }
    }
    if(N<= cnt4*2+1){
        cout<<"Yes"<<endl;
        return 0;
    }else if(N<=cnt4*2+cnt2){
        cout<<"Yes"<<endl;
        return 0;
    }



    cout << "No" << endl;


    return 0;
    

}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll h, w;
  cin >> h >> w;
  vector<vector<char> > pf(h+2, vector<char>(w+2));
  rep(i, 0, h+2) {
    rep(j, 0, w+2) {
      if(i==0 or j==0 or i==h+1 or j==w+1)
        pf[i][j] = '#';
      else cin >> pf[i][j];
    }
  }
  rep(i, 0, h+2) {
    rep(j, 0, w+2) {
      cout << pf[i][j];
    }
    cout << "\n";
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            in = sc.next().toCharArray();
            p = 0;     
            System.out.println(expr());            
        }
    }

    int expr(){
        int a = term();
        while(in[p]=='+' || in[p]=='-'){
            boolean boo = in[p]=='+';
            p++;
            int b = term();
            if(boo) a += b;
            else a -= b;
        }
        return a;
    }

    int term(){
        int a = factor();
        while(in[p]=='*' || in[p]=='/'){
            boolean boo = in[p]=='*';
            p++;
            int b = factor();
            if(boo) a *= b;
            else a /= b;
        }
        return a;
    }

    int factor(){
        if(in[p]=='('){
            p++;
            int res = expr();
            p++;
            return res;
        }
        else return digit();
    }

    int digit(){
        int res = 0;
        while(Character.isDigit(in[p])){
            res = res*10 + (in[p]-'0');
            p++;
        }
        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 17176
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

ll A[200001] = {};
int main() {
	ll N, K; cin >> N >> K;

	rep(i, 0, N) {
		ll a; cin >> a;
		A[a]++;
	}
	sort(A, A + 200001);
	reverse(A, A + 200001);

	ll type = 0;
	ll sum = 0;
	rep(i, 0, N) {
		if (++type > K) {
			break;
		}
		sum += A[i];
	}
	cout << N - sum << endl;
	return 0;
}

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

int main(int argc, char const *arga[]) {
  int n,l;
  cin>>n>>l;
  int a[n];
  iota(a,a+n,l);
  int max=accumulate(a,a+n,0);
  if(a[0]<=0&&a[n-1]>=0){
    cout<<max<<endl;
  }else if(a[0]>0){
    cout<<max-a[0]<<endl;
  }else{
    cout<<max-a[n-1]<<endl;
  }
  return 0;
}


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

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,m,p[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <int> vec;
set <int> s;
map <int,int> M;

pair<string,LL> pl[KL];


int main()
{
    scl(n);
    for(int i=0;i<n;i++)
    {
        cin>>pl[i].F;scl(pl[i].S);
    }
    cin>>t;
    LL sum=0;
    for(int i=0;i<n;i++)
    {
        if(t==pl[i].F)
        {
            for(int j=i+1;j<n;j++)sum+=pl[j].S;
            break;
        }
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 16640
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

struct node{
	int l,r;
}a[100010];

bool cmp(node a,node b){
	return a.l<b.l;
}

int main()
{
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=1;i<=m;i++){
		cin>>a[i].l>>a[i].r;
	}
	
	sort(a+1,a+1+m,cmp);
	int l=a[1].l,r=a[1].r;
	ans=1;
	for(int i=2;i<=m;i++){
		if(a[i].l>l) l=a[i].l;
		if(a[i].r<r) r=a[i].r;
		if(l>=r){
			ans++;
			l=a[i].l;
			r=a[i].r;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define P pair<int, int>
typedef long long ll;
using namespace std;

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2 == 1)co("No");
	else if (s.substr(0, n / 2) == s.substr(n / 2, n/ 2))co("Yes");
	else co("No");
	return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 105;
int n, a[MX], b[MX], c[MX], d[MX];
int to[MX], vis[MX];

int tk (int u) {
	if (vis[u]) return 0;
	vis[u] = 1;

	forn (v, n)
		if (a[u] < c[v] && b[u] < d[v] && to[v] == -1) {
			to[v] = u;
			return 1;
		}

	forn (v, n)
		if (a[u] < c[v] && b[u] < d[v] && tk(to[v])) {
			to[v] = u;
			return 1;
		}

	return 0;
}

int maxmat () {
	memset(to, -1, sizeof(to));
	int res = 0;

	forn (i, n) {
		memset(vis, 0, sizeof(vis));
		res += tk(i);
	}

	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n) cin >> a[i] >> b[i];
	forn (i, n) cin >> c[i] >> d[i];

	cout << maxmat() << endl;

	return 0;
}

Measured memory_bytes: 256
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e5+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

LL a,b,c;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>a>>b>>c;
	ans=1;
	if(b!=a)ans++;
	if(c!=a&&c!=b)ans++;
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String inputed = new String(in.readLine());

		String value[] = inputed.split("[\\s]+");
		int tate = Integer.parseInt(value[0]);
		int yoko = Integer.parseInt(value[1]);

		int fill = tate * yoko;
		int around = tate * 2 + yoko * 2;

		System.out.println(fill + " " + around);



	}
}

Measured memory_bytes: 24352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,K,X,Y;
ll res=0;
int main()
{
	cin>>N>>K>>X>>Y;
	if(N>K)
		res=K*X+(N-K)*Y;
	else
		res=N*X;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
/* Krishna */
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <cstdlib>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n==0)
        cout<<"1";
    else
        cout<<"0";
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<=n;i++)
#define f_(i,a,n) for(ll i=a;i>=n;i--)
char ita(int i)
{
   return static_cast<char>('a' + i);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    ll n,m,j=1,count=0;
    cin>>n;
    m=n-1;
    if(n==1)
    cout<<'a'<<endl;
    else
      {
      while(m>0)
      {
        j=j*26;
        count++;
        if(m==j)
        {
          f(i,0,count)
          cout<<'a';
          break;
        }
        if(m/j>0)
        {
          m=m-j;
        }
        else
        {
          n=m;
          m=0;
        }
      }
      if(m!=0)
      {
        cout<<endl;
        return 0;
      }
      m=n;
      j=j/26;
      ll k=0;
      while(j>1)
      {
        k=m/j;
        m=m%j;
        cout<<ita(k);
        j=j/26;
      }
      cout<<ita(m)<<endl;
  }
}

Measured memory_bytes: 3672
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		double sum = 0;
		PriorityQueue<Integer> pq = new PriorityQueue<> (Collections.reverseOrder());
		
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			sum += Ai;
			pq.add(Ai);
		}
		
		double threshold = sum / (4 * M);
		
		boolean result = true;
		for (int i = 0; i < M; i++) {
			if (pq.poll() < threshold) {
				result = false;
				break;
			}
		}
		// 結果の出力
		System.out.println(result?"Yes":"No");

		sc.close();
	}

}


Measured memory_bytes: 23764
#include <stdio.h>
int main()
{
    int a,b,c,aa;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        aa=a;
        a=b;
        b=aa;
    }
    if(b>c){
        aa=b;
        b=c;
        c=aa;
    }
    if(a>b){
        aa=a;
        a=b;
        b=aa;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
S = input()

# assertion 1
if S[0] != "A":
    print("WA")
    exit(0)

# assertion 2
count = 0
C_index = None
for i, char in enumerate(S[2:-1], start=2):
    if char == "C":
        count += 1
        C_index = i
    else:
        continue
if count != 1:
    print("WA")
    exit(0)

# assertion 3
discard_indices = {0, C_index}
S_the_others = "".join([char for i, char in enumerate(S) if i not in discard_indices])
if not S_the_others.islower():
    print("WA")
    exit(0)

print("AC")


Measured memory_bytes: 3064
/*
PROG: apc001e
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long mod)
{
	return ((1 << 30) * rand() + (1 << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-20;

#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 100010

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
vector<int> edge[MAXN];
int parent[MAXN];
bool line[MAXN];
int ans;

void dfs_par(int u)
{
	for (int v : edge[u])
	{
		if (v == parent[u])
		{
			continue;
		}
		parent[v] = u;
		dfs_par(v);
	}
}
void solve(int u)
{
	int lines = 0;
	for (int v : edge[u])
	{
		if (v == parent[u])
		{
			continue;
		}
		if (line[v])
		{
			lines++;
		}
		else
		{
			solve(v);
		}
	}
//	cerr << u << ' ' << lines << endl;
	ans += max(0, lines - 1);
}

int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("apc001e.in", "r"))
	{	
		freopen ("apc001e.in", "r", stdin);
		freopen ("apc001e.out", "w", stdout);
	}
	cin >> N;
	for (int i = 1; i < N; i++)
	{
		int u, v;
		cin >> u >> v;
		edge[u].PB(v);
		edge[v].PB(u);
	}
	int root = -1;
	for (int i = 0; i < N; i++)
	{
		if (edge[i].size() > 2)
		{
			root = i;
		}
	}
	if (root == -1)
	{
		cout << "1\n";
		return 0;
	}
	parent[root] = N;
	dfs_par(root);
	for (int i = 0; i < N; i++)
	{
		if (edge[i].size() > 1)
		{
			continue;
		}
		int v = i;
		while(edge[v].size() <= 2)
		{
			line[v] = true;
			v = parent[v];
		}
	}
	solve(root);
	cout << ans << '\n';
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
int main(void){
    long int N,sum=0,i;
    
    scanf("%ld",&N);
    
    for(i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0){
            sum=sum+i;
        }
    }
    
    printf("%ld\n",sum);
    
    return 0;
}

Measured memory_bytes: 2152
<?php

$input = trim(fgets(STDIN));
$z = explode(' ', $input);

$a = $z[0];
$b = $z[1];
$x = $z[2];

if ($x < $a * $a * $b / 2) {
    // a * b * c = x
    $c = $x / ($a * $b / 2);
    echo 90- rad2deg(atan2($c, $b));
} else {
    $d = 2 * ($b - $x / ($a * $a));
    echo rad2deg(atan2($d, $a));
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin >> s;
    ll a = 0;
    for (ll i = 1; i < sz(s);i++){
        if(s[i]!=s[i-1])a++;
    }
    ll b = 0;
    for (ll i = sz(s) - 2; i >= 0; i--){
        if(s[i]!=s[i+1])b++;
    }
    ll ans = min(a, b);
    print(ans);
}

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

int main(){
  string S;
  cin >> S;
  bool flag = false;
  int ssize = S.size();
  set<int> a;
  for(int i = 'a'; i <= 'z'; i++){
    a.insert(i);
  }
  for(int i = 0; i < ssize; i++){
    a.erase(S.at(i));
  }
  if(a.size()) cout << (char)*begin(a) << endl;
  else cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>                                          
#include <cstdio>                                            
using namespace std;                                         
                                                             
int main(void) {                                             
  int H, W;                                                  
  while (true) {                                             
    cin >> H >>W;                                            
    if (H==0 && W==0) {                                      
      break;                                                 
    }                                                        
    for (int i=0; i<H; i++) {                                
      for(int j=0; j<W; j++) {                               
        printf("#");                                         
      }                                                      
      printf("\n");                                          
    }                                                        
    printf("\n");                                            
  }                                                          
  return 0;                                                  
}                

Measured memory_bytes: 3044
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n,T;
  cin >>n >>T;
  int ans = 1e9;
  for(int i = 0; i < n;i++) {
    int c, t;
    cin >> c>>t;
    if(t <= T) ans = min(ans, c);
  }
  if(ans == 1e9) cout << "TLE" << endl;
  else cout << ans << endl;
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  if(S == "RRR")
  {
    cout << "3" << endl;
  }
  else if(S == "RRS" || S == "SRR")
  {
    cout << "2" << endl;
  }
  else if(S == "SSS")
  {
    cout << "0" << endl; 
  }
  else
  {
    cout << "1" << endl;
  }
}

Measured memory_bytes: 3592