akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int x = sc.nextInt();
        if(x >= 1200) System.out.println("ARC");
        else System.out.println("ABC");

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 23252
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ca=Counter(a)
cb=Counter(b)
for k in cb:
    if k in ca:
        if cb[k]+ca[k]>n:
            print('No')
            exit()
ans=b.copy()
ans.reverse()
ng=set(())
ok=[]
for i in range(n):
    if a[i]==ans[i]:
        ng.add(i)
    else:
        ok.append(i)
from random import randint
if ng:
    for x in ng:
        y=ok[randint(0,len(ok)-1)]
        while ans[x]==a[y] or ans[y]==a[x]:
            y=ok[randint(0,len(ok)-1)]
        ans[x],ans[y]=ans[y],ans[x]
        ok.append(x)
print('Yes')
print(*ans,sep=' ')


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

int main()
{
    int a,b;
    int t = 0;

    while(cin >> a >> b , a || b)
    {
        bool NAflag = true;

        if(t != 0)cout << '\n';
        for(int i=a; i<=b; i++){
            if(i%4 == 0 && (i%100 != 0 || i%400 == 0)){
                cout << i << endl;
                NAflag = false;
            }
        }
        if(NAflag){
            cout << "NA" << endl;
        }
        
        t++;
    }

    return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)
d = [0] * (10 ** 5 + 10)
for i in a:
    d[i] += 1
for _ in range(q):
    b, c = map(int, input().split())
    ans += c * d[b] - b * d[b]
    print(ans)
    d[c] += d[b]
    d[b] = 0


Measured memory_bytes: 85640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int g[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
	cin>>x>>y;
	if(g[x]==g[y]){
		cout<<"Yes"<<endl;
	}else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> ch = {"Christmas", "Christmas Eve", "Christmas Eve Eve", "Christmas Eve Eve Eve"};
    int d;
    cin >> d;
    cout << ch[25-d] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_BIN 17
unsigned long long int crop(unsigned long long int num, int a){
    return (num&((1<<a)-1))+((num&(((1<<MAX_BIN)-1)^((1<<(a+1))-1)))>>1);
}
unsigned long long int insert(unsigned long long int num, int bit,int a){
    return (num&((1<<a)-1))+((num&(((1<<MAX_BIN)-1)^((1<<a)-1)))<<1)+(bit<<a);
}

vector<unsigned long long int> GrayCodeGenerator(unsigned long long int a,unsigned long long int b,int binary_digit){
    std::bitset<17> dif(a^b);
    if(dif.count()%2==0){
        vector<unsigned long long int> v={};
        return v;
    }
    if(binary_digit==1){
        vector<unsigned long long int> ans;
        ans.push_back(a);
        ans.push_back(b);
        return ans;
    }
    int dig;
    for(int i=binary_digit-1;i>=0;i--){
        if((a&(1<<i))!=(b&(1<<i)))dig=i;
    }
    unsigned long long int adash=crop(a,dig);
    unsigned long long int bdash=crop(b,dig);
    unsigned long long int c=adash;
    c=c^(1<<(binary_digit-2));
    vector<unsigned long long int> p=GrayCodeGenerator(adash,c,binary_digit-1);
    vector<unsigned long long int> q=GrayCodeGenerator(c,bdash,binary_digit-1);
    REP(i,p.size())p[i]=insert(p[i],(a&(1<<dig))>>dig,dig);
    REP(i,q.size())q[i]=insert(q[i],(b&(1<<dig))>>dig,dig);
    std::copy(q.begin(),q.end(),std::back_inserter(p));
    return p;
}

int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    vector<unsigned long long int> ans=GrayCodeGenerator(a,b,n);
    if(ans.empty())printf("NO\n");
    else{
        printf("YES\n");
        for(unsigned long long int i : ans){
            printf("%lld\n",i);
        }
    }
    return 0;
}

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

int time1 = 0;
int a[110][110] = {};
int d[110] = {};
int f[110] = {};
int n;
int p;

void dfs(int cur){
  if(d[cur]==0){
    d[cur] = time1;
  }
  time1 += 1;
  f[cur] = time1;

  for(int dst=1;dst<=n;dst++){
    if(a[cur][dst]==1&&d[dst]==0){
      a[cur][dst]=2;
      dfs(dst);
    }
  }
  for(int k=1;k<=n;k++){
    if(a[k][cur]==2){
      a[k][cur]=1;
      p+=1;
      dfs(k);
    }else{
      p=0;
    }
  }
  if(p==0){
    for(int k=1;k<=n;k++){
      if(d[k]==0){
	time1+=1;
	dfs(k);
      }
    }
  }
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int v;
      cin>>v;
      a[i][v]=1;
    }
  }
  time1 += 1;
  dfs(1);
  for(int k=1;k<=n;k++){
    cout<<k<<" "<<d[k]<<" "<<f[k]<<endl;
  }
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> c(m,vector<int>(n,0));
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      c.at(i).at(s-1)=1;
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;i++)
    cin>>p.at(i);
  int a=0;
  for(int i=0;i<(1<<n);i++){
    vector<int> b(n);
    int x=i;
    for(int d=0;d<n;d++){
      b.at(d)=x%2;
      x/=2;
    }
    bool f=1;
    for(int j=0;j<m;j++){
      int s=0;
      for(int k=0;k<n;k++)
        s+=b.at(k)*c.at(j).at(k);
      f=(s%2==p.at(j)?f:0);
    }
    a+=(f?1:0);
  }
  cout<<a<<endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a == 1 && b == 2) || (b == 1 && a == 2)) {
        cout << 3 << endl;
    } else if ((a == 2 && b == 3) || (b == 2 && a == 3)) {
        cout << 1 << endl;
    } else if ((a == 3 && b == 1) || (b == 3 && a == 1)) {
        cout << 2 << endl;
    }
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

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

vector<pair<int, int>> v;
	
int solve(int idx, int A, int B) {
	int ret = 10000;

	if (idx == v.size()) {
		return max(to_string(A).size(), to_string(B).size());
	}

	rep(i, v[idx].second + 1) {
		int cA = A;
		int cB = B;

		rep(j, i) cA *= v[idx].first;
		rep(j, v[idx].second - i) cB *= v[idx].first;

		ret = min(ret, solve(idx + 1, cA, cB));
	}

	return ret;
}

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

	int pt = 0;
	int loop = sqrt(N) + 1;
	REP(i, 2, loop) {
		if (N % i) continue;

		v.push_back(make_pair(i, 0));
		while (N % i == 0) {
			N /= i;
			v[pt].second++;
		}

		pt++;
	}

	if (N > 1) {
		v.push_back(make_pair(N, 1));
	}

	cout << solve(0, 1, 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,s;
  cin >> k >> s;
  int counter =0;
  for(int x = 0;x <= k;x++){
    for(int y = 0;y <= k;y++){
        if(k >= s-x-y && s-x-y >= 0) counter++;
    }
  }
  cout << counter << endl;
}


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

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
ll ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> k;
    vector<int> a(n);
    vector<ll> asum(n+1, 0);
    vector<ll> bsum(n+1, 0);    // max{0, a_i}
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) {
        asum[i+1] = asum[i] + a[i];
        bsum[i+1] = bsum[i] + max(0, a[i]);
    }
    erep(i, 0, n-k) {
        ll p = bsum[n] - (bsum[k+i] - bsum[i]);
        ll q = p + asum[k+i] - asum[i];
        ans = max(ans, max(p, q));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
	ll n;cin>>n;
	set <string> st;
	while(n--)
	{
		string s;cin>>s;
		st.insert(s);
	}
	cout<<st.size();
}


int main()       
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}


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

int main() {
  long long int A,B,C,a,b,c, count  = 0; cin >> A >> B >> C;
  a = A, b = B, c = C;
  if (a==b && b==c) {
    if (a%2 == 0)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  }
  else {
    while (a%2==0 && b%2==0 && c%2==0) {
      A = (b+c)/2, B = (a+c)/2, C = (a+b)/2;
      a = A, b = B, c= C;
      count++;
    }
    cout << count << endl;
  }
  return 0;
}


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

int main(){
    int N,X;
    cin >> N >> X;
    int m[N];
    int sum=0;
    int res=10000;
    for(int i=0;i<N;i++){
        cin >> m[i];
        sum+=m[i];
        res=min(res,m[i]);
    }
    X-=sum;
    int cnt=N;
    while(X>=res){
        X-=res;
        cnt++;
    }
    cout << cnt << endl;
}

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

struct edge{
    long long u;
    long long v;
    long long cost;
};

struct UnionFind {
	vector<long long> par;
	UnionFind(long long size) : par(size + 1, -1) {}
	bool unite(long long x, long long y){
		x = root(x);
        y = root(y);
		if (x != y){
			if(par[y] < par[x]) swap(x, y);
			par[x] += par[y];
            par[y] = x;
		}
		return x != y;
	}
	bool same(long long x, long long y){
        return root(x) == root(y);
    }
	int root(long long x){
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
	int size(long long x){
        return -par[root(x)];
    }
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

int kruskal(int n, vector<edge> tr){
    sort(tr.begin(), tr.end(), comp);
    UnionFind tree(n);
    int ret  =0;
    for(auto e : tr){
        if(!tree.same(e.u, e.v)){
            tree.unite(e.u, e.v);
            ret += e.cost;
        }
    }
    return ret;
}

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> a(n), b(n);
	for(int i = 0; i < n; i++){
		cin >> a[i].first >> b[i].first;
		a[i].second = i;
		b[i].second = i;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	vector<edge> G;
	for(int i = 0; i < n - 1; i++){
		G.push_back({a[i].second, a[i + 1].second, a[i + 1].first - a[i].first});
		G.push_back({b[i].second, b[i + 1].second, b[i + 1].first - b[i].first});
	}
	cout << kruskal(n, G) << endl;
    return 0;
}


Measured memory_bytes: 15028
def main():
    a, b, c = [int(v) for v in input().split(' ')]
    k = int(input())

    for _ in range(k):
        if b <= a:
            b *= 2
        else:
            c *= 2

    if c > b and b > a:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
N,K=map(int,input().split())
A=[]
sunuke=[False]*N
ds=[]
ans=0
for k in range(K):
    d=int(input())
    ds.append(d)
    a=list(map(int,input().split()))
    A.append(a)

for i in range(K):
    for j in range(ds[i]):
        sunuke[A[i][j]-1]=True


for i in range(N):
    if sunuke[i]==False:
        ans+=1
print(ans)    

Measured memory_bytes: 9208
#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 all(x) x.begin(),x.end()


int main()
{
    string s, t;cin>>s>>t;
    reverse(all(s));
    reverse(all(t));
    string ans = "UNRESTORABLE";
    int l = s.size() - t.size();
    rep(i,0,l){
        int cnt = 0;
        rep(j,0,t.size()-1){
            if(s[i+j]!=t[j] && s[i+j] != '?')break;
            
            if(j==t.size()-1){
                ans = s.substr(0,i)+t+s.substr(i+t.size());
                reverse(all(ans));
                rep(k,0,ans.size()-1){
                    if(ans[k]=='?')ans[k]='a';
                }
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  
  if(a<=8 && b<=8) co("Yay!");
  else co(":(");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a_1(int a) {//素数判定
	int x = 0;
	for (int i = 2; i < a; i++) {
		if (a % i == 0)x++;
	}
	if (x == 0) {
		return 0;//素数であるとき
	}
	if (x != 0) {
		return 1;//素数でないとき
	}
}
int gcd(int a, int b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
int main() {
	int x;
	cin >> x;
	for (int i = 1000;; i += 1000) {
		if (x <= i) {
			cout << i - x << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3580
use std::io::Read;
use std::collections::{HashSet, VecDeque, HashMap};

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let edges: Vec<(usize, usize)> =
        (0..(n - 1))
            .map(|_| {
                let ai: usize = iterator.next().unwrap().parse().unwrap();
                let bi: usize = iterator.next().unwrap().parse().unwrap();
                (ai - 1, bi - 1)
            })
            .collect();

    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
    for &edge in &edges {
        graph[edge.0].push(edge.1);
        graph[edge.1].push(edge.0);
    }
    let k: usize = graph.iter().map(|it| it.len()).max().unwrap();

    let mut colors: HashMap<(usize, usize), usize> = HashMap::new();
    let mut used: Vec<HashSet<usize>> = vec![HashSet::new(); n];
    let mut visited: Vec<bool> = vec![false; n];
    let mut q = VecDeque::new();
    q.push_back(0_usize);
    visited[0] = true;
    while let Some(u) = q.pop_front() {
        let mut color = 1;
        for &v in &graph[u] {
            if visited[v] {
                continue;
            }
            if used[u].contains(&color) {
                color += 1;
            }
            if u < v {
                colors.insert((u, v), color);
            } else {
                colors.insert((v, u), color);
            }
            used[u].insert(color);
            used[v].insert(color);
            visited[v] = true;
            q.push_back(v);
            color += 1;
        }
    }

    let mut result = String::new();
    result.push_str(&format!("{}\n", k));
    for &edge in &edges {
        let color = colors.get(&edge).unwrap();
        result.push_str(&format!("{}\n", color));
    }
    result.trim().to_string()
}


Measured memory_bytes: 26172
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	long long N; cin >> N;
	string S; cin >> S;
	long long R = 0, W = 0;
	for (long long i = 0; i < N; i++) {
		if (S.at(i) == 'R') R++;
		else W++;
	}
	long long ans = 0;
	for (long long i = 0; i < R; i++) {
		if (S.at(i) != 'R') ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <algorithm>
using namespace std;
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int n;
    scanf("%d", &n);
    printf("%d", a[n - 1]);
    return 0;
}

Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int n;
    int a[200000];
    ll sum[200010] = { 0 };
    
    cin >> n;
    rep(i, n) cin >> a[i];

    rep(i, n) sum[i+1] = sum[i] + a[i];

    ll ans = 1ll << 62;
    rep(i, n-1) ans = min(ans, abs(sum[i+1] - (sum[n] - sum[i+1])));

    cout << ans << endl;
}


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

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; ++j) {
        if (A[j] <= x) {
            i = i + 1;
            int tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    int tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;
    return i + 1;
}

int main() {
    int n;
    cin >> n;

    int *A = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    int q = partition(A, 0, n - 1);

    for (int i = 0; i < n; ++i) {
        if (i) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1572
package main

import "fmt"

func main() {
	var n int
	var s, t string
	fmt.Scan(&n, &s, &t)

	ans := ""
	for i := 0; i <= n; i++ {
		tmp := s + t[i:]
		if tmp[len(tmp)-n:] == t {
			ans = tmp
		}
	}

	fmt.Println(len(ans))
}


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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i64 A=read(),B=read(),N=read();
    print( A*Min(N,B-1)/B );
    output();
    return 0;
}

Measured memory_bytes: 3624
require 'set'
n = gets.chomp.to_i
s = gets.chomp.split('')
s1 = Set.new
s2 = Set.new
max = 0
(n - 1).times do |i|
        0.upto(i) do |j|
                s1.add(s[j])
        end
        (i + 1).upto(n - 1) do |j|
                s2.add(s[j])
        end
        num = 0
        s1.each do |j|
                if s2.include?(j) then num += 1 end
        end
        max = (num > max) ? num : max
        s1.clear
        s2.clear
end
puts max


Measured memory_bytes: 3964
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

int main()
{
    string S;
    cin >> S;
    if ((S[2] == S[3]) && (S[4] == S[5])) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
using ll = long long;

ll f(ll b, ll n) {
  if (n < b) {
    return n;
  } else {
    return f(b, n / b) + (n % b);
  }
}

int main() {
  ll n, s;
  cin >> n >> s;

  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }

  int sqrtn = sqrt(n);
  for (int i = 2; i <= sqrtn; i++) {
    if (f(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }

  for (int p = sqrtn + 1; p > 0; p--) {
    if ((n - s) % p == 0) {
      ll b = (n - s) / p + 1;
      if (b >= 2 && f(b, n) == s) {
        cout << b << endl;
        return 0;
      }
    }
  }

  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int sum[5002][5002];
int x[5002];
int y[5002];
int X[5002];
int Y[5002];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
		X[i]=x[i];
		Y[i]=y[i];
	}
	X[a]=-1999999999;
	X[a+1]=1999999999;
	Y[a]=-1999999999;
	Y[a+1]=1999999999;
	std::sort(X,X+a+2);
	std::sort(Y,Y+a+2);
	for(int i=0;i<a;i++){
		x[i]=lower_bound(X,X+a+2,x[i])-X;
		y[i]=lower_bound(Y,Y+a+2,y[i])-Y;
		sum[x[i]][y[i]]++;
	}
	for(int i=0;i<a+2;i++){
		for(int j=1;j<a+2;j++){
			sum[i][j]+=sum[i][j-1];
		}
	}
	for(int i=0;i<a+2;i++){
		for(int j=1;j<a+2;j++){
			sum[j][i]+=sum[j-1][i];
		}
	}
	for(int i=0;i<b;i++){
		int p,q,r,s;
		scanf("%d%d%d%d",&p,&q,&r,&s);
		int P=lower_bound(X,X+a+2,p)-X-1;
		int Q=lower_bound(Y,Y+a+2,q)-Y-1;
		int R=upper_bound(X,X+a+2,r)-X-1;
		int S=upper_bound(Y,Y+a+2,s)-Y-1;
		printf("%d\n",sum[R][S]-sum[R][Q]-sum[P][S]+sum[P][Q]);
	}
}

Measured memory_bytes: 98856
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
s = na()
t = na()
mod = 10**9+7

dp = [[0 for i in range(m + 1)] for j in range(n + 1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if (s[i-1] == t[j-1]):
            dp[i][j] = (1 + dp[i][j-1] + dp[i-1][j])%mod
        else:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1])%mod
  
print((dp[n][m]+1)%mod)

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

int main() 
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        if (C <= i && i <= D) {
            ans++;
        }
    }
    if (ans != 0) {
        cout << ans-1 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
    int n, array[100], count;
    scanf("%d", &n);
    for(count = 0; count < n ; count++){
        scanf("%d", &array[count]);
    }
    printf("%d", array[n - 1]);
    for(count = n - 2; count >= 0; count--){
        printf(" %d", array[count]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
one = [1,3,5,7,8,10,12]
two = [4,6,9,11]
three = [2]
a,b = map(int,input().split())
if a in one and b in one:
    print('Yes')
elif a in two and b in two:
    print('Yes')
elif a in three and b in three:
    print('Yes')
else:
    print('No')

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

using namespace std;

int main(){
	int n,x;
	int a[100001]={};
	int ans=0;
	cin >>n;
	for(int i=1;i<=n;i++){
		cin >>x;
		a[i]=x;
		if(a[x]==i)ans+=1;
	}
	cout << ans << endl;
	return 0;
}

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

    class Program
    {
        static void Main()
        {
            var n = int.Parse(System.Console.ReadLine());
            var ans = 0;
            if (400 <= n && n <= 599) ans = 8;
            else if (600 <= n && n <= 799) ans = 7;
            else if (800 <= n && n <= 999) ans = 6;
            else if (1000 <= n && n <= 1199) ans = 5;
            else if (1200 <= n && n <= 1399) ans = 4;
            else if (1400 <= n && n <= 1599) ans = 3;
            else if (1600 <= n && n <= 1799) ans = 2;
            else if (1800 <= n && n <= 1999) ans = 1;

            Output(ans.ToString());

        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5) + 5;
ll n, m;
 
void solve(){
	cin >> n;
	if(n>=30) {
		cout<<"Yes";
		// return 0;
	} else {
		cout<<"No";
	}
}

int main(){
	fast;
	// #ifndef ONLINE_JUDGE 
 //   freopen("input.txt", "r", stdin); 
 //   freopen("output.txt", "w", stdout); 
 //   #endif 
   
	// tt
		solve();
		return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int td = N.toCharArray()[0] - '0';
		if (td * 111 < Integer.parseInt(N)) {
			System.out.println((td + 1) * 111);
		} else {
			System.out.println(td * 111);
		}

		sc.close();

	}
}

Measured memory_bytes: 21844
import java.io.PrintWriter
import java.lang.StringBuilder

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    // zはNの約数　かつ　ある素数のe乗
    // nを素因数分解し、それぞれの指数に対して　1, 2, 3を選択してゆく
    val n = readLong()
    val primeFactor = primeFactor(n)
    var ans = 0L
    for (v in primeFactor.values) {
        var sum = 0L
        var i = 1L
        while (sum + i <= v) {
            sum += i
            i++
            ans++
        }
    }

    println(ans)
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
if n == 1, return emptyMap
 */
fun primeFactor(n: Long): Map<Long, Long> {
    val factorMap = mutableMapOf<Long, Long>()
    var target = n
    var i = 2L
    while (i * i <= target) {
        while (target % i == 0L) {
            factorMap[i] = factorMap.getOrElse(i) { 0L } + 1L
            target /= i
        }
        i++
    }

    if (target != 1L) { factorMap[target] = 1 }
    return factorMap
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34684
#include<stdio.h>
int main(void){
  int i, j, n, k, t, d[100], a[100],s=0;
  scanf("%d%d", &n, &k);
  for(i=1;i<=n;i++){
    a[i]=0;
  }
  for(i=1;i<=k;i++){
    scanf("%d", &d[i]);
    for(j=1;j<=d[i];j++){
      scanf("%d", &t);
      a[t]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(a[i]==0){
      s++;
    }
  }   
  printf("%d", s);
  return 0;
}


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

#define LL long long

const int N = 100;
const long long mod = 1e9 + 7;

using namespace std;

int n,k,ans;
int a[N][N];

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin>>n>>k;
    for( int i=1; i<=n; i++ ){
        for( int j=1; j<=k; j++ ){
            cin>>a[i][j];
        }
    }
    for( int i=1; i<=n; i++ ){
        for( int j=1;  j <= n; j++ ){
            if( i == j )continue;
            int cnt = 0;
            for( int h=1; h <= k; h++ ){
                cnt += ( ( a[i][h] - a[j][h] ) * ( a[i][h] - a[j][h] ) );
            }
            int k = sqrt(cnt);
            if( k * k == cnt )ans++;
        }
    }
    cout<<ans / 2;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll L, R;
    ll mini = LONG_LONG_MAX;
    cin >> L >> R;
    repi2(i, L, R) {
        repi2(j, i + 1, R) {
            mini = min(mini, i * j % 2019);
            if(mini == 0) goto aaa;
        }
    }
    aaa:
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

void solve(){
  ll n; cin >> n;
  if(n == 1) {
    cout << 0 << endl;
    return;
  } else if(n == 2) {
    cout << 2 << endl;
    return;
  }
  ll ans = 1;
  for(int i = 0; i < n; ++i) {
    ans *= 10;
    ans %= MOD;
  }
  ll notOK = 1;
  for(int i = 0; i < n; ++i){
    notOK *= 9;
    notOK %= MOD;
  }
  notOK *= 2;
  notOK %= MOD;
  ll notOKbutOK = 1;
  for(int i = 0; i < n; ++i) {
    notOKbutOK *= 8;
    notOKbutOK %= MOD;
  }
  // cout << ans << " " << notOK << " " << notOKbutOK << endl;
  if(ans  - notOK + notOKbutOK >= 0) ans = (ans - notOK + notOKbutOK) % MOD;
  else ans = (ans - notOK + notOKbutOK + MOD) % MOD;
  cout << ans << endl;
  
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000007;

int main() {
    int r, n;
    cin >> n >> r;
    if (n >= 10)cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    
    return 0;
}

Measured memory_bytes: 256
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int dp[2001][2001]; //I
int dp2[2001][2001]; //OI
char s[2001], t[2001];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s%s", s, t);
    int ans = 0;
    for(int i : in(n + 1)) for(int j : in(m + 1)) {
        ans = max(ans, dp[i][j]);
        if(i < n) {
            if(s[n - i - 1] == 'I')
              dp[i + 1][j] = max(dp[i + 1][j], dp2[i][j] + 1);
            else if(dp[i][j] > 0)
              dp2[i + 1][j] = max(dp2[i + 1][j], dp[i][j] + 1);
        }
        if(j < m) {
            if(t[m - j - 1] == 'I')
              dp[i][j + 1] = max(dp[i][j + 1], dp2[i][j] + 1);
            else if(dp[i][j] > 0)
              dp2[i][j + 1] = max(dp2[i][j + 1], dp[i][j] + 1);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 34488
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n = scan.nextInt();
			int[] a = new int[n];
			//int[] b = new int[n];
			int sum=0;
			for(int i=0;i<n;i++)
			{
				a[i]=scan.nextInt();
				sum=sum+a[i];
			}
			int abc=0;
			for(int i=0;i<n;i++)
			{
				abc=abc+a[i]*(sum-a[i]);
			}
			System.out.println(abc/2);
    	}
    }

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

int main(){
  ll n;
  cin >> n;
  string ans="";
  while(n){
    if(n%26!=0)ans+='a'+(n%26)-1;
    else{
      ans+='z';
      n--;
    }
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
return 0;}

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

int n, f=0, s=0;
vector<vector<int>> g(100002);
int tmp1[100002]={}, tmp2[100002]={};

void dfs(int k, int d, int *a) {
    if (a[k])
        return;
    a[k] = d;
    for (int t : g[k])
        dfs(t, d+1, a);
    return;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=1; i<n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 1, tmp1);
    dfs(n, 1, tmp2);
    for (int i=1; i<=n; i++)
        if(tmp1[i] <= tmp2[i])
            f++;
        else
            s++;
    if (f > s)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
}


Measured memory_bytes: 11264
n = int(input())

x = n%10
if x==7:
  print("Yes")

else:
  y = n//10#nを更新(位をずらす)

  if y%10==7:
    print("Yes")

  else:
    z = y//10
    if z==7:
      print("Yes")
    else:
      print("No")


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

LL a[105];
LL dp[100005];
LL n;

LL cal(LL k)
{
   // cout<<"k is "<<k<<endl;
    LL i;
    if(dp[k]==-1)
    {
        LL truth=0;
        for(i=1;i<=n;i++)
        {
            if(k-a[i]<0)
            {
                break;
            }
            else
            {
                if(cal(k-a[i])==0)
                {
                    truth=1;
                    break;
                }
            }            
        }

        dp[k]=truth;
    }
    //cout<<"dp["<<k<<"] is "<<dp[k]<<endl;
    return dp[k];
}

int main()
{
    LL k,i,j;
    cin>>n>>k;
    
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    

    sort(a+1,a+n+1);

    for(i=1;i<100005;i++)
    {
        dp[i]=-1;
    }

    dp[0]=0;

    LL ans=cal(k);
    if(ans==1)
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }
    

}

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++){
      for(int j=i+1;j<s.size();j++){
         if(s[i] == s[j]){
            cout << "no" << endl;
            return 0;
         }
      }
   }
   cout << "yes" << endl;
   return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
  s=list(map(str,input().split()))
  for j in range(w):
    if s[j]=="snuke":
      print(alphabet[j]+str(i+1))

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a,b,c,tmp;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  string S;
  int K;
  cin >> S >> K;
  int i = 0;
  while(true){
    if(S[i] != '1' || i == K-1){
      cout << S[i] << endl;
      break;
    } 
    ++i;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const double Pi = acos(-1.);
const int N = 110;
int n;
struct D{double x, y, f;} d[N], e[N];
double ans[N];

bool cmp(D a, D b) {return a.f < b.f;}

int main() {
	int i, j, m; D key;
	scanf("%d", &n);
	rep(i, 1, n) scanf("%lf%lf", &d[i].x, &d[i].y);
	rep(i, 1, n) {
		key = d[i];
		
		m = 0;
		rep(j, 1, n)
			if(i != j) {e[++m] = d[j]; e[m].f = atan2(e[m].y-key.y, e[m].x-key.x);}
		sort(e+1, e+m+1, cmp);
		rep(j, 1, m-1)
			if(e[j+1].f - e[j].f > Pi) ans[i] = (e[j+1].f - e[j].f - Pi) / Pi / 2.;
		if(e[1].f + Pi + Pi - e[m].f > Pi) ans[i] = (e[1].f + Pi - e[m].f) / Pi / 2.;
		printf("%.7lf\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld a,p;
     cin>>a>>p;
     cout<<((a*3)+p)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
num = int(7)

ipt = input()
ipt = int(ipt)

res = 1
ok = False
while res < 1000000:
    if num % ipt==0:
        print(res)
        ok = True
        break
    else:
        num = num % ipt
        res = res + 1
        num = num*10 +7

if ok == False:
    print(-1)



Measured memory_bytes: 9168