akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % int(powl(10,9) + 7);
    }

    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;

    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    int a,z;
    for(int i = 0;i < s.size(); ++i){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    for(int i = s.size() - 1; i >= 0; --i){
        if(s[i] == 'Z'){
            z = i;
            break;
        }
    }

    cout << z-a+1 << endl;
    return 0;
}

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

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

  int n=N;
  int X=0;
  while(n>0){
    X+=(n%10);
    n/=10;
  }

  if( N%X==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

def check(p):
    i = 0
    for _ in range(k):
        wight = 0
        while wight+w[i] <= p:
            wight += w[i]
            i += 1
            if i == n:
                return n
    return i

if __name__ == '__main__':
    left = 0
    right = 100000 * 10000
    mid = 0
    while right - left > 1:
        mid = (left+right)//2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    print(right)



Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<vector<int> > Matrix;
Matrix d; 
const int INF = 100000000;


void warshall_floyd(int n) { // ワーシャルフロイド nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
int main(){
  int n,m,hon;
  std::cin >> n>>m>>hon;
  std::vector<int> r(hon);
  d = Matrix(n, vector<int>(n, INF));
  rep(i,hon)std::cin >> r[i];
  sort(all(r));
  rep(i,n)d[i][i]=0;
  rep(i,m){
    int a,b,c;
    std::cin >> a>>b>>c;
    d[a-1][b-1]=c;
    d[b-1][a-1]=c;
  }

  warshall_floyd(n);
  int mi;
  mi=INF;
  do{
    int le=0;
    rep(i,hon-1)le+=d[r[i]-1][r[i+1]-1];
    if(le<mi)mi=le;
  }while(next_permutation(all(r)));
  std::cout << mi << std::endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

MOD = 10 ** 9 + 7

def main():
  S = input()
  dp = [[0 for _ in range(13)] for _a in range(len(S)+1)]

  coef = 1
  dp[0][0] = 1
  for i in range(len(S)):
    c = S[len(S) - 1 - i]
    if c == '?':
      for n in range(10):
        m = (coef * n) % 13
        for k in range(13):
          dp[i+1][(m + k) % 13] += dp[i][k]
          dp[i+1][(m + k) % 13] %= MOD
    else:
      n = int(c)
      m = (coef * n) % 13
      for k in range(13):
        dp[i+1][(m + k) % 13] += dp[i][k]
        dp[i+1][(m + k) % 13] %= MOD
    coef = (coef * 10) % 13
  print(dp[len(S)][5])

if __name__ == "__main__":
  main()


Measured memory_bytes: 66012
N, K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
V = {'r':P, 's':R, 'p':S}
ans = 0
 
 
for i in range(K):
    check = T[i]
    ans += V[check]
    while True:
        i += K
        if i >= N:
            break
        if check == T[i]:
            check = '-1'
        else:
            ans += V[T[i]]
            check = T[i]
print(ans)


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            int n = ReadAndParseInt();
            var s = new string[n];
            for (int i = 0; i < n; ++i)
            {
                s[i] = Console.ReadLine();
                
            }
            var list = new List<string>(s);
            list.Sort();

            int[,] table = new int[n, 26];
            for (int i = 0; i < n; ++i)
            {
                string sz = s[i];
                for (int j = 0; j < sz.Length; ++j)

                {
                    char c = sz[j];
                    int idx = c - 'a';
                    table[i, idx]++;
                }
            }

            int[] doc = new int[26];
            for(int j=0;j<doc.Length;++j)
            {
                int cnt = table[0, j];
                if( cnt == 0) { continue; }
                for(int i=1;i<n;++i)
                {
                    cnt = Math.Min(cnt, table[i, j]);
                }
                doc[j] = cnt;
            }
            var sb = new StringBuilder();
            for(int i=0;i<doc.Length;++i)
            {
                char c = (char)(i + 'a');
                int repeat = doc[i];
                for(int j=0;j<repeat;++j)
                {
                    sb.Append(c);
                }
            }
            Console.WriteLine(sb.ToString());
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ll arr[N],n,m,v,p;

bool ok(int x) {
    if(x < p) return true;
    if(arr[x] + m < arr[p-1]) return false;
    ll tot = (p - 1) * m; // first p - 1 elements.
    tot += (n - 1 - x) * m; // elements less than arr[x].
    tot += m; // own vote for arr[x]
    // from p to x - 1.
    FOR(i, p - 1, x) {
        tot += max(0LL, min(m, arr[x] + m - arr[i]));
    }
    return tot >= m * v;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();
    cin>>n>>m>>v>>p;
    FOR(i, 0, n) {
        cin>>arr[i];
    }
    sort(arr, arr + n); reverse(arr, arr + n);
    int lo = 0, hi = n - 1, res = p;
    while(lo <= hi) {
        int mid = (lo + hi)>>1;
        if(ok(mid)) {
            res = max(res, mid + 1);
            lo = mid + 1;
        } else hi = mid - 1;
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

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

int main() {

  long long int n;
  cin >> n;

  long long int ans = 1145141919LL;


  long long int pay9[5];
  long long int mo[5];

  for ( pay9[0] = 0; pay9[0] < 9; pay9[0]++ ) {
    mo[0] = n - 59049 * pay9[0];
    if ( mo[0] < 0 ) break;

    for ( pay9[1] = 0; pay9[1] < 9; pay9[1]++ ) {
      mo[1] = mo[0] - 6561 * pay9[1];
      if ( mo[1] < 0 ) break;

      for ( pay9[2] = 0; pay9[2] < 9; pay9[2]++ ) {
	mo[2] = mo[1] - 729 * pay9[2];
	if ( mo[2] < 0 ) break;

	for ( pay9[3] = 0; pay9[3] < 9; pay9[3]++ ) {
	  mo[3] = mo[2] - 81 * pay9[3];
	  if ( mo[3] < 0 ) break;

	  for ( pay9[4] = 0; pay9[4] < 9; pay9[4]++ ) {
	    mo[4] = mo[3] - 9 * pay9[4];
	    if ( mo[4] < 0 ) break;

	    long long int cnt = pay9[0] + pay9[1] + pay9[2] + pay9[3] + pay9[4];

	    cnt += mo[4] / 46656;
	    mo[4] %= 46656;
	    cnt += mo[4] / 7776;
	    mo[4] %= 7776;
	    cnt += mo[4] / 1296;
	    mo[4] %= 1296;
	    cnt += mo[4] / 216;
	    mo[4] %= 216;
	    cnt += mo[4] / 36;
	    mo[4] %= 36;
	    cnt += mo[4] / 6;
	    mo[4] %= 6;
	    cnt += mo[4] / 1;

	    ans = min( ans, cnt );

	  }
	}
      }
    }
  }


  cout << ans << endl;

}


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int k;
    cin >> k;
    queue<ll> q;
    repr(i, 1, 10) q.push(i);
    int cnt = 9;
    if (k <= cnt){
        cout << k << endl;
        return 0;
    }
    while(true){
        ll x = q.front();
        q.pop();
        ll m = x % 10;
        ll ans;
        if (m != 0){
            cnt++;
            ans = x*10 + (m-1);
            if (cnt == k){
                cout << ans << endl;
                return 0;
            }
            q.push(ans);
            
        }
        cnt++;
        ans = x*10 + m;
        if (cnt == k){
            cout << ans << endl;
            return 0;
        }
        q.push(ans);

        if (m != 9){
            cnt++;
            ans = x*10 + (m+1);
            if (cnt == k){
                cout << ans << endl;
                return 0;
            }
            q.push(ans);
        }
    }

}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<climits>
#include<map>
// #include<algorithm>
// #include<string>
// #include<stack>
#include<queue>
#include <fstream>
using namespace std;

int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    // vector<int> A(n);
    vector<int> B(n-1);
    for(int i=0;i<n-1;i++){
        cin>>B[i];
        // cout<<"B[i] "<<B[i]<<" ";
    }
    // cout<<endl;
    int ans = B[0];
    // A[0] = B[0];
    if(n>1)
        ans+=B[n-2];
    // cout<<ans<<endl;
    for(int i=1;i<=n-2;i++){
        ans += min(B[i-1], B[i]);
        // cout<<min(B[i-1], B[i-2])<<endl;
        // cout<<B[i-1]<<" "<<B[i-2]<<endl;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
n=int(input())
nstr=bin(n)[2:]
thrpow=[1]
now=1
for k in range(len(nstr)):
    now=(now*3)%(10**9+7)
    thrpow.append(now)
f=dict()
g=dict()
if nstr[-1]=='0':f[1]=1
elif nstr[-1]=='1':f[1]=2
g[1]=3
for k in range(2,len(nstr)+1):
    if nstr[-k]=='0':
        f[k]=(f[k-1])%(10**9+7)
        g[k]=(thrpow[k-1]+f[k-1]+g[k-1])%(10**9+7)
    if nstr[-k]=='1':
        f[k]=(f[k-1]+g[k-1])%(10**9+7)
        g[k]=(2*thrpow[k-1]+g[k-1])%(10**9+7)
print(f[len(nstr)])

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int n, m;
vector<ll> a;

bool can(ll x) {
	ll cur = 1;
	rep(i, m-2) {
		int id = lower_bound(a.begin(), a.end(), cur) - a.begin();
		ll add = 0;
		if (id != n) {
			add= max((ll)1, x-(a[id] - cur));
		}
		if (id != 0) {
			add = max(add, max((ll)1, x-(cur - a[id - 1])));
		}
		cur += add;
	}
	//cout << cur << endl;
	return cur + x <= a[n - 1];
}
void solve() {
	while (cin >> n >> m, n) {
		a.clear();
		a.resize(n);
		rep(i, n) {
			cin >> a[i];
		}
		int le = -1, ri = 2000000;
		while (ri - le > 1) {
			int mid = (ri + le) / 2;
			if (can(mid))le = mid;
			else ri = mid;
		}
		if (1 + le <= a[0])le = -1;
		cout << le << endl;
		//cout << can(le+1)<<" hello?" << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 3984
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        //Scanner sc = new Scanner("10\r\n10\r\n5\r\n9\r\n8\r\n10\r\n4\r\n7\r\n4\r\n5\r\n7");
        
        // もちの数
        int mochiNum = sc.nextInt();
        
        // 直系の重複をしないもちリストの初期化
        List<Integer> mochiList = new ArrayList<>();
        
        while(sc.hasNext()) {
            int diameter = sc.nextInt();
            
            // リストに同一直径のもちが存在しなければリストに追加する
            if(!mochiList.contains(diameter)) {
                mochiList.add(diameter);
            }
            
        }
        
        // もちリストの数が最大の段数
        System.out.println(mochiList.size());
    }
}


Measured memory_bytes: 21588
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			int n = scanner.nextInt();
			
			int s = n*(n+1)/2 + 1;
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 26072
import java.util.*;
import java.util.Map.Entry;



public class Main{
	
	public int num;
	public int vol;

	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int H=sc.nextInt(),W=sc.nextInt();
	 char[][] s=new char[H][W];
	 for(int i=0;i<H;i++) {
		 String tmp=sc.next();
		 s[i]=tmp.toCharArray();
		 
	 }
	 
	 boolean flag=false;
	 for(int i=0;i<H;i++) {
		 for(int j=0;j<W;j++) {
			 if(s[i][j]=='#') {
				flag=false;
				 if(j+1<=W-1) {
					 if(s[i][j+1]=='#') {
						 flag=true;
					 }
				 }
				 if(j-1>=0) {
					 if(s[i][j-1]=='#') {
						 flag=true;
					 }
				 }
				 if(i+1<=H-1) {
					 if(s[i+1][j]=='#') {
						 flag=true;
					 }
				 }
				 if(i-1>=0) {
					 if(s[i-1][j]=='#') {
						 flag=true;
					 }
				 }
				 if(!flag) {
					 System.out.println("No");
					 return;
				 }
			 }
		 }
		 
	 }
	
		 System.out.println("Yes");
	
	 
 }
	


}



Measured memory_bytes: 23892
h, w = map(int, input().split())
s = []
score = [[0] * w for i in range(h)]
for i in range(h):
  s.append(list(input()))
  for j in range(w):
    if i == 0:
      if j == 0:
        score[0][0] = 1 if s[0][0] == '#' else 0
      else:
        score[0][j] = score[0][j-1]
        if s[0][j] == '#' and s[0][j-1] != '#':
          score[0][j] += 1
    else:
      if j == 0:
        score[i][0] = score[i-1][0]
        if s[i][0] == '#' and s[i-1][0] != '#':
          score[i][0] += 1
      else:
        r = score[i][j-1]
        if s[i][j] == '#' and s[i][j-1] != '#':
          r += 1
        d = score[i-1][j]
        if s[i][j] == '#' and s[i-1][j] != '#':
          d += 1
        score[i][j] += min(r, d)
print(score[-1][-1])

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

public class Main { //REMEMBER TO USE MAIN//
	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader( new InputStreamReader(System.in));//
		String line;
		while((line=in.readLine())!=null){//
			String s;
			s = line.toUpperCase();
			System.out.println(s);
			////Some code
		}//while#1
	}//static main
}//class

Measured memory_bytes: 24152
n, p = map(int, input().split())

if n == 1:
    print(p)
    exit()
ans = 1
for i in range(2, int(p ** (1 / n) + 1)):
    cnt = 0
    while p % i == 0:
        cnt += 1
        p //= i
    if cnt != 0:
        ans *= i ** (cnt // n)

print(ans)

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

string s;

ll calc(string command){
    string n;
    ll sum = 0;
    while(command.size()){
        if(command[0] == '+'){
            sum += stoll(n);
            n = "";
        } else {
            n += command[0];
        }
        command.erase(0, 1);
    }
    sum += stoll(n);
    return sum;
}

ll dfs(string command, int cnt){
    if(cnt == s.size() - 1) return calc(command);

    cnt++;
    return dfs(command + s[cnt], cnt) + dfs(command + '+' + s[cnt], cnt);
}

int main(){
    cin >> s;
    string command = "";
    command += s[0];
    cout << dfs(command, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 105


void warshal_floyd(vector<vector<int> >& dp){
    REP(k,ARRAY_MAX){
        REP(i,ARRAY_MAX){
            REP(j,ARRAY_MAX){
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }
}


int main(){

    int n,m;
    while(cin >> n >> m,n){

        int a,b,c,t;
        vector<vector<int> > mini_cost(ARRAY_MAX,vector<int>(ARRAY_MAX));
        vector<vector<int> > mini_time(ARRAY_MAX,vector<int>(ARRAY_MAX));

        REP(i,ARRAY_MAX){
            REP(j,ARRAY_MAX){
                mini_cost[i][j] = mini_time[i][j] = INF;
                if(i == j){
                    mini_cost[i][j] = mini_time[i][j] = 0;
                }
            }
        }


        REP(i,n){
            cin >> a >> b >> c >> t;
            a--;
            b--;
            mini_cost[a][b] = mini_cost[b][a] = c;
            mini_time[a][b] = mini_time[b][a] = t;
        }

        warshal_floyd(mini_time);//最小コスト
        warshal_floyd(mini_cost);//最小時間

        int k;
        cin >> k;
        REP(i,k){
            int p,q,r;
            cin >> p >> q >> r;
            p--;
            q--;
            if(r == 0){
                //最小コスト
                cout << mini_cost[p][q] << endl;
            }else{
                cout << mini_time[p][q] << endl;
            }
        }
        mini_cost.shrink_to_fit();
        mini_time.shrink_to_fit();
    }


    return 0;
}



Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

	final static int MAX = 24 * 60 * 60;

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

		while (true) {
			final int n = sc.nextInt();

			if(n == 0){
				break;
			}
			
			final int m = sc.nextInt();
			
			int[] prices = new int[n];
			char[][] inputs = new char[n][];
			
			for(int i = 0; i < n; i++){
				inputs[i] = sc.next().toCharArray();
				prices[i] = sc.nextInt();
			}
			
			int sum = 0;
			for(int i = 0; i < m; i++){
				char[] str = sc.next().toCharArray();
				
				for(int j = 0; j < n; j++){
					boolean found = true;
					
					for(int k = 0; k < inputs[j].length; k++){
						if(inputs[j][k] == '*'){
							continue;
						}else if(inputs[j][k] != str[k]){
							found = false;
							break;
						}
					}
					
					if(found){
						sum += prices[j];
						break;
					}
				}	
			}
			
			System.out.println(sum);
			
		}

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

vector<int> es[(int)2e5];

int n,m;

bool dfs(int v,int cnt){
	if(cnt > 2) return false;
	if(v == n-1) return true;
	
	for(int i=0;i<es[v].size();i++){
		if(dfs(es[v][i],cnt+1)) return true;
	}
	return false;
}

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

	cin >> n >> m;
	
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
	}

	cout << (dfs(0,0)?"":"IM") << "POSSIBLE\n";

	return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll n;
  cin>>n;

  vector<ll> a(n, 0);
  vector<bool> valid(1000005, false);
  map<ll, ll> cnt;
  ll top = 0;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    cnt[a[i]]++;
    valid[a[i]] = true;
    top = max(top, a[i]);
  }
  sort(a.begin(), a.end());

  for (auto k : a) {
    for (int i=2; i<=1000000; i++) {
      if (i * k <= top) 
        valid[i*k] = false;
      else
        break;
    }

    if (cnt[k] > 1)
      valid[k] = false;
  }

  ll ans = 0;
  for (auto k : a)
    if (valid[k])
      ans++;
  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 17392
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
map<int,int> num;
int ans;
set<int> a[100005];

void f(int s) {
    int sum = 0;
    for(auto itr = a[s].begin(); itr != a[s].end(); ++itr) {
      sum += num[*itr];
    }
    ans += sum / 2;
}

int main() {
  int n,m;
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x % m].insert(x);
    num[x]++;
  }

  int l = 1;
  int r = m-1;

  while(l < r) {
    //   cout << l <<"  "<<r<<endl;
    int lsum = 0;
    int X = 0;
    int Y;
    for(auto itr = a[l].begin(); itr != a[l].end(); ++itr) {
      lsum += num[*itr];
      X += num[*itr] / 2;
    }
    Y = lsum - 2 * X;
    int rsum = 0;
    int XX = 0;
    int YY;
    for(auto itr = a[r].begin(); itr != a[r].end(); ++itr) {
      rsum += num[*itr];
      XX += num[*itr] / 2;
    }
    YY = rsum - 2 * XX;
    //  cout << lsum <<"  "<<rsum << endl;
    if(rsum < lsum) {
      int L = 0;
      int R = X;
      while(R - L > 1) {
	int mid = (L + R) / 2;
	if(2*mid >= rsum - Y) R = mid;
	else L = mid;
      }
      ans += rsum;
      if(rsum - Y <= 0) ans += X;
      else ans += X - R;
    }
    else {
      //  cout << XX << "  ji"<<YY << endl;
      int L = 0;
      int R = XX;
      while(R - L > 1) {
	int mid = (L + R) / 2;
	if(2*mid >= lsum - YY) R = mid;
	else L = mid;
      }
      ans += lsum;
      if(lsum - YY <= 0) ans += XX;
      else ans += XX - R;
    }
    l++;
    r--;
    // cout << "ans = "<<ans << endl;
  }
  if(l == r) {
    f(m/2);
  }
  f(0);

  cout << ans << endl;
      
}
    


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

using namespace std;

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

  set<int> st;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (st.find(a) == st.end()) st.insert(a);
    else st.erase(a);
  }

  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 4864
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
      	double in = 0;
      
      for(int i=0;i<N;i++){
        in+=sc.nextDouble()*(sc.next().equals("JPY")?1:380000.0);
      }
 		System.out.print(in);
    }
}

Measured memory_bytes: 23252
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <array>
#include <vector>

using namespace std;

int func(vector<int> ar, int b) {
    
    int kanasi = 0;
    for (int i = 0; i < ar.size(); i++) {
        kanasi += abs(ar[i] - (b+i+1));
    }
    return kanasi;
}


int main() {

    int r;
    cin >> r;
    
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import numpy as np
n,m,c= [int(_) for _ in input().split()]
B = np.array([int(_) for _ in input().split()])
ans = 0
for i in range(n):
    A = np.array([int(_) for _ in input().split()])
    ans += (A*B).sum() + c >0

print(ans)

Measured memory_bytes: 12428
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    int k,a,b,flag=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}






Measured memory_bytes: 3612
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], m = tmp[1];

    long[] factors;
    for (long i = 1; i * i <= m; ++i)
    {
        if (m % i == 0)
        {
            factors ~= i;
            if (i * i != m) factors ~= m / i;
        }
    }

    factors.sort!"a > b";
    long result;
    foreach (x; factors)
    {
        if (x * n > m) continue;
        if ((m - x * n) % x == 0)
        {
            result = x;
            break;
        }
    }

    result.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

signed main(void)
{
	int n, a, b;
	int A, B, C, ans;

	cin >> n >> a >> b;
	A = B = C = 0;
	rep(i, n)
	{
		int x;
		cin >> x;
		if (x <= a)
			A++;
		else if (x <= b)
			B++;
		else
			C++;
	}
	ans = min(A, min(B, C));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000];
int main()
{
    string g;
    int n,l,i,k=0;
    cin>>g;
    l=g.length();
    for(i=0;i<l;i++)
    {
        n=g[i]-'0';
        a[n]++;
    }
    for(i=0;i<150;i++)
    {
        //cout<<a[i]<<endl;
        if(a[i]%2!=0)
        {
            k=5;
            cout<<"No"<<endl;
            break;
        }
        if(k==5)
            break;
    }
    if(k==0)
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
const int N=2e5+10;
const int N4=N<<2;
int a[N4];
void init(int n,int l,int r){
    if(l==r)a[n]=l;
    else{
        int mid=(l+r)>>1;
        init(n*2+1,l,mid);
        init(n*2+2,mid+1,r);
        a[n]=0;
    }
    return ;
}
int find(int n,int l,int r,int x){
    if(l==r)return a[n];
    else{
        int mid=(l+r)>>1;
        if(mid>=x)return a[n]+find(n*2+1,l,mid,x);
        else return a[n]+find(n*2+2,mid+1,r,x);
    }
}
void fix(int n,int l,int r,int R){
    if(r<=R)a[n]++;
    else if(!(l>R)){
        int mid=(l+r)>>1;
        fix(n*2+1,l,mid,R);
        fix(n*2+2,mid+1,r,R);
    }
    return ;
}
int main(){
    string s,ans;
    int k,p=0,now,n,temp;
    bool used[N];
    queue<int> v[30];
    cin>>s>>k;
    n=(int)s.size()-1;
    init(0,0,n);
    for(int i=0;i<s.size();i++){
        used[i]=false;
        v[s[i]-'a'].push(i);
    }
    for(int i=0;i<s.size();i++){
        while(used[p])p++;
        now=s[p]-'a';
        for(int j=0;j<now;j++)if(!v[j].empty()){
            temp=find(0,0,n,v[j].front());
            if(temp-i<=k){
                now=j;
                k-=temp-i;
                used[v[j].front()]=true;
                fix(0,0,n,v[j].front());
                break;
            }
        }
        if(now==s[p]-'a')used[p]=true;
        v[now].pop();
        ans+=now+'a';
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 6516
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  getLine
  (a:b:cs) <- getIntList
  print $ solve a b cs

solve :: Int -> Int -> [Int] -> Int
solve a b cs
  | odd (s - x) || s < x || d .&. x /= 0 || d > a = -1
  | z == 0 = -1
  | otherwise = a - z
  where
    s = a + b
    x = foldr xor 0 cs
    d = (s - x) `div` 2
    xBound = finiteBitSize x - countLeadingZeros x - 1
    xBits = filter (/= 0) $ map ((x .&.) . bit) [0..xBound]
    z = foldr step d xBits
    step x d
      | x `xor` d <= a = x `xor` d
      | otherwise = d

-- Input

getInt :: IO Int
getInt = readLn

second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

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

using namespace std;

int powerOf[1000000];

vector<int> base;

int main ()
{
    //Para cada par (i, j)
    //(x, y) é o par que representa N
    //Resultado = x + y - 2
    //Logo, encontrar o menor produto x * y = n
    long long n; cin >> n;
    long long r = n+2;
    for (long long i = 1; i * i <= n; i++)
    {
        if (n%i == 0)
        {
            r = min(r, n/i + i - 2);
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 384
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def judge(bw, lr):
    if bw[0] != "B" or bw[-1] != "B":
        return False

    elif lr.count("L") != lr.count("R"):
        return False

    else:
        return True


def fact(num, mod):
    if num == 1:
        return 1
    else:
        return num * fact(num-1, mod) % mod

n = ni()
bw = lc()
MOD = 10**9 + 7

# 各マスの左端or右端を判定
lr = ['L']
for i in range(2*n-1):
    if bw[i+1] == bw[i]:
        if lr[-1] == "L":
            lr.append("R")
        else:
            lr.append("L")

    else:
        if lr[-1] == "L":
            lr.append("L")
        else:
            lr.append("R")

# 答えが存在するか判定
if judge(bw, lr):
    cnt = 0
    ans = 1
    for lri in lr:
        if lri == "L":
            cnt += 1
        else:
            ans *= cnt
            ans %= MOD
            cnt -= 1

    print(ans * fact(n, MOD) % MOD)
else:
    print(0)

Measured memory_bytes: 92220
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  int data[10];
  data[0] = abs(a-b);
  data[1] = abs(a-c);
  data[2] = abs(a-d);
  data[3] = abs(a-e);
  data[4] = abs(b-c);
  data[5] = abs(b-d);
  data[6] = abs(b-e);
  data[7] = abs(c-d);
  data[8] = abs(c-e);
  data[9] = abs(d-e);
  for(int i = 0; i < 10; i++ ){
    if(data[i] > k){
      cout << ":(" << endl;
      return 0;
    }
  }
  cout << "Yay!" << endl;
  

  return 0;
}


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

#define ll long long
#define ar array

using namespace std;
int main(){
	int a;
	cin>>a;
	cout<<(a+(a*a)+(a*a*a))<<endl;
}
void readArray(int Array[],int N){
	for(int i=0;i<N;i++){
		cin>>Array[i];
	}
}

void printArray(int Array[],int N){
	for(int i=0;i<N;i++){
		cout<<Array[i] << " ";
	}
	cout<<endl;
}
void readVector(vector<int>&v){
	for(int &e : v){
		cin>>e;
	}	
}
void swap(int* a, int* b) 
{ 
    int t = *a; 
    *a = *b; 
    *b = t; 
} 
int partition (int arr[], int low, int high) 
{ 
    int pivot = arr[high];    // pivot 
    int i = (low - 1);  // Index of smaller element 
  
    for (int j = low; j <= high- 1; j++) 
    { 
        // If current element is smaller TEMPthan or 
        // equal to pivot 
        if (arr[j] <= pivot) 
        { 
            i++;    // increment index of smaller element 
            swap(&arr[i], &arr[j]); 
        } 
    } 
    swap(&arr[i + 1], &arr[high]); 
    return (i + 1); 
} 
void Sort(int arr[], int low, int high) 
{
   //quicksort using divide and conquer	
    if (low < high) 
    { 
        /* pi is partitioning index, arr[p] is now 
           at right place */
        int pi = partition(arr, low, high); 
  
        // Separately sort elements before 
        // partition and after partition 
        Sort(arr, low, pi - 1); 
        Sort(arr, pi + 1, high); 
    } 
}

void printVector(vector<int>&v){
	for(int &e : v){
		cout<<e<<" ";
	}
}



Measured memory_bytes: 3568
#include<stdio.h>
int main( ){
  int H,W;
  while( 1 ){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for( int i = 0 ; i < H ; i++ ){
      for( int j = 0; j < W ; j++ ){
	if( i%2 == 0 ){
	  if( j%2 == 0 ){
	    printf("#");
	  }else{
	    printf(".");
	  }
	}else{
	  if( j%2 == 0 ){
	    printf(".");
	  }else{
	    printf("#");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
import math

a, b, h, m = list(map(int, input().split()))

deg_h = (h*60+m)/(12*60)*2*math.pi
deg_m = (m/60)*2*math.pi

# print(deg_h/(2*math.pi)*360)
# print(deg_m)
h_x = a*math.sin(deg_h)
h_y = a*math.cos(deg_h)
# print(h_x)
# print(h_y)


m_x = b*math.sin(deg_m)
m_y = b*math.cos(deg_m)
# print(m_x)
# print(m_y)
ans = ((h_x-m_x)**2+(h_y-m_y)**2)**0.5
print(ans)


Measured memory_bytes: 9572
import java.util.*;

public class Main{

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

    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());

    int[] d = new int[k];
    boolean[] t = new boolean[n];
    for(int i=0; i<k; i++){
      d[i] = Integer.parseInt(sc.next());
      for(int j=0; j<d[i]; j++){
        t[Integer.parseInt(sc.next())-1] = true;
      }
    }
    int T=0;

    for(int i=0; i<n; i++){
      if(t[i] != true)
        T++;
    }

    System.out.println(T);
    

  }
}


Measured memory_bytes: 41568
n = [int(input()) for i in range(1)][0]
li = list(map(int,input().split()))
a = 1
while True:
    if 0 in li:
        print(0)
        break
    for num in li:
        a = a * num
        if a <= 10**18:
          continue
        if a > 10**18:
          break
    if a <= 10**18:
        print(a)
        break
    if a > 10**18:
        print(-1)
        break

Measured memory_bytes: 21652
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      
      	while((a>0)&&(c>0)){
          	c -= b;
          	if(c<=0){
              	System.out.println("Yes");
              	return;
          	}
          	a -= d;
          	if(a<=0){
          		System.out.println("No");
          		return;
          	}
        }
    }
}


Measured memory_bytes: 35740
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct s {
    int a, b, c, d;
};

int n, m, q;
vector
 v;
vector<int> a(10);

uint64_t solve(int idx) {
    uint64_t res = 0;
    if (idx == n) {
        for (int i = 0; i < q; ++i) {
            if (a[v[i].b] - a[v[i].a] == v[i].c) {
                res += v[i].d;
            }
        }
        return res;
    }
    for (int i = 1; i <= m; ++i) {
        if (idx > 0 && a[idx - 1] > i) continue;
        a[idx] = i;
        res = max(res, solve(idx + 1));
    }
    return res;
}

int main() {
    cin >> n >> m >> q;
    v.reserve(q);
    v.resize(q);
    for(size_t i = 0; i < q; ++i) {
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
        --v[i].a;
        --v[i].b;
    }
    cout << solve(0);
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class345
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var edge = new List<int>[N];
            for (int i = 0; i < N; i++) edge[i] = new List<int>();
            for(int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();
                edge[r[0]].Add(r[1]);
                edge[r[1]].Add(r[0]);
            }
            int[] nums = new int[N];
            bool[] frags = new bool[N];
            frags[0] = true;
            var que = new Queue<int>();
            que.Enqueue(0);
            while (que.Count > 0)
            {
                var t = que.Dequeue();
                foreach(int i in edge[t])
                {
                    if (frags[i]) continue;
                    frags[i] = true;
                    nums[i] = t;
                    que.Enqueue(i);
                }
            }
            if (frags.Contains(false)) Console.WriteLine("No");
            else
            {
                Console.WriteLine("Yes");
                for(int i = 1;i<N;i++)
                    Console.WriteLine(nums[i]+1);
            }
        }
    }
}


Measured memory_bytes: 52104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, cnt_mochi;
  scanf("%d", &n);
  vector<int> d(n);

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

  sort(d.begin(), d.end());

  for(int i = 0; i < n; i++){
    cnt_mochi++;
    if( i != 0 && d[i-1] == d[i] ){
      cnt_mochi--;
    }
    
  }

  printf("%d", cnt_mochi);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  string s;
  cin>>s;
  vector<int> a(26,0);

  for(auto c : s) a[c-'a']++;

  int ans = 0;
  rep(i,26) if(a[i]%2==1) ans++;

  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 3156
s=input()
S=[0]*len(s)
for i in range(len(s)):
  S[i]=int(s[i])
k=int(input())
ans=0
if len(s)>=k:
  if sum(S[:k])==k:
    print(1)
    ans=1
if ans!=1:
  for i in range(len(S)):
    if S[i]!=1:
      print(S[i])
      break

Measured memory_bytes: 3064
<?php
    $list = explode(" ", trim(fgets(STDIN)));

    $count1 = 0;
    $count2 = 0;

    foreach($list as $val){
        if($val == '7' ){
            $count1++;
        }elseif($val=='5'){
            $count2++;
        }
    }

    if($count1 == 1 && $count2 == 2){
        echo "YES\n";
    }else{
        echo "NO\n";
    }


Measured memory_bytes: 4604