akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
        int t=sc.nextInt();
        int s=0;
        if(n%k==0) {
        	s=n/k;
        }
        else {
        	s=n/k+1;
        }
        System.out.println(t*s);

		
	}
}

Measured memory_bytes: 35628
class Max
  def solve
    loop do
      n = gets.chomp.to_i
      break if n == 0
      
      max = -100000
      sum = 0
      n.times do
        a = gets.chomp.to_i
        sum += a
        if max < sum
          max = sum
        end
        if sum < 0 then 
          sum = 0
        end
      end
      puts max
    end
  end
end
Max.new.solve

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, MOTON,i;
  int sum=0;
  cin >> N ;
  
  MOTON = N;
  while(N>0){
	sum+= N%10;//   sum = sum +N%10;//sum+= N%10;
	N/=10;//   N =  N/10;//N /= 10
			}
  if(MOTON%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
   }
}


  
  
  /*  for(i=100000000;i=0;i/10){
   	 while(N/i!=0){
      sum += N/i;
      N -= N/i;
      }
  }
*/

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
struct E
{
	string a;
	int sc,num;
}r[110];
bool cmp(E a,E b)
{
	if(a.a==b.a)
		return a.sc>b.sc;
	return a.a<b.a;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>r[i].a>>r[i].sc;
		r[i].num=i+1;
	}
	sort(r,r+n,cmp);
	for(int i=0;i<n;i++)
	{
		cout<<r[i].num<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#id:KabukiMining
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]
    
    rks = [None] *n
    sys.setrecursionlimit(10**9)
    # r: どの連結成分に存在するかをメモするid
    def dfs(graph,s,r):
        if rks[s] is None:
            rks[s] = r
        for i in range(len(graph[s])):
            if rks[graph[s][i]-1] is not None:
                continue
            dfs(graph, graph[s][i]-1,r)

    for i in range(m):
        a,b = map(int, input().split())
        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    # print(fgraph)
    #print(bgraph)
    # 連結成分に対してid的なindexをつける
    c = -1
    for i in range(n):
        if rks[i] is None:
            c += 1
            dfs(fgraph, i, c)
    
    for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)

    counter = Counter(rks)
    for i in range(n):
        # counter[rks[i]] 連結成分のサイズ
        # len(fgraph[i]) 友達の数
        # len(bgraph[i]) 連結成分内のブロックの数
        # 1 自分
        print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 66768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  long long dp[110][4][4][4] = {}; // A:0, G:1, C:2, T:3
  rep(x, 4) rep(y, 4) rep(z, 4) dp[0][x][y][z] = 1;
  dp[0][2][1][0] = dp[0][2][0][1] = dp[0][1][2][0] = 0;

  rep(i, n) rep(j, 4) rep(x, 4) rep(y, 4) rep(z, 4) {
    if (j==2 and x==1 and y==0) continue;
    if (j==2 and x==0 and y==1) continue;
    if (j==1 and x==2 and y==0) continue;
    if (j==2 and x==1 and z==0) continue;
    if (j==2 and y==1 and z==0) continue;
    dp[i+1][j][x][y] = (dp[i+1][j][x][y] + dp[i][x][y][z]) % MOD;
  }
  print(dp[n][3][3][3]);

  return 0;
}

Measured memory_bytes: 256
data = list(map(int, input().split()))
n = int(input())
dice = ['12431', '03520', '01540', '04510', '02530', '13421']
for i in range(n):
    up, front = map(int, input().split())
    u = data.index(up)
    f = data.index(front)
    a = dice[u].find(str(f))
    print(data[int(dice[u][a+1])])


Measured memory_bytes: 5596
n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i).sort().reverse
longest = 0
second  = 0
update_flag = false
(0..a.length - 2).each do |i|
  break if longest != 0 && second != 0
  if update_flag
    update_flag = false
    next
  end
  if a[i] == a[i + 1]
    if longest == 0
      longest = a[i]
    else
      second = a[i]
    end
      update_flag = true
  end
end

puts longest * second

Measured memory_bytes: 11016
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
typedef long long ll; const int inf=2e9;
typedef double lf; const lf err=1e-7;
typedef pair<int,int> pii;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define Clear(a) {a=decltype(a)();}
#define qwq {cerr<<"qwq"<<endl;}
#define orz(x) {cerr<<#x": "<<x<<endl;}
ll read(){ll n; scanf("%lld",&n); return n;}
const int N=2010;
const int mod=1e9+7;
//#define int ll
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,ans=0,m=inf,x;
	cin>>n;
	repeat(i,0,n){
		cin>>x;
		if(x<m){
			m=x;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    char s[5];
    scanf("%s",s);
    int a[256]={};
    for(int i=0;i<4;i++)a[s[i]]++;
    for(int i=0;i<4;i++){
        if(a[s[i]]!=2){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

long long modi=1000000007;

int main()
{
    long long pre[2004][2004],dp[2004][2004];
    long long ans=0,s,i,j;
    cin>>s;
    for(i=3;i<=s;i++)
    {
        dp[1][i]=1;
        pre[1][i]=dp[1][i]+((i==3)?0:pre[1][i-1]);
      //cout<<pre[1][i]<<" "<<i<<"\n";
    }
    //cout<<pre[1][4]<<" ";
    ans=(ans+dp[1][s])%modi;
    for(i=3;i<=s;i++)
    {
        for(j=2;j<=s/3;j++)
        {
            dp[j][i]=(pre[j-1][i-3]+dp[j][i])%modi;
            if(i==s){ans=(ans+dp[j][s])%modi;}
            pre[j][i]=(pre[j][i-1]+dp[j][i])%modi;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 24556
H,W,K= map(int,input().split())
a= [list(input())for i in range(H)]
ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        black = 0
        for i in range(H):
            for j in range(W):
                if(a[i][j]!='#'):
                    continue
                if h>>i&1!=0 or w>>j&1!=0:
                    continue
                black+=1
        if black == K:
            ans+=1
print(ans)

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

// Ngoc Minh

using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define f first
#define s second
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define bit(x,k) ((x>>k)&1ll)
#define offbit(x,k) (~(1ll<<k)&x)
#define onbit(x,k) ((1ll<<k)|x)
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);

const int maxn=1e5+5;

struct canh
{
    int u,v,w,vt;
};

canh a[maxn],b[2*maxn];

bool cmp1(canh a,canh b)
{
    return a.u<b.u;
}

bool cmp2(canh a,canh b)
{
    return a.v<b.v;
}

bool cmp3(canh a,canh b)
{
    return a.w<b.w;
}

int n,m=0,cha[maxn],dodai[maxn];
ll res=0;

void make_set(int v)
{
    cha[v]=v;
    dodai[v]=1;
}

int find_set(int v)
{
    if(v==cha[v])
        return v;
    else
        return cha[v]=find_set(cha[v]);
}

void union_set(int a,int b)
{
    if(dodai[a]<dodai[b])
        swap(a,b);
    dodai[a]+=dodai[b];
    cha[b]=a;
}

int main()
{
    fast_io

    cin>>n;

    ford(i,1,n)
    {
        cin>>a[i].u>>a[i].v;
        make_set(i);
        a[i].vt=i;
    }

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

    ford(i,2,n)
    {
        m++;
        b[m].u=a[i].vt;
        b[m].v=a[i-1].vt;
        b[m].w=a[i].u-a[i-1].u;
    }

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

    ford(i,2,n)
    {
        m++;
        b[m].u=a[i].vt;
        b[m].v=a[i-1].vt;
        b[m].w=a[i].v-a[i-1].v;
    }

    sort(b+1,b+m+1,cmp3);

    ford(i,1,m)
    {
        int p1=find_set(b[i].u);
        int p2=find_set(b[i].v);
        if(p1!=p2)
        {
            union_set(p1,p2);
            res+=b[i].w;
        }
    }

    cout<<res;

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	bool b;
	cin>>b;
	cout<<!b;
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int n, W; cin >> n >> W;
    vector<long long> dp(n*1000+1, 2e9);
    
    dp[0] = 0;
    for (int i=0; i<n; i++){
        int w,v; cin >> w >> v;
        for (int j=n*1000 - v; j>=0; j--){
            dp[j+v] = min(dp[j+v], dp[j] + w);
        }
    }
    int ans = 0;
    for (int i=0; i<n*1000+1; i++){
        if (dp[i] <= W) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <cstdio>
#define LIMIT 10000
using namespace std;
bool ck(vector<int>&v){
	for(int i=0;i<v.size();i++)if(v[i]!=i+1)return false;
	return true;
}
main(){
	int n,i,j,s,x,l;
	vector<int>tri;
	for(i=1;i<199;i++)tri.push_back(i*(i+1)/2);
	for(;scanf("%d",&n),n;){
		vector<int>v;
		for(s=i=0;i<n;i++){
			scanf("%d",&x);
			s+=x;
			v.push_back(x);
		}
		vector<int>::iterator idx=find(tri.begin(),tri.end(),s);
		i=LIMIT+1;
		if(idx!=tri.end()){
			for(i=0;i<=LIMIT&&!ck(v);i++){
				l=v.size();
				for(j=0;j<l;j++)v[j]--;
				v.erase(remove(v.begin(),v.end(),0),v.end());
				v.push_back(l);
			}
		}
		printf("%d\n",i>LIMIT?-1:i);
	}
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int x;
  cin >> x;
  if(x>=30)cout << "Yes" << endl;
  else  cout << "No" << endl;
}


Measured memory_bytes: 3632
using System;

namespace abc164_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = new string[n];
            for(int i = 0; i < n; ++i)
            {
                s[i] = Console.ReadLine();
            }
            StringComparer cmp = StringComparer.OrdinalIgnoreCase;
            Array.Sort(s, cmp);
            int num = n;
            for(int i = 0; i < n-1; ++i)
            {
                if (s[i] == s[i + 1])
                {
                    num--;
                }
            }
            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 38408
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 25

struct node{
  int key;
  node *p,*l,*r;
};

node *NIL,*root;

void insert(node * z){
  node * y=NIL;
  node * x=root;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }
  z->p=y;

  if(y==NIL){
    root=z;
  }else if(z->key < y->key){
    y->l=z;
  }else{
    y->r=z;
  }
}

void Preorder(node * x){
  if(x==NIL) return;
  cout<<" "<<x->key;
  Preorder(x->l);
  Preorder(x->r);
}

void Inorder(node * x){
  if(x==NIL) return;
  Inorder(x->l);
  cout<<" "<<x->key;
  Inorder(x->r);
}



int main(){
  int n,x;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="insert"){
      cin>>x;
      node * a=(node *)malloc(sizeof(node));
      a->key=x;
      a->l=a->r=NIL;
      insert(a);
    }else{
      Inorder(root);
      cout<<endl;
      Preorder(root);
      cout<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 26596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 100000007;
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2)%bg;	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll modinv(ll m)
{
	return power(m,bg-2)%bg;
}
ll sum(ll i)
{
	ll s = (i*(i+1))/2;
	return s;
}
int main()
{ 
	ll t;
	t = 1;
	while(t--)
	{
		string s;
		cin>>s;
		for(ll i =0 ;i<s.length();i++)
		   if(s[i]=='?')
		     s[i] = 'D';
		cout<<s;     
	}
	return 0;
}

Measured memory_bytes: 3756
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int N;
vector<LL> A;
LL a;

int bai4=0;
int bai2=0;
int odd=0;
int main(){
    
    cin>>N;
    REP(i,N){
     cin>>a;
     A.push_back(a);
     
     if(a%4==0){
         bai4++;
     }
     else if(a%2==0){
         bai2++;

     }
     else{
         odd++;
     }

    }


    if(bai4+1>=odd+(bai2!=0)){
        cout<<"Yes"<<endl;
    }
    else{
         cout<<"No"<<endl;
    }
    
    // if(N<=3){
    //     if(bai4!=0){
    //         cout<<"Yes"<<endl;
    //     }
    //     else{
    //         cout<<"No"<<endl;
    //     }
    // }
    // else{
    //     if(bai4+1>=odd+(bai2!=0)){
    //        cout<<"Yes"<<endl;
    //     }
    //     else{
    //         cout<<"No"<<endl;
    //     }
    // }







}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<=13&&n!=4&&n!=7&&n!=8&&n!=11&&n!=12){
		cout<<"No"<<endl;
	}
	else if(n==17){
		cout<<"No"<<endl;
	}
		
	else cout<<"Yes"<<endl;
}
//1 2 3 5 6 9 10 13
//4  7 8 11 12 17


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        c: [[i64; 3]; 3],
    };

    println!(
        "{}",
        if c[0][0] + c[1][1] == c[1][0] + c[0][1]
            && c[0][1] + c[1][2] == c[0][2] + c[1][1]
            && c[1][0] + c[2][1] == c[1][1] + c[2][0]
            && c[1][1] + c[2][2] == c[1][2] + c[2][1]
        {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2160
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int extGCD(long long int a, long long int b, long long int &x, long long int &y){
	long long int d = a;
	if(b == 0){
		x = 1;
		y = 0;
	}else{
		d = extGCD(b, a % b, y, x);
		y -= a / b * x;
	}
	return d;
}

int main(){
	long long int a, b, x, y, G;
	cin >> a >> b;
	G = extGCD(a, b, x, y);
	cout << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 3084
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = readints()
tmp = list(range(-200, 201))
# print(tmp)
for i in range(n):
    tmp.remove(p[i])
#print('tmp', tmp)
ans = [None]*500

for i in range(len(tmp)):
    ans[tmp[i]] = abs(tmp[i]-x)
# print(ans)
x = 10**5
for i in range(len(ans)):
    if ans[i] != None:
        x = min(x, ans[i])
# print(x)
print(ans.index(x))


Measured memory_bytes: 72940
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import defaultdict

def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
beki = [2**i for i in range(1, 31)]
D = defaultdict(list)


for i, a in enumerate(A):
    D[a].append(i)

answer = 0
matched = [0]*(N)

for t in range(31, 0, -1):
    S = 2 ** (t)
    R = bisect_left(A, S) - 1
    for i in range(R, 0, -1):
        if A[i] + A[i-1] < S:
            break
        if matched[i]:
            continue
        X = S - A[i]
        if len(D[X]) >= 1 + (X == A[i]):
            a = D[A[i]].pop()
            b = D[X].pop()
            assert a == i
            matched[a] = 1
            matched[b] = 1
            answer += 1
print(answer)


Measured memory_bytes: 126288
n = gets.to_i

z_arr = []
w_arr = []
n.times do
  x, y = gets.split(" ").map(&:to_i)
  z_arr << x + y
  w_arr << x - y
end

puts [z_arr.max - z_arr.min, w_arr.max - w_arr.min].max


Measured memory_bytes: 17560
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
char s[N], t[N];
ll dp[N][2];

int main(){
    ios;
    cin>>n;
    cin>>s+1;
    /*rep(i,1,n){
        dp[i][0]=min(dp[i-1][0],dp[i-1][1]) + (s[i]=='R');
        dp[i][1]=dp[i-1][1] + (s[i]=='W');
    }
    cout<<min(dp[n][0],dp[n][1]);*/
    rep(i,1,n){
        t[i]=s[i];
    }
    sort(t+1,t+1+n);
    int cnt=0;
    rep(i,1,n) if(s[i]!=t[i]) ++cnt;
    cout<<cnt/2;
    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int mas[1000][1000];
int x[2]={1,0},y[2]={0,1};
typedef pair<int,int>P;
int road(int,int);
int main(){
  int h,w,cnt,n,x,y;
  while(1){
    cin >> h >> w;
    if(h==0 && w==0){
      break;
    }
    cin >> n;

    memset(mas,0,sizeof(mas));
    
    for(int i=0;i<n;i++){
      cin >> y >> x;
      y--;
      x--;
      mas[y][x]=56;
    }
    
    mas[h-1][w-1]=100;
    cnt=road(h,w);

    cout << cnt << endl;
  }
}

int road(int h,int w){
  queue<P>que;
  int cnt=0;
  que.push(P(0,0));
  while(!que.empty()){
    P p=que.front();
    que.pop();
    //if(
    for(int i=0;i<2;i++){
      int H = p.first+x[i];
      int W = p.second+y[i];
      if(H>=0 && H<h && W>=0 && W<w && mas[H][W]==0){
	que.push(P(H,W));
      }
      if(mas[H][W]==100){
	cnt++;
      }
    }
  }
  return (cnt);
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int n;string s;cin>>n>>s;
	rep(i,s.size()){
		rep(j,n){
			if(s[i]=='Z')s[i]='A';
			else s[i]++;
		}
	}
	cout<<s<<endl;
}

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

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> ab, cd;
    for(int i = 0;i*a*100 <= f;i++){
        for(int j = 0;j*b*100+i*a*100 <= f;j++){
            ab.emplace_back(i*a*100+j*b*100);
        }
    }
    for(int i = 0;i*c < f;i++){
        for(int j = 0;j*d+i*c < f;j++){
            cd.emplace_back(i*c+j*d);
        }
    }
    sort(ab.begin(), ab.end());
    sort(cd.begin(), cd.end());
    int sugarwater = 0;
    int sugar = 0;
    double M = 0;
    for(int i = 0;ab[i] <= f;i++){
        int sugarmax = e*ab[i]/100;
        for(int j = 0;cd[j]+ab[i] <= f && cd[j] <= sugarmax;j++){
            double r = 100*cd[j];
            double s = ab[i]+cd[j];
            if(M < r/s){
                M = r/s;
                sugarwater = ab[i]+cd[j];
                sugar = cd[j];
            }
        }
    }
    if(M == 0){
        for(int i = 0;i < ab.size();i++){
            if(ab[i] <= f && ab[i] > 0){
                sugarwater = ab[i];
                break;
            }
        }
    }
    cout << sugarwater << " " << sugar << endl;
}

Measured memory_bytes: 1400
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        a_vec: [usize; n]
    }

    let mut set: HashSet<usize> = HashSet::new();

    let mut ans: isize = 0;
    let mut idx = 0;
    loop {
        let v = a_vec[idx]-1;
        if set.contains(&v) { ans = -1; break; }

        ans += 1;
        idx = v;
        set.insert(v);
        if v == 1 {
            break;
        }
    }
    
    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 5268
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;

using namespace std;

int main()
{
	double w,h,x,y;
	cin>>w>>h>>x>>y;

	cout<<fixed<<setprecision(10)<<(w*h/2)<<" "<<(x+x == w && y+y == h)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]        

def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
        
if __name__ == "__main__":
    main()



Measured memory_bytes: 31268
#include<iostream>
#include<cstdio>
#define MAIN 110
using namespace std;
int main()
{
    int n,data[MAIN];
    double sum=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&data[i]);
        sum+=data[i];
    }
    sum/=n;
    int num=sum-(int)sum>0.5?(int)sum+1:(int)sum,ans=0;
    for( int i=1; i<=n; i++)
        ans+=(data[i]-num)*(data[i]-num);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n;
	ll ans=0LL;
	cin >>n;
	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}
	ans+=n/10LL;
	n/=10LL;
	while(n/5LL !=0){
		ans+=n/5LL;
		n/=5LL;
	}
	cout<<ans<<endl;
}
/*
10
20
30
40
50 5
60
70
80
90
100 5
*/

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var cur = 0;
        for (int i = 1; i <= n; i++)
        {
            cur *= 10;
            cur += 7;
            cur %= n;
            if (cur == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 27472
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x, y; cin >> x >> y;
    map<int,int> mp;
    mp[1] = 300000;
    mp[2] = 200000;
    mp[3] = 100000;
    int ans = mp[x] + mp[y];
    if (x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.util.*;

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

        String s = sc.next();
        int c = 0;

        for (int i=0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                c++;
            }
        }
        System.out.print(c);
    }
}

Measured memory_bytes: 21972
#include<stdio.h>

int odd[100001];
int even[100001];
int n, odd1, odd2, even1, even2, i;
char c;

int max(int a, int b);
int nextInt();

int main(){
	n = nextInt();
	for(i=0; i<n; i+=2){
		odd[nextInt()]++;
		even[nextInt()]++;
	}
	for(i=0; i<100001; i++){
		if(odd[i] > odd[odd1]){
			odd2 = odd1;
			odd1 = i;
		}else if(odd[i] > odd[odd2]){
			odd2 = i;
		}
		if(even[i] > even[even1]){
			even2 = even1;
			even1 = i;
		}else if(even[i] > even[even2]){
			even2 = i;
		}
	}
	if(odd1 == even1){
		i = max(odd[odd1]+even[even2], odd[odd2]+even[even1]);
	}else{
		i = odd[odd1]+even[even1];
	}
	printf("%d", n-i);
	return 0;
}

int max(int a, int b){
	return (a<b?b:a);
}

int nextInt(){
	int f=0;
	c= getchar();
	while((c<'0')||('9'<c)){
		c=getchar();
	}
	while((c>='0')&&(c<='9')){
		f=f*10+(c-'0');
		c=getchar();
	}
	return f;
}


Measured memory_bytes: 896
q,h,s,d=map(int,input().split())
n=int(input())
if n==1:
  print(min(s,h*2,q*4))
elif n%2==0:
  print(min(int(n/2)*d,n*s,2*n*h,4*n*q))
else:
  print(min(int(n/2)*d+s,int(n/2)*d+2*h,int(n/2)*d+4*q,n*s,2*n*h,4*n*q))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define E esit(0)
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
const int N=1e5+5;
const int INF=1e9+7;

double dp[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    dp[0]=1;
    for (int cnt=1;cnt<=n;cnt++) {
        double p;
        cin>>p;
        for (int i=cnt;i>=0;i--) {
            dp[i]=dp[i-1]*p+dp[i]*(1.0-p);
        }
    }
    double ans;
    for (int i=0;i<=n;i++) {
        int j=n-i;
        if (i>j) {
            ans+=dp[i];
        }
    }
    cout<<fixed<<setprecision(20)<<ans;
    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  long long int a,b,n,c;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(a%2==0){
        c=a;
        a/=2;b+=c/2;
      }
      else{
        c=a;
        a=(c-1)/2;b+=(c-1)/2;
      }
    }
    else{
      if(b%2==0){
        c=b;
        b/=2;a+=c/2;
      }
      else{
        c=b;
        b=(c-1)/2;a+=(c-1)/2;
      }
    }
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
    int N, K; cin >> N >> K;
    vector<int> sunuke(N, 0);
    rep(i, 0, K) {
        int d; cin >> d;
        rep(j, 0, d) {
            int A; cin >> A;
            sunuke[A - 1]++;
        }
    }

    int ans = 0;
    rep(i, 0, N) {
        if (sunuke[i] == 0)ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const int error=1e9+7;
#define F first
#define S second
#define MK make_pair






int main(){
    int n;
    int mi=error;
    cin>>n;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        int count=0;
        while(b%2==0){
            b/=2;
            count++;
        }
        mi=min(mi,count);
    }
    cout<<mi<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

ans=0

for i in range(n):
    for j in range(i+1,n):
        dist_2=0
        for k in range(d):
            dist_2+=(x[i][k]-x[j][k])**2
        #print(dist_2)
        if math.sqrt(dist_2).is_integer():
            ans+=1
        #print(ans)    
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
int a,b,c,d,i,j,k;
char t;
int main(){
	scanf("%d %c %d",&a,&t,&b);
	if (t=='-'){
		printf("%d\n",a-b);
	}	
	if (t=='+'){
		printf("%d\n",a+b);
	}
}

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

int main(){
  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++)
    cin>>p.at(i);
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<N-1;i++)
    ans+=p.at(i);
  ans+=p.at(N-1)/2;
  cout<<ans;
}

Measured memory_bytes: 256
memo = [0]*20010
lidx = 1

def solve(m):
    global lidx,memo
    if m < lidx: return memo[m]
    for i in range(lidx,m+1):
        memo[i] = memo[i-1]
        n = i
        while n%5 == 0:
            n/=5
            memo[i] += 1
    lidx = m
    return memo[m]


while(True):
    n = int(input())
    if not n: break
    print(solve(n))



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

using namespace std;

struct point
{
	int p, index;
};

bool comp(point p1, point p2)
{
	return p1.p < p2.p;
}

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

	long long taka = 0, aoki = 0;

	vector<point> table(N);
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;

		table[i] = { a + b, i };
		A[i] = a; B[i] = b;
	}

	sort(table.begin(), table.end(), comp);
	reverse(table.begin(), table.end());

	for (int i = 0; i < N; i++)
	{
		int idx = table[i].index;

		if (i % 2 == 0)
		{
			taka += A[idx];
		}
		else
		{
			aoki += B[idx];
		}
	}

	cout << taka - aoki << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
import heapq
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
h = na()
for i in range(n):
    h[i] *= -1
heapq.heapify(h)
for i in range(min(len(h), k)):
    heapq.heappop(h)
print(-1 * sum(h))

Measured memory_bytes: 25872
#include <iostream>
#include <string>
#include <algorithm>

int main(){

	int i,n;
	int x=100000;

	std::cin >> n;
	
	for(i=0;i<n;i++){
		x*= 1.05;
		if(x%1000 != 0){
			x+= 1000 - x % 1000;
		}
	}

	std::cout << x << std::endl;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M, Q;
vector<string> field;

int a[2005][2005];
int b[2005][2005];
int c[2005][2005];

int main(){
  cin >> N >> M >> Q;
  rep(i,N){
    string str;
    cin >> str;
    field.push_back(str);
  }

  REP(x,1,N+1){
    REP(y,1,M+1){
      a[x][y] = (field[x-1][y-1]=='1'?1:0) + a[x-1][y] + a[x][y-1] - a[x-1][y-1];
      b[x][y] = (field[x-1][y-1]=='1'&&(x-2>=0&&field[x-2][y-1]=='1')?1:0) + b[x-1][y] + b[x][y-1] - b[x-1][y-1];
      c[x][y] = (field[x-1][y-1]=='1'&&(y-2>=0&&field[x-1][y-2]=='1')?1:0) + c[x-1][y] + c[x][y-1] - c[x-1][y-1];
    }
  }
  
  rep(i,Q){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int cnta = a[x2][y2] - a[x1-1][y2] - a[x2][y1-1] + a[x1-1][y1-1];
    int cntb = b[x2][y2] - b[x1][y2] - b[x2][y1-1] + b[x1][y1-1];
    int cntc = c[x2][y2] - c[x1-1][y2] - c[x2][y1] + c[x1-1][y1];

    //cout << cnta << " " << cntb << " " << cntc << endl;
    cout << cnta - cntb - cntc << endl;
  }
  
  return 0;
}



Measured memory_bytes: 52992
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return
    val subordinates = Array(n) { 0 }
    a.forEach {
        subordinates[it - 1]++
    }
    subordinates.forEach {
        println(it)
    }
}


Measured memory_bytes: 69724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String argv[]) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		int week = Integer.parseInt(br.readLine());
		double money = 100000;
		for (int i = 0; i < week; i++) {
			money = plusMoney(money);
		}
		System.out.printf("%.0f\n",money);
	}

	public static double plusMoney(double money) {
		money = money * 1.05;
		if (money % 1000 != 0) {
			money = money - money % 1000 + 1000;
		}
		return money;
	}

}

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

int N=pow(10,6);

vector<vector<int>> Eratosthenes(const int N){
    vector<bool> is_prime(N+1);
    for(int i=0; i<=N; i++){
        is_prime.at(i) = true;
    }
    vector<vector<int>> prime_list(N+1);
    //prime_list.at(1).push_back(1);
    for(int i=2; i<=N; i++){
        if(is_prime.at(i)){
            prime_list.at(i).push_back(i);
            for(int j=2*i; j<=N; j+=i){
                is_prime.at(j) = false;
                prime_list.at(j).push_back(i);
            }
        }
    }
    return prime_list;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    vector<vector<int>> prime_list;
    prime_list = Eratosthenes(N);
    /*
    for(int i=0; i<prime_list.size(); i++){
        for(int j=0; j<prime_list.at(i).size(); j++){
            cout << prime_list.at(i).at(j) << " ";
        }
        cout << endl;
    }
    */
    map<int, int> m;
    bool pair_prime=true;
    set<int> s;
    for(int i=0; i<n; i++){
        int k=a.at(i);
        for(int j=0; j<prime_list.at(k).size(); j++){
            int p=prime_list.at(k).at(j);
            if(s.count(p)) pair_prime=false;
            s.insert(p);
            m[p]++;
        }
    }
    if(pair_prime){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    for(auto p:m){
        //cout << p.first << " " << p.second << endl; 
        if(p.second == n){
            cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "setwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 69952
import java.util.Scanner;

public class Main {
	
	   

		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
//	        int x = sc.nextInt();
//	        int y = sc.nextInt();
//	        int z = sc.nextInt();
	        int[] all = new int[3];
	        for(int i = 0 ; i<3; i++) {
	        	all[i] = sc.nextInt();
	        }
	        System.out.println(all[2]+" "+all[0]+" "+all[1]);
	        
	        
	        
	        
	        
	        
	       // System.out.println(result); 
	        
            

          
	        
            //System.out.println(res); 
	        
	}
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int t;
long long a, b, c, d;

long long gcd(long long a, long long b){
	if(b == 0LL){
		return a;
	}else{
		return gcd(b, a % b);
	}
}

void solve(){
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	if(b > d || b > a){
		printf("No\n");
		return;
	}
	// now b <= d
	if(c >= b - 1){
		printf("Yes\n");
		return;
	}
	// now c + 1 < b <= d
	// if it is possible to reach a number in [c + 1, b - 1],
	// then gg
	
	// first simulate up to first restock
	a -= (a / b) * b;
	
	// can assume restock is adding < 2b cans
	// indeed, can assume restock + consume is going from a to (a + d) % b
	// if any time this is >= c + 1, you lose
	long long g = gcd(d, b);
	// Largest x s.t. a + gx <= b - 1
	long long x = (b - 1 - a) / g;
	if(a + g * x >= c + 1){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}

int main(){
	scanf("%d", &t);
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.Int

solve :: [Int64] -> Int64
solve [] = 0
solve [x] = x `div` 2
solve (x:y:xs) | y == 0 = a + solve xs
               | otherwise = b + solve ((y-p):xs)
    where p = x `mod` 2
          a = x `div` 2
          b = (x+p) `div` 2

main :: IO ()
main = do
    n <- read <$> getLine
    as <- mapM (\_ -> (read :: String -> Int64) <$> getLine) [1..n]
    putStrLn . show $ solve as


Measured memory_bytes: 63740
X=int(input())
value = [100,101,102,103,104,105]
m = 1000000
if X < 100:
    print(0)
else:
    dp = [-1]*100001
    dp[0] = 0
    for i in value:
        for j in range(X+1):
            if dp[j] >= 0:
                dp[j] = m
            elif j < i or dp[j - i] <=0:
                dp[j] = -1
            else:
                dp[j] = dp[j -i] -1
    if dp[X] >=0:
        print(1)
    else:
        print(0)

Measured memory_bytes: 6772
#include <iostream>

using namespace std;

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

    int min_diff = 1000;
    for (int i = 0; i < line.size() - 2; i++)
    {
        const int number = 100 * (line[i] - '0') + 10 * (line[i + 1] - '0') + (line[i + 2] - '0');
        min_diff = min(min_diff, abs(753 - number));
    }
    cout << min_diff << endl;
}

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

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int R;

int main() {
  cin >> R;

  if(R < 1200) {
    cout << "ABC" << endl;
  } else if(R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    string s;
    cin >> s;

    if (s == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1 << endl;
    }
    else if (s.length() < 26)
    {
        for (int i = 0; i < 26; ++i)
        {
            char c = 'a' + i;
            if (s.find(c) == s.npos)
            {
                s += c;
                break;
            }
        }

        cout << s << endl;
    }
    else
    {
        vector<bool> used(26);

        for (int i = 25; i >= 0; --i)
        {
            int u = s[i] - 'a';

            for (int j = u + 1; j < 26; ++j)
            {
                if (used[j])
                {
                    string ans = "";
                    for (int k = 0; k < i; ++k)
                        ans += s[k];
                    ans += (char)('a' + j);
                    cout << ans << endl;
                    return 0;
                }
            }

            used[u] = true;
        }
    }

    return 0;
}

// abcdefghijklmnopqrstuvwzyx
// abcdefghijklmnopqrstuvx

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = 500*i + 100*j + 50*k
            if sum == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
a=input()
a0=a.split()
h1=int(a0[0])
m1=int(a0[1])
h2=int(a0[2])
m2=int(a0[3])
k=int(a0[4])
t1=60*h1+m1
t2=60*h2+m2
t=t2-t1
print(t-k)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


bool f(int m,bool a[][100],int n){

  bool b[100]={};
  queue<P> q;

  rep(i,n){
    if(a[i][m]){
      b[i]=true;
      q.push(P(i,m));
    }
  }

  while(!q.empty()){
    P p = q.front(); q.pop();
    if(!p.second) continue;

    if(a[p.first][p.second]){
      rep(i,n){
        if(a[i][p.second]&&!b[i]){
          b[i]=true;
          q.push(P(i,p.second-1));
        }
      }
    }
    q.push(P(p.first,p.second-1));
  }

  rep(i,n){
    if(!b[i]){
      return false;
    }
  }

  return true;
}


void search(int n){
  bool a[100][100]={};

  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int m;
      cin>>m;
      a[i][m]=true;
    }
  }

  rep(i,31){
    if(f(i,a,n)){
      cout<<i<<endl;
      return;
    }
  }

  cout<<-1<<endl;

}



int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;

    search(n);
  }


  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string order;
  int fee;
  cin >> order;
  if (order == "ooo") {
    fee = 1000;
  } else if(order == "xxx") {
    fee = 700;
  } else if(order == "xxo" || order == "xox" || order == "oxx") {
    fee = 800;
  } else {
    fee = 900;
  }
  cout << fee << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
    int i, l, n, x, w, sum=0, s=0, aw[50000], ai[50000], p=0;
    scanf("%d", &l);
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d %d", &x, &w);
        sum+=x*w;
    }
    if(sum>0)s=-1;
    else if(sum<0)s=1;
    sum=abs(sum);
    for(i=l; i>0; i--)if(sum/i>0){
        aw[p]=sum/i;
        ai[p++]=i*s;
        sum%=i;
        if(sum==0)break;
    }
    printf("%d\n", p);
    for(i=0; i<p; i++)printf("%d %d\n", ai[i], aw[i]);
    return 0;
}

Measured memory_bytes: 612
li = [int(x) for x in input().split()]
cost = 10**9
for i in range(3):
  for j in range(3):
    for k in range(3):
      if(i==j or j==k or i==k):continue
      cost = min(cost,abs(li[i]-li[j])+abs(li[j]-li[k]))
print(cost)

Measured memory_bytes: 3060