akhauriyash/Code-Regression huggingface dataset:
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll H,W;cin>>H>>W;
    ll cnt=0;
    REP(i,H*W){
        char a;cin>>a;
        if(a=='#')cnt++;
    }
    if(cnt==H+W-1)cout<<"Possible";
    else cout<<"Impossible";
    cout<<"\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    X = list(map(int, input().split()))
    res = float('inf')
    for p in range(101):
        res = min(res, sum((x-p)**2 for x in X))
    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
constexpr int f(int a){
	return a?a%10+f(a/10):0;
}
template<int N>struct ans{
	int a[37][N+1];
	constexpr ans(){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[j][i]=a[j][i-1];
			a[f(i)][i]+=i;
		}
	}
};
void print(int a){
	a?print(a/10),putchar(a%10+48):0;
}
ans<10000>s;
int t,n,a,b,c;
main(){
	while((c=getchar())>47)n=n*10+c-48;
	while((c=getchar())>47)a=a*10+c-48;
	while((c=getchar())>47)b=b*10+c-48;
	for(;a<=b;a++)t+=s.a[a][n];
	t?print(t),0:putchar(48);
}


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

int main(void){

    string S,T;
    int a,b;
    map<string,int> mp;
    cin >> S >> T;
    cin >> a >> b;
    mp[S]=a;
    mp[T]=b;
    string U;
    cin >> U;
    mp[U]--;
    cout << mp[S]<<" "<<mp[T]<<endl;
    

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353  //1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n];
   int f=1;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       if(a[i] % 2==0)
       {
           if(a[i] % 3!= 0 &&  a[i] % 5 != 0)
              f=0;
       }
   }
   if(!f)
    cout<<"DENIED"<<endl;
   else
    cout<<"APPROVED"<<endl;

}



Measured memory_bytes: 256
import sys
x = list(map(int,input().split()))

a = x[0]
b = x[1]

if a > b:
    large = a
    small = b
elif a < b:
    large = b
    small = a
else:
    ans = ''.join([str(a)]*a)
    print(ans)
    sys.exit()

ans = ''.join([str(small)]*large)
print(ans)

    


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {

	int k;
	cin >> k;

	int a, b;
	cin >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x, sum;
  cin >> N >> K;
  sum=0;

  for(int i=1;i<=N;i++){
    cin >> x;
    if( x<K){
      if(K-x>x) sum+=x;
      else sum+=K-x;
    }
    else{
      sum+=x-K;
    }
  }

  cout << sum*2 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	ll k, a, b, ans;
    cin >> k >> a >> b;
    ll minK = k-(a-1);
    if(b-a >= 3){
        if(minK % 2 == 0){
            ans = a + minK/2 * (b-a);
        }else{
            ans = a + minK/2 * (b-a) + 1;
        }
    }else{
        ans = k + 1;
    }
    cout << ans << endl;
	return 0;
}


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

#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    REP(i, n1) {
        L[i] = A[left + i];
    }
    REP(i, n2) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    REPN(k, left, right) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    REP(i, n) {
        cin >> A[i];
    }

    mergeSort(A, n, 0, n);

    REP(i, n) {
        if (i) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << '\n';
    cout << cnt << '\n';
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        long sum = 0;
        for (int k = 1; k <= N; k++)
        {
            for (int j = k; j <= N; j+=k)
            {
                sum += j;
            }
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 27492
#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(){
    ll N, X, T; cin >> N >> X >> T;
    ll ans = 0;
    ll sum = 0;
    FOR(i, 1, 10000) {
        sum += X;
        ans += T;
        if (sum >= N) break;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3644
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>

#define ff(i,a,b) for (int i=(a);i<=(b);i++)
using namespace std;
const int N=1501, inf=1e9;
int n,r,d[N][N],W,maxOf[N];
typedef pair<int,int> ii;
vector <ii> adj[N];
bool inEiden[N];
bool visited[N][N];

void dijkstra (int s, int d[]) {
    ff(i,1,n) d[i]=inf;
    priority_queue<ii, vector<ii>, greater<ii> > pq;
    d[s]=0; pq.push(ii(d[s],s));
    while (!pq.empty()) {
        ii to=pq.top(); pq.pop();
        int w=to.first, u=to.second;
        if (w > d[u]) continue;
        ff(i,0,(int)adj[u].size()-1) {
            int v=adj[u][i].first, cost=adj[u][i].second;
            if (d[u]+cost<d[v]) {
                d[v]=d[u]+cost;
                pq.push(ii(d[v],v));
            }
        }
    }
    ff(i,1,n) if (d[i]==inf) d[i]=-inf;
}
void dfs (int s, int u) {
    visited[s][u]=1; inEiden[u]=1;
    ff(i,0,(int)adj[u].size()-1) {
        int v=adj[u][i].first, c=adj[u][i].second;
        if (!visited[s][v] && d[s][v]+c==d[s][u])
            dfs(s,v);
    }
}

int main() {/*
    freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); //*/
    scanf("%d%d",&n,&r);
    ff(i,1,r) {
        int s,t,d; scanf("%d%d%d",&s,&t,&d);
        adj[s].push_back(ii(t,d)); adj[t].push_back(ii(s,d));
    }
    ff(i,1,n) {
        dijkstra (i, d[i]); maxOf[i]=0; ff(j,1,n) maxOf[i]=max(maxOf[i], d[i][j]);
        if (maxOf[i] < W) continue;
        if (maxOf[i] > W) {W=maxOf[i]; fill(inEiden+1, inEiden+n+1, 0);}
        ff(j,1,n) {
            if (d[i][j] == W && !visited[i][j])
                dfs (i, j);
        }
    }
    int ans = 0;
    ff(i,1,n) if (!inEiden[i]) ans++;
    printf("%d\n",ans);
    ff(i,1,n) if (!inEiden[i]) printf("%d\n",i);
    return 0;
}



Measured memory_bytes: 13848
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll a,b;cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int k = in.nextInt();
        int cnt=0;
        while(n>0){
            cnt++;
            n/=k;
        }
        out.println(cnt);
        
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22740
h,w = map(int,input().split())
a = []
list_w = []
list_h = []
for i in range(h):
    A = list(str(input()))
    a.append(A)
for i in range(h):
    cnt_w = 0
    cnt_h = 0
    for j in range(w):
        if a[i][j] == ".":
            cnt_w += 1
    if cnt_w == w:
        list_w.append(i)

for i in range(w):
    cnt_h = 0
    for j in range(h):
        if a[j][i] == ".":
            cnt_h += 1
    if cnt_h == h:
        list_h.append(i)

for i in list_w:
    for j in range(w):
        a[i][j] = "!"
for i in list_h:
    for j in range(h):
        a[j][i] = "!"


ans = []
for i in range(h):
    tmp = []
    for j in range(w):
        if a[i][j] == "#" or a[i][j] == ".":
            tmp.append(a[i][j])
    tmp = "".join(tmp)
    ans.append(tmp)
for i in ans:
    if i != '':
        print(i)

Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

const int maxn = 15e4 + 5;

double dp[maxn], dp2[maxn];
int deg[maxn];
vector<int> G[maxn];

void dfs(int u, int fa) {
    dp[u] = 0;
    int p = deg[u];
    if (fa != -1) p --;
    for (int v : G[u]) if (v != fa) {
        dfs(v, u);
        dp[u] += (dp[v] + 1) * 1.0 / p;
    }
}

void dfs2(int u, int fa) {
    int p = deg[u];
    for (int v : G[u]) if (v != fa) {
        if (fa == -1) {
            if (p == 1)
                dp2[v] = 1;
            else
                dp2[v] = ((dp[u] + 1) * p - (dp[v] + 2)) / (p - 1);
        }
        else
            dp2[v] = ((dp2[u] + 1) + (dp[u] + 1) * (p - 1) - (dp[v] + 2)) / (p - 1);
        dfs2(v, u);
    }
}

int main(int argc, char const *argv[]) {
    int N; cin>>N;
    
    for (int i = 1; i < N; i ++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
        deg[u] ++, deg[v] ++;
    }
    
    dp2[1] = 0;
    dfs(1, -1);
    dfs2(1, -1);
    
//    for (int i = 1; i <= N; i ++)
//        cout<<i<<" "<<dp[i]<<" "<<dp2[i]<<" "<<deg[i]<<endl;
    
    printf("%.8f\n", dp[1]);
    for (int i = 2; i <= N; i ++) {
        printf("%.8f\n", (dp[i] * (deg[i] - 1) + dp2[i]) * 1.0 / deg[i]);
    }
}

Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string t;
    cin>>t;
    int n=t.size();
    rep(i,n){
        if(t[i]=='?')t[i]='D';
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,j,n) for(int i=j; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const ll mod=1000000007;
 
int main()
{
    optimizeIO();
    int nT; nT=1;
	while(nT--)
	{
		ll n; cin>>n;
		cout<<n*n*n;
	}
	return 0;
}

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

int main()
{
    int N, T;
    long long int answer;
    cin>>N>>T;
    vector<int> D(N);
    for(int i=0; i < N; i++) {
        cin>>D[i];
    }
    sort(D.begin(), D.end());
    answer = 1;
    for(int i=1; i < N; i++) {
        int count = 0;
        for(int j=0; j <= i; j++) {
            if(D[j] >= D[i] - T) count++;
        }
        if(!count) continue;
        answer *= count;
        answer %= 1000000007;
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 1536
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
//string str;
int A;
int N;
int main(){
	cin>>N>>A;


	cout<<N*N-A<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace 令和{
    class ABC{
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            //bool[] isEven = new bool[n-1];
            List<int[]>[] tonari = new List<int[]>[n+1];
            int[] ans = new int[n+1];
            for(int i=0;i<n+1;i++){
                tonari[i] = new List<int[]>();
                ans[i] = -1;
            }
            int u,v,w;
            for(int i=1;i<n;i++){
                string[] uvw = Console.ReadLine().Split();
                u = int.Parse(uvw[0]);
                v = int.Parse(uvw[1]);
                w = int.Parse(uvw[2]);
                tonari[u].Add(new int[2]{v,w});
                tonari[v].Add(new int[2]{u,w});
                /*
                if(w[i]%2==0){
                    isEven[i] = true;
                }else{
                    isEven[i] = false;
                }
                */
            }
            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            ans[1] = 0;
            while(q.Count!=0){
                int p = q.Dequeue();
                foreach(int[] tnr in tonari[p]){
                    if(ans[tnr[0]]==-1){
                        ans[tnr[0]] = (tnr[1]+ans[p])%2;
                        q.Enqueue(tnr[0]);
                    }
                }
            }
            for(int i=0;i<n;i++){
                Console.WriteLine(ans[i+1]);
            }
 
 
        }
    }
}

Measured memory_bytes: 39368
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<ll, int> P;
#define fs first
#define sc second

ll INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    P p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i].fs;
        p[i].sc = i;
    }

    sort(p, p + N, greater<P>());

    //大きい方からi個つかって、左に詰めたのがjこのときのスコアmax
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -INF));
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= i; j++) {
            int k = i - j - 1; //右に詰めた個数

            //右に詰める
            ll t1 = dp[i - 1][j] + p[i - 1].fs * (N - k - 1 - p[i - 1].sc);
            //左に詰める
            ll t2 = -INF;
            if(j != 0) t2 = dp[i - 1][j - 1] + p[i - 1].fs * (p[i - 1].sc - j + 1);

            dp[i][j] = max(t1, t2);
            //cout << p[i - 1].fs << endl;
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }

    ll ans = 0;
    for(int j = 0; j <= N; j++) {
        ans = max(ans, dp[N][j]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34672
#include <stdio.h>
int a,b;
int kouzi[17][17]={0,};
int memo[17][17];

int keiro(int i,int j){
    if(i>a || j>b || kouzi[i][j])
        return 0;
    if(i==a&&j==b)
        return 1;
    if(memo[i][j])
        return memo[i][j];
    else
        return memo[i][j]=keiro(i+1,j)+keiro(i,j+1);
}
main(){
    int i;
    int t,t2;
    int n;
    while(scanf("%d %d",&a,&b)!=EOF){
        if(a==0)
            break;
        scanf("%d",&n);
        for(i=0;i<17*17;i++)
            kouzi[0][i]=memo[0][i]=0;
        for(i=0;i<n;i++){
            scanf("%d %d",&t,&t2);
            kouzi[t][t2]=1;
        }
        printf("%d\n",keiro(1,1));
    }
    return 0;
}

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

int main(){
    int a[3][3], c[3][3];
    int n;
    rep(i,3){
        rep(j, 3){
            cin >> a[i][j];
            c[i][j]=0;
        }
    }
    cin >> n;
    vector<int> b(n);
    rep(i, n){
        cin >> b.at(i);
    }
    rep(i, 3){
        rep(j, 3){
            rep(k, n){
                if(a[i][j]==b.at(k)){
                    c[i][j]=1;
                }
            }
        }
    }
    int t = 1;
    rep(i, n){
        int s = b.at(i);
        rep(j, n){
            if(i!=j&&s==b.at(j)){
                t=0;
            }
        }
    }
    int ans=0;
    rep(i, 3){
        if(c[i][0]*c[i][1]*c[i][2]!=0){
            ans = 1;
        }
        else if(c[0][i]*c[1][i]*c[2][i]!=0){
            ans = 1;
        }
        
    }
    if(c[0][0]*c[1][1]*c[2][2]!=0||c[0][2]*c[1][1]*c[0][2]!=0){
        ans = 1;
    }
    if(ans==1&&t==1){
        cout<< "Yes" << endl;
    }
    
    else if(ans==0){
        cout << "No" << endl;
    }
}

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

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

  int S = s.length();
  if (S < 26) {
    set<char> c;
    rep(i, 26) c.insert('a' + i);
    rep(i, S) c.erase(s[i]);
    cout << s << *c.begin() << endl;
    return 0;
  }

  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 25; i >= 0; i--) {
    string sub = s.substr(0, i);
    char c = s[i] + 1;
    while (c <= 'z') {
      if (sub.find(c) == sub.npos) {
        cout << sub << c << endl;
        return 0;
      }
      c++;
    }
  }
}


Measured memory_bytes: 3612
from bisect import bisect as B
LI=lambda:map(int,input().split())
A=0
n,m=LI()
a=sorted(LI())
ra=a[::-1]
def Q(x,M):
    w=0
    for i in range(n):
        y=x-ra[i]
        c=B(a,y-1)
        w+=n-c
        if w>=M:return True
    return False
N=a[-1]*3
O=-1
while abs(O-N)>1:
    f=(O+N)//2
    if Q(f,m):
        O=f
    else:
        N=f
O
P=0
for i in range(n):
    e=n-B(a,O-a[i]-1)
    P+=e
    A+=e*a[i]*2
print(A-O*(P-m))


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

int main() {
  
  string S, T;
  cin >> S;
  cin >> T;
  int n = S.size();
  int k = 0;
  
  for(int i = 0; i < n; i++){
    if(S.at(i) == T.at(i)){
      k++;
    }
  }
  
  cout << n - k << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
using ll=long long;
using P=pair<ll,ll>;
using vi=vector<ll>;

void print(ll p,ll q){
  cout<<p<<" "<<q<<endl;
}
void solve() {
  ll n,m;
  cin>>n>>m;
  ll a=m/2;
  rep(i,a){
    print(i+1,i+1+2*(a-i));
  }
  ll b=m-a;
  rep(i,b){
    print(2*a+2+i,2*a+1+i+2*(b-i));
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl;
#define pv(v) for(auto a: v){ cout << a << endl; }


long gcd(long a, long b)
{
    long buff = a;
 
    if (a < b) {
        a = b;
        b = buff;
    }
 
    return b ? gcd(b, a % b) : a;
}

int main() { 
  long a, b, c, d; cin >> a >> b >> c >> d;

  long lcm =  c * d / gcd(c,d);

  long x = b/c;
  long y = b/d;
  long xy = b/lcm;

  long i = (a-1)/c;
  long j = (a-1)/d;
  long ij = (a-1)/lcm;

  long sumb = x + y -xy;
  long suma = i + j - ij;

  p((b - sumb) - (a - 1) + suma);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, x, ct;
	cin >> n;
	ct = 0;
	for (i = 0; i < n; i++) {
		cin >> x;
		while (x % 2 == 0) {
			x /= 2;
			ct++;
		}
	}

	cout << ct << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
inline int read()
{
    int s=0,f=1; char ch=getchar();
    while(!isdigit(ch) && ch!='-')ch=getchar();
    if(ch=='-')ch=getchar(),f=-1;
    while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
    return ~f?s:-s;
}

const int Zero=2e5-3;
const int One=2e5-1;
const int Two=2e5-2;
const int A=0;
const int B=1;

ll f[200020];

struct cz {
    int op,x,y,z;
};

int tmptot=5;

int a[100],b[100];

vector<cz>ans;

inline void Add(int a,int b,int c)
{
    f[c]=f[a]+f[b];
    ans.push_back((cz){0,a,b,c});
}

inline void Cmp(int a,int b,int c)
{
    f[c]=f[a]<f[b];
    ans.push_back((cz){1,a,b,c});
}

inline int Tmp(){ return ++tmptot;}

inline int power(int a,ll b) // 位置a *b 的位置
{
    int st=Tmp(); Add(a,st,st);
    int k=Tmp();
    while(b)
    {
	if(b&1)Add(k,st,k);
	b>>=1;
	Add(st,st,st);
    }
    return k;
}

inline int Mult(int a,int b)
{
    int t1=Tmp(),t2=Tmp(),t3=Tmp(),t4=Tmp();
    Cmp(Zero,a,t1); Cmp(Zero,b,t2);
    Cmp(a,b,t3); Cmp(b,a,t4);
    Add(t1,t2,t2); Add(t3,t4,t4);
    int t5=Tmp();
    Cmp(t4,t2,t5);
    return t5;
}

int main()
{
    f[0]=1e9-2; f[1]=1e9-1;
    Add(0,1,One);
    Cmp(2,One,One);
    Add(One,One,Two);

    Add(A,One,A);
    Add(B,One,B);

    int s=Tmp();
    DREP(i,30,0)
    {
	int p=Tmp(),val=power(One,1<<i),val1;
	Add(s,val,p);
	Cmp(p,A,a[i]=Tmp());
	val1=power(a[i],1<<i);
	Add(s,val1,s);
    }

    s=Tmp();
    DREP(i,30,0)
    {
	int p=Tmp(),val=power(One,1<<i),val1;
	Add(s,val,p); 
	Cmp(p,B,b[i]=Tmp());
	val1=power(b[i],1<<i);
	Add(s,val1,s);
    }
    s=2;
    REP(i,0,30)REP(j,0,30)
    {
	int t1=Mult(a[i],b[j]),val=power(t1,1ll<<i+j);
	Add(s,val,s);
    }
    printf("%d\n",SZ(ans));
    for(cz t:ans)
    {
	printf("%c %d %d %d\n",t.op==0?'+':'<',t.x,t.y,t.z);
    }
    cerr<<f[2]<<endl;
    return 0;
}


Measured memory_bytes: 4460
import numpy as np
N = int( input() )
V = np.array( list( map( int, input().split() ) ) ) # Value
C = np.array( list( map( int, input().split() ) ) ) # Cost

"""
Vi - Ci > 0 ならばその宝石を手に入れることで利益は増える
したがって全ての差を計算して0より大きいもので総和をとれば良い
たかだか N <= 20　回 なのでループで確認する
"""

P = V - C # Profit

ret = 0
for i in range( N ):
    if P[i] > 0:
        ret += P[i]

print( ret )


Measured memory_bytes: 13072
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	string ans = ""; forl(i, 0, n) ans += 'x';
	forl(i, 0, m) {
		int a; char b; cin >> a >> b; a--;
		if(ans[a] != 'x' and ans[a] != b) { println("-1"); return 0; }
		ans[a] = b;
	}
	if(ans[0] == '0' and n != 1) { println("-1"); return 0; }
	forl(i, 0, n) {
		if(ans[i] != 'x') continue;
		if(!i and n != 1) ans[i] = '1';
		else ans[i] = '0';
	}
	println(ans);
}


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

using namespace std;

int main(){
  long long i=1;
  long long j=1;
  long long n=0;
  vector< tuple <long long, long long, long long> > a;
  long long ans=0;
  bool sosuu=false;

  cin >> n;

  int pn=pow(n,(0.5));
  for(int i=2;i<=pn;i++){
    if(n%i==0){
      a.push_back(make_tuple( abs(i+n/i) , i , n/i ) );
      sosuu=true;
    }
  }
  sort(a.begin(),a.end());

  long long pans=0;
  long long qans=0;

  if(sosuu==false){
    cout << n-1 << endl;
  }
  else{
    pans=get<1>(a.at(0));
    qans=get<2>(a.at(0));
    ans=min(pans+qans-2,n-1);

    cout << ans << endl;
    //cout << pans << " " << qans << endl;
  }


  return 0;
}


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

int min(int a,int b){
  int temp;
  if(a>b)return b;
  if(a<=b)return a;
}

int max(int a,int b){
  int temp;
  if(a>b)return a;
  if(a<=b)return b;
}

int main(){

  int n,m;
  scanf("%d%d",&n,&m);

  int k[m],s[m][n];

  for(int i=0; i<m ; i++){
    scanf("%d",&k[i]);
    for(int j=0; j<k[i]; j++){
      scanf("%d",&s[i][j]);
    }
  }

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

  int ret = 0;
  for(int bit=0; bit < (1<<n); bit++){
    int sum = 0;
    for(int i=0; i<m; i++){
      int temp = 0;
      for(int j=0; j<k[i]; j++){
        if( (bit >> (s[i][j]-1)) & 1 ) temp ++;
      }
      //printf("%d ",temp);
    if( temp % 2 == p[i] ) sum++;  
    }
  if(sum == m) ret ++;
  }

  printf("%d",ret);

  return 0;

}

Measured memory_bytes: 128
o = list(input())
e = list(input())

ans = list('a' * (len(o) + len(e)))
tmp = 0
for i in range(0, len(ans), 2):
    ans[i] = o[tmp]
    tmp += 1
tmp = 0
for i in range(1, len(ans), 2):
    ans[i] = e[tmp]
    tmp += 1
print("".join(ans))


Measured memory_bytes: 3060
module modulo_util
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer(8), allocatable :: f(:), invf(:)
contains
  subroutine init(n)
    integer, intent(in) :: n
    integer :: i
    if (allocated(f)) deallocate(f)
    if (allocated(invf)) deallocate(invf)
    allocate(f(0:n),invf(0:n))
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
    end do
    invf(n) = inv(f(n))
    do i = n, 1, -1
      invf(i-1) = mod(invf(i)*int(i,8),md)
    end do
  end
  integer(8) function perm(n,k)
    integer, intent(in) :: n, k
    perm = 0_8
    if (k > n .or. n < 0 .or. k < 0) return
    perm = mod(f(n)*invf(n-k),md)
  end
  integer(8) function comb(n,k)
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
  end
  integer(8) function homo(n,k)
    integer, intent(in) :: n, k
    homo = 1_8
    if (n == 0 .and. k == 0) return
    homo = comb(n+k-1,k)
  end
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = modulo(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = modulo(y,md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: k
    integer(8) :: r, p
    r = 1_8
    p = a
    k = b
    do while (k > 0)
      if (btest(k,0)) r = mod(r*p,md)
      p = mod(p*p,md)
      k = rshift(k,1)
    end do
  end
end module modulo_util
program colorful_blocks
  use modulo_util
  implicit none
  integer :: n, k, i
  integer(8) :: m, ans = 0_8
  read(*,*) n, m, k
  call init(n)
  do i = 0, k
    ans = mod(ans+comb(n-1,i)*pow(m-1_8,n-1-i),md)
  end do
  write(*,'(i0)') mod(m*ans,md)
end program colorful_blocks

Measured memory_bytes: 5976
#include<stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)
            break;
    if(x<y){
        printf("%d %d\n",x,y);
        }
    else{
        printf("%d %d\n",y,x);
        }
    }



    return 0;
    }

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


bool primeNumber(long long n){
    if(n < 2) return false;
    else{
        for(long long j = 2; j* j <= n; j++){
            if(n % j == 0) return false;
        }
        return true;
    }
}


int main() {
long long Q;
cin>>Q;
long long A[100010]={};
A[0]=0;
A[1]=0;
A[2]=0;
for(long long i=2; i<=100000; i++){
    if(i%2!=0){
        if(primeNumber(i)==true && primeNumber(((i+1)/2))==true){
            A[i+1]=A[i-1]+1;
        }
        else{
            A[i+1]=A[i-1];
        }
        
    }
}
    
 for(long long i=0; i<Q; i++){
     long long l,r;
     cin>>l>>r;
     cout<<A[r+1]-A[l-1]<<endl;
 }   
    


}

Measured memory_bytes: 1408
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
 	long double h,a ;
 	cin >> h >> a;
 	
 	cout << ceil(h / a) << endl;       
}
}

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

#define REP(i,n) for(int i=0; i<(n); i++)
using namespace std;

int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

int W, H;
char rL[60][60], rR[60][60];
bool check[60][60][60][60];

struct state{
	int ly, lx, ry, rx;
	state(int y1, int x1, int y2, int x2){
		ly=y1; lx=x1;
		ry=y2; rx=x2;
	}
};

int main(){
	while(cin>>W>>H, W|H){
		fill( rL[0], rL[0]+60*60, '#' );
		fill( rR[0], rR[0]+60*60, '#' );
		fill( check[0][0][0], check[0][0][0]+60*60*60*60, false );
		int fLx, fLy, fRx, fRy;
		REP(i, H){
			int j;
			for(j=1; j<=W; j++){
				cin >> rL[i][j];
				if( rL[i][j] == 'L' ){
					fLx = j;
					fLy = i;
				}
			}
			for(j--; j>0; j--){
				cin >> rR[i][j];
				if( rR[i][j] == 'R' ){
					fRx = j;
					fRy = i;
				}
			}
		}
		stack<state> st;
		st.push(state(fLy, fLx, fRy, fRx));
		bool ret = false;
		while( !st.empty() && !ret ){
			int ly = st.top().ly;
			int lx = st.top().lx;
			int ry = st.top().ry;
			int rx = st.top().rx;
			st.pop();
			if( check[ly][lx][ry][rx] ) continue;
			check[ly][lx][ry][rx] = true;
			for(int k=0; k<4&&!ret; k++){
				char nL = rL[ ly+vy[k] ][ lx+vx[k] ];
				char nR = rR[ ry+vy[k] ][ rx+vx[k] ];
				if( nL == '.' && nR == '.' ) 
					st.push(state(ly+vy[k], lx+vx[k], ry+vy[k], rx+vx[k]));
				else if( nL == '.' && nR == '#' ) 
					st.push(state( ly+vy[k], lx+vx[k], ry, rx ));
				else if( nL == '#' && nR == '.' )
					st.push(state( ly, lx, ry+vy[k], rx+vx[k] ));
				else if( nL == '%' && nR == '%' ) 
					ret = true;
			}
		}
		if(ret) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;	
}

Measured memory_bytes: 27984
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>

const int MAX_N = 11;
const int MAX_NUMS = 101;
const int MAX_S = 1001;

long long dp[MAX_NUMS][MAX_S];

void solve(){
    dp[0][0] = 1;
    for(int i = 0; i < MAX_NUMS; ++i)
        for(int j = 9; j >= 0; --j)
            for(int k = 0; i + k < MAX_S; ++k)
                dp[j + 1][k + i] += dp[j][k];
    return;
}

int main(){
    // std::cout << dp[10][10] << std::endl;
    solve();

    int n, s;
    while(true){
        std::cin >> n >> s;
        if(n == 0 && s == 0)
            break;
        std::cout << dp[n][s] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final String string = scanner.nextLine();
		if (string.contains("A")) {
			System.out.println("T");
		} else if (string.contains("T")) {
			System.out.println("A");
		} else if (string.contains("C")) {
			System.out.println("G");
		} else {
			System.out.println("C");
		}
		scanner.close();
	}

}

Measured memory_bytes: 21844
N=int(input())
A=list(map(int, input().split()))
MOD=1000000007
s=0
for i in range(1,N):
    s+=A[i]
    s%=MOD

ans=0
for i in range(N-1):
    ans+=A[i]*s
    ans%=MOD
    s-=A[i+1]
    s%=MOD
    
print(ans%MOD)

Measured memory_bytes: 31572
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll y;
	cin>>y;
	y = sqrt(y);
	y = pow(y,2LL);
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

int k,a,b;

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	k=read();a=read();b=read();
	Rf(i,a,b) if(i%k==0) {
		puts("OK");
		return 0;
	}
	puts("NG");

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n,t;
  cin >> n >> t;
  ll cost = INFLONG;
  ll tmp1,tmp2;
  rep(i,n){
    cin >> tmp1 >> tmp2;
    if(tmp2 <= t){
      chmin(cost,tmp1);
    }
  }
  if(cost == INFLONG){
    cout << "TLE";
  }else{
    cout << cost;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;

    uint64_t n, power = 1;
    cin >> n;

    for (uint64_t i = 1; i <= n; i++) {
        power *= i;
        power %= 1000000007;
    }
    cout << power << endl;
}

Measured memory_bytes: 3628
n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(len(queue)>0):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)

Measured memory_bytes: 9688
#include<stdio.h>

#define INF (1 << 29)

typedef struct{
  int u;
  int k;
  int v[100];
  int c[100];
  int used;
  int cost;
} WeightedGraph;
WeightedGraph G[100];
void SSSP(int);

main(){
  int i, j, n, u, k;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d", &G[i].u, &G[i].k);
    for(j = 0; j < G[i].k; j++){
      scanf("%d %d", &G[i].v[j], &G[i].c[j]);
    }
  }
  SSSP(n);
  for(i = 0; i < n; i++){
    printf("%d %d\n", G[i].u, G[i].cost);
  }
  return 0;
}

void SSSP(int n){
  int i, j, res, minCost, pos, next_pos, next_cost;
  
  for(i = 0; i < n; i++){
    G[i].used = 0;
    G[i].cost = INF;
  }
  G[0].cost = 0;

  while(1){
    minCost = INF;
    for(i = 0; i < n; i++){
      if(G[i].used == 0 && minCost > G[i].cost){
	minCost = G[i].cost;
	pos = i;
      }
    }
    if(minCost == INF) break;
    G[pos].used = 1;

    for(i = 0; i < G[pos].k; i++){
      next_pos = G[pos].v[i];
      next_cost = G[pos].c[i] + minCost;
      if(G[next_pos].cost > next_cost) G[next_pos].cost = next_cost;
    }
  }
}

Measured memory_bytes: 680
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;

ll powmod(int a, int x){
	int i;
	ll res=1;
	rep(i, x){
		res = a*res % MOD;
	}
	return res;
}

int main(){
	int n;
	ll ans;
	cin >> n;
	ans = powmod(10, n) - (2 * powmod(9, n)) + powmod(8, n);
	ans %= MOD;
	if(ans < 0) ans = (ans + MOD)%MOD;
	cout << ans << endl;

}


Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;
const int INF = 5*1e9;
const int MAX = 1e2+10;
int a[MAX];

int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int n;
    int sum=0;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    for (int i=n-1; i>=0; i--) {
        for (int j=0; j<i; j++) {
            if (a[j]>a[j+1]) {
                int t;
                t=a[j+1];
                a[j+1]=a[j];
                a[j]=t;
                sum++;
            }
        }
    }
    for (int i=0; i<n; i++) {
        if (i) {
            printf(" ");
        }
        printf("%d",a[i]);
    }
    printf("\n%d\n",sum);
    return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
char a[10000],b[10000],p[10000];
int main()
{
	int c,d;
	scanf("%s",&a);
	scanf("%s",&b);
	scanf("%d %d",&c,&d);
	scanf("%s",&p);
	if(strcmp(p,a)==0)
	c--;
	else
	d--;
	printf("%d %d",c,d);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long 
#define pi 3.1415926536
using namespace std;
const ll N=1e6;
void solve()
{ll n,k,h,x,y,z,w,a,b,c,d,mini,maxi=INT_MAX,prev;
  cin>>k>>a>>b;
  c=a/k;
  d=b/k;
  if(a%k==0||b%k==0)
  cout<<"OK"<<endl;
  else if(d-c>0)
  cout<<"OK"<<endl;
  else
  cout<<"NG";
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //pre();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll pr(ll a,ll b,ll c)
{
	if(b==0)
	return 1LL;
	ll ans=1;
	while(b>0)
	{
		if(b%2)
		ans=((ans%c)*(a%c))%c;
		a=((a%c)*(a%c))%c;
		b/=2;
		a%=c;
		ans%=c;
	}
	return ans;
}
vector<ll> fact(N+1);
void pre()
{
	fact[0]=1;
	for(ll i=1;i<=N;i++)
	fact[i]=fact[i-1]*i,fact[i]%=hell;
	
}
*/

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
using pint = pair<int,int>;

int main() {
    int N; cin >> N;
    vector<long long> P(N);
    for (int i = 0; i < N; ++i) cin >> P[i];

    // prev[i] := i より手前で初めて P[i] より小さい値になる場所
    // next[i] := i より先で初めて P[i] より小さい値になる場所
    vector<int> prev(N, 0), next(N, N);
    stack<pint> st;
    st.push({0, -1}); // 番兵
    for (int i = 0; i < N; ++i) {
        while (st.size() > 0 && st.top().first >= P[i]) st.pop();
        prev[i] = st.top().second + 1;       
        st.push({P[i],i});
    }
    while (!st.empty()) st.pop();
    st.push({0, N});
    for (int i = N-1; i >= 0; --i) {
        while (st.size() > 0 && st.top().first >= P[i]) st.pop();
        next[i] = st.top().second;      
        st.push({P[i],i});
    }

    // 集計
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        //cout << i << ": " << next[i] << ", " << prev[i] << endl;
        res += P[i] * (next[i] - i) * (i+1 - prev[i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 4992