akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    string top, under;
    cin >> top >> under;
    reverse(ALL(under));
    if (top == under) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for n in range(N)]
B = [int(input()) for n in range(N)]
A.sort()
B.sort()
A.append(10**10) #門番
B.append(10**10) #門番
mod = 7 + 10**9
ANU, BNU = 0, 0 #A not used, B not used
Total = 1
 
ai, bi = 0, 0
if A[0] < B[0]:
    ANU += 1
    ai += 1
else:
    BNU += 1
    bi += 1
while ai < N or bi < N:
    if A[ai] < B[bi]:
        if BNU == 0:
            ANU += 1
        else:
            Total *= BNU
            Total %= mod
            BNU -= 1
        ai += 1
    else:
        if ANU == 0:
            BNU += 1
        else:
            Total *= ANU
            Total %= mod
            ANU -= 1
        bi += 1
print(Total)

Measured memory_bytes: 11364
A, B = map(int, input().split())
import collections

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

Af = collections.Counter(factorize(A))
Bf = collections.Counter(factorize(B))

Ak = Af.keys()
Bk = Bf.keys()

print(len(set(Ak) & set(Bk))+1)

Measured memory_bytes: 3444
from math import factorial

mod = 10 ** 9 + 7
n, m = map(int, input().split())
print(
    ((factorial(n) % mod) ** 2 % mod) * 2 % mod
    if n == m
    else (factorial(n) % mod) * (factorial(m) % mod) % mod
    if abs(n - m) == 1
    else 0
)

Measured memory_bytes: 10024
#include <stdio.h>

int main(void){
  int n,i,j,ans=0,x[10000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }

  for(i=0;i<n;i++){
    if(x[i]%2!=0 && x[i]>3073){
      for(j=3;j<x[i]/64;j+=2){
	if(x[i]%j==0){
	  break;
	}
      }
      if(j>=x[i]/64){
	ans++;
      }
    }
    else if((x[i]%2!=0 && x[i]<=3073) || x[i]==2){
      for(j=3;j<x[i];j+=2){
	if(x[i]%j==0) break;
      }
      if(x[i]<=j || x[i]==2){
	ans++;
      }
    }
  }
  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p,sum=0;

    cin>>n>>m;
    long long int a[m];
    for (int i=0;i<m;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if (sum>n)
        cout<<-1<<endl;
    else if (sum==n)
        cout<<0<<endl;
   else{
        cout<<n-sum<<endl;











   }










    return 0;
}


Measured memory_bytes: 3696
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;

	bool good = true;
	foreach (i; 1..4)
	{
		if (S[i] == S[i-1])
			good = false;
	}

	writeln(good ? "Good" : "Bad");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = [[0]*n for i in range(k)]

for i in range(k) :
    n_i = int(input())
    a = list(map(int,input().split()))
    a = [i-1 for i in a]
    for j in range(n_i) :
        s[i][a[j]] = 1

ans = 0
for i in range(n) :
    check = 1
    for j in range(k) :
        if s[j][i] == 1 :
            check = 0
            break
    if check == 1 :
        ans += 1

print(ans)

Measured memory_bytes: 69188
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<String> set = new HashSet<>();

    for(int i =0; i<n; i++){
          set.add(sc.next());
    }

    System.out.println(set.size());






  }
}

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

using namespace std;
int mini(int a,int b){
if(a<b)return a;
return b;
}
int minCostdown(int*h,int n){
    int* dp = new int[n];
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-2]-h[n-1]);
    for(int i = n-3;i>=0;i--){
        dp[i] = mini(dp[i+1] + abs(h[i]-h[i+1]),dp[i+2] + abs(h[i]-h[i+2]));
    }
    return dp[0];
}
int main()
{
    int n;
    cin>>n;
    int* h = new int[n];
    for(int i = 0;i<n;i++)
        cin>>h[i];
    //cout<<minCost(h,0,n)<<endl;
    cout<<minCostdown(h,n)<<endl;
    return 0;
}


Measured memory_bytes: 4364
//Pradeep_7
//double tt = clock();
//if((clock()-tt)/CLOCKS_PER_SEC > 1) break;
#include<bits/stdc++.h>
#define mp make_pair 
#define pb push_back
#define fi first
#define se second 
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
#define nn cout<<"\n"
#define tcc int tc;	cin>>tc; while(tc--)
#define arr(a,n)	for(int i=0;i<n;i++)		cin>>a[i]
#define all(a)	a.begin(),a.end()
#define rall(a)	a.rbegin(),a.rend()
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	double sum=0.0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int avg = round(sum/n);	
//	double avg =round(accumulate(all(a),0)/n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans += (a[i]-avg)*(a[i]-avg);
	}
	cout<<ans;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#define INF 1000000000
#define N 100010
using namespace std;
int n,k,cnta,cntb,Ans,a[N],b[N];

int main() {
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++) a[i]=b[i]=INF;
	for (int i=1; i<=n; i++) {
		int x;
		scanf("%d",&x);
		if (x<0) a[++cnta]=-x;
		else b[++cntb]=x;
	}
	for (int i=1; i<=(cnta/2); i++) swap(a[i],a[cnta-i+1]);
	Ans=b[k];
	for (int i=1; i<=min(cnta,k); i++)
		Ans=min(Ans,a[i]+b[k-i]*2);
	Ans=min(Ans,a[k]);
	for (int i=1; i<=min(cntb,k); i++)
		Ans=min(Ans,b[i]+a[k-i]*2);
	printf("%d",Ans);
	return 0 ;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

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

ll N;

int main() {
    cin >> N;
    string ans = "";
    while(N != 0) {
        if(N & 1)
            ans = "1" + ans;
        else
            ans = "0" + ans;
        N = ceil((double)N / (-2));
    }
    cout << (ans == "" ? "0" : ans) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long long N;
    long long A[100001], B[100001], C[100001];
    long long sum[100001], bigger[100001];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long *c;
        c = upper_bound(C, C+N, B[i]);
        //if(*c <= B[i]) bigger[i] = 0;
        //else bigger[i] = C+N - c;
        bigger[i] = C+N - c;
        //cout << bigger[i] << endl;
    }
    sum[N-1] = bigger[N-1];
    for(int i = N-2; i >= 0; i--){
        sum[i] = sum[i+1] + bigger[i];
    }
    for(int i = 0; i < N; i++){
        long long *b, *c;
        b = upper_bound(B, B+N, A[i]);
        //if(*b <= A[i]) break;
        if(b == B+N) break;
        ans += sum[b-B];
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int ans = 0;
  for (char c : s) {
    if (c == '1') ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  int ans(0);
  for (int i(1);i*i<=M;i++){
    if (M % i == 0){
      if (i>=N){
        ans = max(ans,M/i);
      }
      if (M/i>=N){
        ans = max(ans,i);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import random
N = int(input())
A = list(map(int, input().split()))
S = A[0] + A[1]
X = 0
for a in A[2:]:
  X ^= a
D = (S - X) >> 1
if S != X + (D << 1) or D > A[0] or (X & D) != 0:
  print(-1)
  exit(0)
a = D
b = 2 ** 64
while b > 0:
  if (X & b) != 0 and (a | b) <= A[0]:
    a |= b
  b >>= 1
if a == 0:
  print(-1)
  exit(0)
print(A[0] - a)

Measured memory_bytes: 81576
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  string s; cin >> s;
  int n = 0;
  for(int i=0; i<s.size(); i++) {
    n += s[i] - '0';
    n %= 9;
  }
  if (n == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3708
s = input()
def simulate(c):
    W = list(s[:])
    cnt = 0
    while len(set(W)) > 1:
        for i,w in enumerate(W):
            if w==c and i >= 1:
                W[i-1] = c
        cnt += 1
        W.pop()
    return cnt

ans = len(s)
for c in set(s):
    ans = min(ans, simulate(c))

print(ans)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
int dp[N];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        ans = max(ans, dp[p] = dp[p-1] + 1);
    }
    cout << n - ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long mod = 1000000007;
		long A = 10;
		long B = 9;
		long C = 8;
		for(var i=1;i<N;i++){
			A = A * 10 % mod;
			B = B * 9 % mod;
			C = C * 8 % mod;
		}
		long ans = (A - B - B + C + mod * 4) % mod;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17612
(n, k), p, c = [[*map(int, i.split())] for i in open(0)]
 
def solve(x, t):
    visit = [0] * n
    visit[x] = 1
    loop = [0] * n
    count = 0
    ans = c[p[x] - 1]
    l = True
    sub = 0
    while True:
        x = p[x] - 1
        if l:
            if visit[x]:
                if loop[x]:
                    ln = sum(loop)
                    if t > ln:
                        sub += (t//ln -1)*count*(count>0)
                        t %= ln
                        t += ln
                    l = False
                count += c[x]
                loop[x] = 1
            visit[x] = 1
        sub += c[x]
        t -= 1
        ans = max(sub, ans)
        if t < 1:
            return ans
 
 
print(max(solve(i, k) for i in range(n)))

Measured memory_bytes: 98488
#include <iostream>
using namespace std;
int main(void){
  //yheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
  int a, b;
  cin >> a >> b;
  if (a*b%2 == 0)
  cout << "Even" << endl;
  else
  cout << "Odd" << endl;
}

Measured memory_bytes: 3600
n = int(input())
h = list(map(int, input().split()))

ans = 0
while any(height > 0 for height in h):
    ans += 1
    maxh = max(h)
    for i in range(n):
        if h[i] == maxh:
            for j in range(i,n):
                if h[j] == 0:
                    break
                else:
                    h[j] = h[j]-1
        else:
            continue
        break

print(int(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;






int main() {
    
    int n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    ll m=1000;
    ll k=0;
    rep(i,n){
        // cout<<m<<" "<<k<<endl;
        if(i==n-1){
            m+=k*v[i];
            break;
        } else if(v[i]==v[i+1]){
            continue;
        } else if(v[i]<v[i+1]) {
            if(v[i]>m)continue;
            k+=m/v[i];
            m=m-m/v[i]*v[i];
        } else {
            m+=k*v[i];
            k=0;
        }
    }
    fin(m);
}


Measured memory_bytes: 3632
from copy import deepcopy
def main():
    S = list(input())

    for i in range(len(S)):
        for j in range(i,len(S)+1):
            now = deepcopy(S)
            del now[i:j]
            if "".join(now)=="keyence":
                print("YES")
                exit()
    print("NO")
if __name__ == '__main__':
    main()

Measured memory_bytes: 45916
#include <iostream>

using namespace std;


int main(void){
   
    int A, B, N;
    cin >> N >> A >> B;
    
    int prevA, prevB;
    
    for(int i = 0; i< N; i++){
        prevA = A;
        prevB = B;
        
        if(A + 1 != B){
            A++;
        }else if(A - 1 >= 1){
            A--;
        }else{
            cout << "Borys" << endl;
            return 0;
        }
        if(B - 1 != A){
            B--;
        }else if(B + 1 <= N){
            B++;
        }else{
            cout << "Alice" << endl;
            return 0;
        }
        
    }
    cout << "Draw" << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n,k;
    cin >>n >>k;
    int64_t total;
    vector<int64_t> h(n);
    for(auto &e:h) cin >>e;
    sort(h.begin(),h.end());

    if(n-k<=0){
        cout << 0 <<endl;
    }else {
        total = accumulate(h.begin(),h.begin()+n-k,0LL);
        cout << total;
    }
}

Measured memory_bytes: 1792
S = input()

if S[0] == S[1] and S[2] == S[3] and S[0] != S[3]:
    print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print("Yes")
elif S[0] == S[3] and S[2] == S[1] and S[0] != S[1]:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> A(N+1);
    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        A[y].push_back(x);
        A[x].push_back(y);
    }
    for(int x : A[N]){
        for(int x2 : A[x]){
            if(x2 == 1){
                cout << "POSSIBLE" << endl;
                exit(0);
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  map<char,char> dict={{'A','T'},{'C','G'},{'T','A'},{'G','C'}};
  char s;
  cin >> s;
  cout << dict[s] << endl;
}

Measured memory_bytes: 256
from sys import stdin


n, m = map(int, stdin.readline().split() )

mp = [[1, int(i)] for i in stdin.readline().split()]

dat = [ list(map(int, stdin.readline().split() ) ) for _ in range(m) ]

mp.extend(dat)

mp.sort(key = lambda x : x[1], reverse = True)

#print(mp)
ans = 0
for e in mp:
    if n > e[0]:
        n -= e[0]
        t = e[0] * e[1]
        #print(t)
        ans += t
    else:
        ans += n * e[1]
        break

print(ans)

Measured memory_bytes: 45476
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int main()
{
	int h, w, k; cin >> h >> w >> k;
	vector<string> s(h); rep(i, h)cin >> s[i];
	vector<vector<int>> sum(h, vector<int>(w + 1, 0));
	rep(i, h)rep(j, w)
	{
		sum[i][j + 1] = sum[i][j];
		if (s[i][j] == '1')++sum[i][j + 1];
	}
	int mn = 1e9;
	rep(i, pow(2, h - 1))
	{
		vector<int> pos = { 0 };
		rep(j, h - 1)if (i&(1 << j))pos.push_back(j + 1);
		pos.push_back(h);
		int left = 0;
		int right = 1;
		bool ng = false;
		int cnt = 0;
		while (!ng && left < w)
		{
			int mx = 0;
			for (int i = 1; i < pos.size(); ++i)
			{
				int tmp = 0;
				for (int j = pos[i - 1]; j < pos[i]; ++j)
				{
					tmp += sum[j][right] - sum[j][left];
				}
				mx = max(mx, tmp);
			}
			if (mx <= k)++right;
			if (right - left <= 1)ng = true;
			if (mx > k)
			{
				left = right - 1;
				++cnt;
				//cout << i << " " << left << endl;
			}
			if (right > w)break;
		}
		if (ng)continue;
		else mn = min(mn, cnt + (int)pos.size() - 2);
		//cout << cnt + (int)pos.size() - 2 << endl;
	}
	cout << mn << endl;
}

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

int main() {
int A,B,C;
cin>>A>>B>>C;
  
  if (A==B && B ==C){cout<<"No"<<endl;}
  else if (A==B || B ==C || C== A){cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
}



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

int main(){
  int n1,n2;
  std::string s;
  cin >> n1 >> n2;
  int ans = 0;

  while(1){
    s = std::to_string(n1);
    if(s[0] == s[4] && s[1] == s[3]){
      ans++;
    }
    n1++;
    if(n1 == n2 + 1)
      break;
  }
  
  cout << ans << endl;      

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a, b, c;
  int sum = 0;
  
  scanf("%d %d %d", &a, &b, &c);
  
  for(;c >= a;c -= a){
    sum += b;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, d;

int solve() {
    int e = 2 * d + 1;
    return (n + e - 1) / e;
}

void input() {
    cin >> n >> d;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("mmx,avx,fma")
//#pragma GCC optimize ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, set<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define cont continue
#define ret return
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define fordn(i, a) for (int i = a - 1;i >= 0;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << (s_) << '\n';return 0;}
#define endl '\n'
#define makeunique(x) sort(all(x)), (x).resize(unique(all(a)) - (x).begin())
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef long double ldd;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_tree;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
////const int mod = 1e9 + 7;
//const int mod = 998244353;
//ll powq(ll a, ll n) {
//    ll res = 1;
//    while (n){
//        if (n & 1) {
//            res *= a;
//            res %= mod;
//            --n;
//        }
//        else {
//            a *= a;
//            n >>= 1;
//            a %= mod;
//        }
//    }
//    return res;
//}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    forn(i, n){
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def resolve():
    from collections import deque

    def checker(n):
        n = str(n)
        OK3 = False
        OK5 = False
        OK7 = False
        for i in n:
            if i == "3":
                OK3 = True
            elif i== "5":
                OK5 = True
            elif i == "7":
                OK7 = True
        if OK3 and OK5 and OK7:
            return True
        else:
            return False

    n = int(input())
    if n < 357:
        print(0)
    else:
        ans = 0
        nxt = [3, 5, 7]
        nxt = deque(nxt)
        OK = True
        while OK:
            a = nxt.popleft()
            if a > n:
                break
            nxt.append(a*10+3)
            nxt.append(a * 10 + 5)
            nxt.append(a * 10 + 7)
            if checker(a):
                ans += 1
        print(ans)
resolve()

Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N;cin>>N;
    for(int i=1;i<=9;i++){
        if(111*i-N>=0){
            cout<<111*i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int a,b;
  cin>>hex>>a>>b;
  if(a<b){
    cout<<"<";
  }else if(a>b){
    cout<<">";
  }else{
    cout<<"=";
  }
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll n; cin >> n;
   if(n % 2 == 0){
      n /= 2;
      ll m = 2 * n * (n - 1);
      cout << m << endl;
      REP(i, n){
         FOR(j, i + 1, n){
            printf("%lld %lld\n", i + 1, j + 1);
            printf("%lld %lld\n", i + 1, (2 * n + 1) - (j + 1));
            printf("%lld %lld\n", (2 * n + 1) - (i + 1), j + 1);
            printf("%lld %lld\n", (2 * n + 1) - (i + 1), 2 * n + 1 - (j + 1));    
         }
      }
   }
   else{
      n /= 2;
      ll m = 2 * n * n;
      cout << m << endl;
      REP(i, n){
         FOR(j, i + 1, n){
            printf("%lld %lld\n", i + 1, j + 1);
            printf("%lld %lld\n", i + 1, (2 * n + 1) - (j + 1));
            printf("%lld %lld\n", (2 * n + 1) - (i + 1), j + 1);
            printf("%lld %lld\n", (2 * n + 1) - (i + 1), 2 * n + 1 - (j + 1));    
         }
         printf("%lld %lld\n", i + 1, 2 * n + 1);
         printf("%lld %lld\n", 2 * n + 1 - (i + 1), 2 * n + 1);
      }
   }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.range, std.conv;

void main() {
  long N, M;
  readf(" %d %d ", &N, &M);
  
  long[][] edges;
  edges.length = N;
  foreach (i; 0..M) {
    long x, y;
    readf(" %d %d ", &x, &y);
    --x;
    --y;
    edges[x] ~= y;
  }
  
  auto dp = new long[N];
  dp[] = -1;
  long rec(long target) {
    if (dp[target] >= 0) return dp[target];
    
    dp[target] = 0;
    foreach (n; edges[target]) {
      dp[target] = dp[target].max(rec(n) + 1);
    }
    return dp[target];
  }
  
  long ans;
  foreach (i; 0..N) {
    ans = ans.max(rec(i));
  }
  ans.writeln;
}

Measured memory_bytes: 10108
import java.io.*;
import java.util.*;

class FastReader 
{ 
    BufferedReader br; 
    StringTokenizer st; 
    
    public FastReader() 
    { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    
    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    
    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
    
    long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
    
    double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
    
    String nextLine() 
    { 
          String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} 

class Solution
{
    void solve()
    {
        FastReader sc = new FastReader();
        
        int L = sc.nextInt();
        int R = sc.nextInt();

        R -= L;
        L %= 2019;
        R += L;

        int res = 2019; //max value

        if(R - L > 2019)
        {
            System.out.println(0);
            return;
        }

        for(int i = L; i <= R; i++)
        {
            for(int j = L; j < i ; j++)
            {
                res = Math.min(res, (i*j) % 2019);
            }
        }

        System.out.println(res);
    }
}
  
public class Main 
{ 
    public static void main(String[] args) 
    { 
        Solution ob = new Solution();

        ob.solve();
    } 
} 

Measured memory_bytes: 32716
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main(){
    int a;
    string s;
    
    cin >> a;
    cin >> s;
    
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll r;
cin>>r;
cout<<3*(pow(r,2));



}







Measured memory_bytes: 256
tower, road = map(int, input().split(" "))

towers = list(map(int, input().split(" ")))
goods = {i+1 for i in range(tower)}

for _ in range(road):
    tower_a, tower_b = map(int, input().split(" "))
    if towers[tower_a-1] > towers[tower_b-1]:
        goods.discard(tower_b)
    elif towers[tower_a-1] < towers[tower_b-1]:
        goods.discard(tower_a)
    else:
        goods.discard(tower_b)
        goods.discard(tower_a)

print(len(goods))

Measured memory_bytes: 22528
import statistics
n = int(input())
a = list(map(int, input().split()))
median_low = statistics.median_low(a)
median_high = statistics.median_high(a)
for i in range(n):
    if median_high > a[i]:
        print(median_high)
    elif median_low < a[i]:
        print(median_low)
    elif median_high == a[i]:
        print(a[i])
    else:
        print(a[i-1])


Measured memory_bytes: 27184
package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(n int64, str string) string {
	n--
	m := n % 26
	str = string(rune('a' + m)) + str 
	n /= 26
	if n <= 0 {
		return str
	}
    return solve(n,str)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int64
	fmt.Fscan(r, &n)
	str := ""
	str = solve(n,str)
	fmt.Println(str)
}


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

int main()
{

  int x,y,s;
  for(;cin>>x>>y>>s,x;)
    {
      int ans=0;
      for(int i=1;i<=s;i++)
	{
	  for(int j=i;i+j<=s;j++)
	    {
	      if(int(i+i*(x/100.0))+int(j+j*(x/100.0))==s)
		{
		  //  cerr<<i<<" "<<j<<" "<<int(i+i*(x/100.0))<<" "<<int(j+j*(x/100.0))<<endl;
		  ans=max(ans,int(i+i*(y/100.0))+int(j+j*(y/100.0)));
		}
	    }
	}
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var a = new int[N];
        for (int j = 0; j < N; j++)
        {
            a[j] = int.Parse(Console.ReadLine());
        }
        for (int k = 1; k <= M; k++)
        {
            for (int i = 0; i < N - 1; i++)
            {
                if (a[i] % k > a[i + 1] % k)
                {
                    var t = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = t;
                }
            }
        }
        foreach (var item in a)
        {
            Console.WriteLine(item);
        }
    }
}


Measured memory_bytes: 18296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=998244353;
const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
  	ll comb=1;
	ll fact[k+1];
	fact[k]=1;
	for(int i=k-1;i>=0;i--){
		fact[i]=fact[i+1]*(m-1);
		fact[i]%=divisor;
	}
	ll sup = m;
	rep(i,n-k-1){
		sup*=m-1;
		sup%=divisor;
	}
	rep(i,k+1){
		ll val=1;
		
      	val*=COM(n-1,i);
		val*=fact[i];
		val%=divisor;
		ans+=val;
		ans%=divisor;
	}
	ans*=sup;
	ans%=divisor;
	puts(ans);
}

Measured memory_bytes: 17104
import java.util.Scanner;

public class Main {

    static final long MOD = 1000000007;
    
    static int H, W, K;
    static long[][] dp = new long[110][10];
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        K = sc.nextInt() - 1;
        dp[0][0] = 1;
        for(int h=1; h<=H; ++h) {
            for(int w=0; w<W; ++w) {
                for(int b=0; b<(1<<(W-1)); ++b) {
                    int x = 3;
                    boolean flg = false;
                    while(x < 1<<20) {
                        if((x&b) == x) flg = true;
                        x <<= 1;
                    }
                    if(flg) continue;
                    if(w>0 && (b&(1<<(w-1)))>0) {
                        dp[h][w] += dp[h-1][w-1];
                    }
                    else if(w < W-1 && (b&(1<<w))>0) {
                        dp[h][w] += dp[h-1][w+1];
                    }
                    else {
                        dp[h][w] += dp[h-1][w];
                    }
                    dp[h][w] %= MOD;
                }
            }
        }
        System.out.println(dp[H][K]);
    }
}

Measured memory_bytes: 22996
count = 0
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if arr[i]==arr[j] or arr[i]==arr[k] or arr[j]==arr[k]:
        continue
      if arr[i]+arr[j]>arr[k]:
        count+=1
print(count)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>399 && n<600)
        cout<<"8";
    else if(n>599 && n<800)
        cout<<"7";
    else if(n>799 && n<1000)
        cout<<"6";
    else if(n>999 && n<1200)
        cout<<"5";
    else if(n>1199 && n<1400)
        cout<<"4";
    else if(n>1399 && n<1600)
        cout<<"3";
    else if(n>1599 && n<1800)
        cout<<"2";
    else
        cout<<"1";
}


Measured memory_bytes: 3592
import sys

def Not_Divisible(n,p):
    maxp = max(p)
    dp = [True for _ in range(maxp+1)]
    count =[0 for _ in range(maxp+1)]
    for a in p:
        count[a]+=1
        t =2
        while a*t <= maxp:
            if dp[a*t] == True :
                dp[a*t] = False
            t+=1
    k=0
    for d in p:
        if count[d] == 1 and dp[d] == True:
            k+=1
    return k


def main():
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    n = int(inp1[0])

    inp2 = input().rstrip().split()
    p = tuple(map(int,inp2))
    print(Not_Divisible(n,p))


if __name__ == '__main__':
    main()

Measured memory_bytes: 219096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int  k;
int a[5];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i=0;i<5;i++) cin>>a[i];
    cin >>k;
    if(a[4]-a[0]>k){
        cout<<":("<<"\n"; 
        return 0;
    }
    cout << "Yay!" << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

long long dp[100][(int)1e5+1] ;
vector<long long> w , v ;

long long fun(int i , long long c)
{
	if(i==w.size()) return 0 ;
	if(dp[i][c]==-1)
	{
		if(c >= w[i])
		{
			long long num = v[i]+fun(i+1,c-w[i]) ;
			dp[i][c] = max(fun(i+1,c) , num) ;
		}
		else dp[i][c] = fun(i+1,c) ;
	}
	return dp[i][c] ;
}

int main()
{
	int t=1;
	// cin >> t ;

	while(t--)
	{
		for(int i=0 ; i<100 ; i++) 
			for(int j=0 ; j<=1e5 ; j++)
				dp[i][j] = -1 ;
		
		int n ,W; 
		cin>>n>>W;
		w.resize(n) ;
		v.resize(n) ;
		for(int i = 0 ; i<n ; i++)
			cin>>w[i]>>v[i] ;

		cout << fun(0,(long long)W) << endl ;
	}
	return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <string.h>

int main() {
  char t[200002];
  scanf("%s", t);
  int l=strlen(t);
  
  for(int i=0;i<l;i++){
    if(t[i]=='?') t[i]='D';
  }

  printf("%s", t);
  return 0;
}


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

int x[200005];
int sorted[200005];

int int_compare(int *x, int *y);

void trickle_down(void *base, size_t i, 
		size_t n_memb, size_t data_size,
		int (*compare)(const void *, const void *));

void sort(void *base, size_t n_memb, size_t data_size, 
		int (*compare)(const void *, const void *));

void memswap(void *x, void *y, size_t size);

int main()
{
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);

		sorted[i] = x[i];
	}

	sort(sorted, n, sizeof(int), (int (*)(const void *, const void *))int_compare);

	for (int i = 0; i < n; i++) {
		if (x[i] < sorted[n / 2]) {
			printf("%d\n", sorted[n / 2]);
		} else {
			printf("%d\n", sorted[n / 2 - 1]);
		}
	}

	return 0;
}


//ソート本体(ヒープソート)
void sort(void *base, size_t n_memb, size_t data_size, 
		int (*compare)(const void *, const void *))
{
	int i;

	//ヒープ構築
	for (i = n_memb / 2; i >= 0; i--) {
		trickle_down(base, i, n_memb, data_size, compare);
	}

	//最大のものを末尾へ移動し、ヒープを再構築
	for (i = n_memb - 1; i >= 1; i--) {
		memswap((unsigned char *)base,
				(unsigned char *)base + (data_size * i), data_size);

		trickle_down(base, 0, i, data_size, compare);
	}

	return;
}

//上のソートに必要なヒープ性を保つ関数
//みんなのデータ構造 p181 参考
void trickle_down(void *base, size_t i, 
		size_t n_memb, size_t data_size,
		int (*compare)(const void *, const void *))
{
	size_t l, r;
	size_t j = i;
	unsigned char *arr = base;
	
	do {
		i = j;

		r = 2 * i + 2;
		l = 2 * i + 1;

		if (l < n_memb &&
				compare(arr + l * data_size, arr + j * data_size) > 0) {
			j = l;
		}

		if (r < n_memb &&
				compare(arr + r * data_size, arr + j * data_size) > 0) {
			j = r;
		}

		if (i != j) {
			memswap(arr + i * data_size, arr + j * data_size, data_size);
		}

	} while (i != j);

	return;
}

//比較関数群
int int_compare(int *x, int *y)
{
	if (*x > *y) {
		return 1;
	} else if (*x == *y) {
		return 0;
	} else {
		return -1;
	}
}

void memswap(void *x, void *y, size_t size)
{
	if (x != y) {
		while (size--) {
			*((unsigned char *)x + size) ^= *((unsigned char *)y + size);
			*((unsigned char *)y + size) ^= *((unsigned char *)x + size);
			*((unsigned char *)x + size) ^= *((unsigned char *)y + size);
		}
	}

	return;
}


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

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
  
    ret.push_back(n);
	return ret;
}

int main()
{
  ll N;
  vector<ll> tmp;
  
  cin >> N;
  
  tmp = enum_div(N);
  
  sort(tmp.begin(), tmp.end());
  
  if(tmp.size() % 2 == 0)
  	cout << tmp[(int)(tmp.size() / 2)] - 1 + tmp[(int)(tmp.size() / 2) - 1] - 1<< endl;
  else
  	cout << tmp[(int)(tmp.size() / 2)] + tmp[(int)(tmp.size() / 2)] - 2<< endl;
  
  return 0;
}
  
  

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

namespace AtCoderBiginnerContest154
{
	class Program
	{
		static void Main(string[] args)
		{
			var target = ReadString();
			var result = "";
			for(var i = 0; i < target.Length; i++)
			{
				result += "x";
			}
			Console.WriteLine(result);
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
 
	vector<int> t2;
	for (int i = 0;i < n;i++) {
		if (t[i] == 'r') t2.push_back(2);
		if (t[i] == 's') t2.push_back(0);
		if (t[i] == 'p') t2.push_back(1);
	}
	int sc[3] = { r, s, p };
 
	int score = 0;
	for (int i = 0;i < n;i++) {
		score += sc[t2[i]];
	}
 
	for (int i = 0;i < n - k;i++) {
		if (t2[i] == t2[i + k]) {
			score -= sc[t2[i]];
			t2[i + k] = -1;
		}
	}
	cout << score;
	return 0;
}

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

long long n, m;

int main() {
  cin >> n >> m;
  n = 2 * m + 1;
  if (m % 2) {
    for (int i = 0; i < m / 2; ++i) cout << i + 1 << " " << m - i << endl;
    for (int i = 0; i < m / 2 + 1; ++i)
      cout << m + i + 1 << " " << 2 * m + 1 - i << endl;
  } else {
    for (int i = 0; i < m / 2; ++i) cout << i + 1 << " " << m + 1 - i << endl;
    for (int i = 0; i < m / 2; ++i)
      cout << m + i + 2 << " " << 2 * m + 1 - i << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#define f first
#define s second

using namespace std;

typedef pair<int,int> P;

int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

int main(void){

  int t;
  cin >> t;

  while(t--){
    int p,q;
    cin >> p >> q;
    int tmp=p*p+q*q,cnt=0;

    for(int n=0;n*n<=tmp;n++){
      for(int m=0;m*m<=tmp;m++){
        if(m*m+n*n<1)continue;
        int res=gcd(m*p+n*q,m*q-n*p);
        if((m*p+n*q)%(m*m+n*n)==0 && (m*q-n*p)%(m*m+n*n)==0)cnt++;
      }
    }

    if(cnt*2<=8)cout << "P" << endl;
    else cout << "C" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

time=[A,B,C,D,E]

for i in range(5):
    if time[i]%10!=0:
        time[i]=(time[i]//10)*10+10

A_=A+time[1]+time[2]+time[3]+time[4]
B_=time[0]+B+time[2]+time[3]+time[4]
C_=time[0]+time[1]+C+time[3]+time[4]
D_=time[0]+time[1]+time[2]+D+time[4]
E_=time[0]+time[1]+time[2]+time[3]+E

print(min(A_,B_,C_,D_,E_))

Measured memory_bytes: 3064