akhauriyash/Code-Regression huggingface dataset:
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;



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

	string abc = "abcdefghijklmnopqrstuvwxyz";
	ll ans = 1;
	ll cnt = 1;
	rep(i, abc.size()) {
		rep(j, s.size()) {
			if (abc[i] == s[j]) cnt++;
		}
		ans *= cnt;
		ans %= MOD;
		cnt = 1;
	}
	ans--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var k int
	var a, b int
	fmt.Scan(&k)
	fmt.Scanf("%d %d", &a, &b)

	if a%k == 0 || b%k == 0 {
		fmt.Println("OK")
		return
	}

	a_k := a / k
	b_k := b / k
	if b_k-a_k > 0 {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
#define NODE 1000005
#define NINF INT_MIN

vll graph[NODE];
bool vis[NODE];
bool wset[NODE];
int wss;
bool gset[NODE];
bool bset[NODE];
void dfs(int node,int dp[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (auto v:graph[node]) { 
  
        // If not visited 
        if (!vis[v]) 
            dfs(v,dp); 
  
        // Store the max of the paths
        dp[node] = max(dp[node], 1 + dp[v]); 
    } 
}
  
// Function that returns the longest path 
int findLongestPath(int n) 
{ 
    // Dp array 
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp);
  
    // Call DFS for every unvisited vertex 
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i,dp); 
    } 
  
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
}

bool dfs(int curr) {
   //moving curr to white set to grey set.
   wset[curr]=false;
   wss--;
   gset[curr]=true;

   for(auto v:graph[curr]) {

         if(bset[v]==true)
            continue;    //if the vertices are in the black set
         if(gset[v]==true)
            return true;    //it is a cycle
         if(dfs(v))
            return true;    //cycle found
   }

   //moving v to grey set to black set.
   gset[curr]=false;
   bset[curr]=true;
   return false;
}

bool hasCycle(int k) {
	wss=0;
   for(int i = 1; i<=k; i++){
      wss++;
      wset[i]=true;   //initially add all node into the white set
   }

   while(wss > 0) {
   	// cout<<1<<endl;
      for(int current = 1; current <= k; current++) {
         if(wset[current]==true)
            if(dfs(current))
               return true;
      }
   }
   return false;
}

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	map< set<ll> , ll> m;
	ll k=1;
	for(ll i=1;i<=n;++i){
		for(ll j=i+1;j<=n;++j){
			set<ll> s;
			s.insert(i);
			s.insert(j);
			m[s]=k++;
		}
	}
	// for(auto val: m){
	// 	for(auto p :val.first)
	// 		cout<<p<<" ";
	// 	cout<<":";
	// 	cout<<val.second<<endl;
	// }
	set<ll> s,t;
	for(ll i=1;i<=n;++i){
		s.clear();
		s.insert(i);
		ll val;
		scanf("%d",&val);
		s.insert(val);
		for(ll j=1;j<n-1;++j){
			t.clear();
			t.insert(i);
			scanf("%d",&val);
			t.insert(val);
			graph[m[s]].pb(m[t]);
			s=t;
		}
	}
	// cout<<"here"<<endl;
	if(hasCycle(k))
		printf("-1\n");
	else{
		// cout<<1<<endl;
		printf("%d",findLongestPath(k)+1);
	}
}

Measured memory_bytes: 137856
#include<iostream>
#include<math.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
long long ma = pow(10, 20);

long long nasu(long long X[18], int re, int n) {
	long long ans = ma;
	long long L[17][18];
	if (n == 3) {
		return X[0] + X[1] * 2 + X[2];
	}
	if (re < 1) re = 1;
	for (int i = re; i < n - 1; i++) {
		int f = 0;
		for (int j = 0; j < n - 1; j++) {
			if (j == i) {
				L[i][j - 1] = X[j - 1] + X[j];
				L[i][j] = X[j] + X[j + 1];
				f = 1;
			} else {
				L[i][j] = X[j + f];
			}
		}
		long long t = nasu(L[i], i - 1, n - 1);
		if (t < ans) {
			ans = t;
		}
	}
	return ans;
}

int main() {
	int n;
	long long L[18];
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		L[i] = x;
	}
  	if (n == 2) {
    	cout << L[0] + L[1] << endl;
    } else {
  		cout << nasu(L, 1, n) << endl;
    }
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
	static long nck(int n,int k) {
		if(k>n)return 0;
		if(k==n)return 1;
		long numerator=fac[n];
		long denominator=(fac[k]*fac[n-k])%mod;
		return (numerator*modinv(denominator))%mod;
	}
	static long fastpow(long n,long ti) {
		 if (ti == 0) 
		        return 1l;
		if(ti%2==0) {
			long y=fastpow(n, ti/2);
			long k=y*y;
			k%=mod;
			return k;
		}
		else {
			long y=fastpow(n, ti/2);
			long k=((n*y)%mod)*y;
			k%=mod;
			return k;
		}
	}
	static long modinv(long a) {
		return fastpow(a, mod-2);
	}
	static long mod=(long)1e9+7;
	static long[]fac;
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt(),k=sc.nextInt();
		fac=new long[n+1];
		fac[0]=1;
		for(int i=1;i<=n;i++)fac[i]=(fac[i-1]*i)%mod;
		Integer[]in=sc.takearrobj(n);
		Arrays.sort(in);
		long ans=0;
		for(int i=0;i<n;i++) {
			int smaller=i,bigger=n-i-1;
			ans+=(nck(smaller, k-1)*in[i])%mod;
			ans%=mod;
			ans-=(nck(bigger, k-1)*in[i])%mod;
			ans+=mod;
			ans%=mod;
		}
		pw.println(ans);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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


int main(){
  int a,b;
  cin >> a >> b;
  
  if(a+b < 10) cout << a + b << endl;
  else cout << "error"<< endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    auto nblue = 0;
    for(auto i = 0; i < n; ++i){
        if(s[i] == '1'){
            nblue++;
        }
    }
    auto nred = n - nblue;
    cout << min(nred, nblue) * 2;
    return 0;
}



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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong N = ulong.Parse(Console.ReadLine());
            ulong[] A=new ulong[1000000];
            for (ulong i = 1; i <= 1000000; i++)
            {
                A[i - 1] = 1000000000001;
                if (N % i == 0)
                {
                    A[i - 1] = i + N / i - 2;
                }
            }
            Console.WriteLine(A.Min());
        }
    }
}


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

int F[102][102];

void setblock(int c, int d, int x, int y){
  if(d==0){
    for(int i=0;i<4;i++){
      F[y][x+i]=c;
      F[y+1][x+i]=c;
    }
  }else{
    for(int i=0;i<4;i++){
      F[y+i][x]=c;
      F[y+i][x+1]=c;
    }
  }

}

void DFS(int Y, int X, int c){
  if(F[Y][X]!=c)
    return;

  F[Y][X] = 6;

  DFS(Y-1, X  ,c);
  DFS(Y  , X+1,c);
  DFS(Y+1, X  ,c);
  DFS(Y  , X-1,c);
}

int main(){
  int w,h,xs,ys,xg,yg,n;
  while(true){
  cin >> w >> h;
  for(int i=0;i<h;i++){
   for(int k=0;k<w;k++){
     F[i][k]=-1;
   }
  }
  if(w==0&&h==0){
    break;
  }
  cin >> xs >> ys;
  cin >> xg >> yg;
  cin >> n;
  for(int i=0; i<n; i++){
    int c,d,x,y;
    cin >> c >> d >> x >> y;
    setblock(c,d,x,y);
  }

  DFS(ys,xs,F[ys][xs]);
  if(F[yg][xg]==6){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}
  return 0;
}



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

using namespace std;

bool solve(const vector<int> &va, int m, vector<vector<int>> &memo,
           int offset = 0) {
  if (m < 0 || va.size() == offset) {
    return m == 0;
  }

  if (memo[m][offset] < 0) {
    memo[m][offset] = solve(va, m, memo, offset + 1) ||
                      solve(va, m - va[offset], memo, offset + 1);
  }

  return memo[m][offset];
}

int main(int argc, char *argv[]) {
  int n, m, q;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  cin >> q;
  vector<int> vm(q);
  for (int i = 0; i < q; ++i) {
    cin >> vm[i];
  }

  int max_m = *max_element(vm.begin(), vm.end());
  vector<vector<int>> memo(max_m + 1, vector<int>(n + 1, -1));
  for (auto m : vm) {
    cout << (solve(va, m, memo) ? "yes" : "no") << '\n';
  }
  return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n);
	rep(i,n){
		cin>>v[i];
	}
	ll ans=0;
	rep(l,n+1)rep(r,n+1){
		if(l+r>k || l-1>=n-r) continue;
		vector<ll> now;
		rep(i,l) now.push_back(v[i]);
		for(int i=n-1;i>=n-r;i--) now.push_back(v[i]);
		sort(begin(now),end(now),greater<ll>());
		ll ret=k-(l+r),sum=0;
		while(ret && now.size()){
			if(now.back()<0){
				ret--;
				now.pop_back();
			}else{
				break;
			}
		}
		for(auto x:now) sum+=x;
		chmax(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<vector<int>> ww(h+5, vector<int>(w+5, 0));
    vector<vector<int>> hh(h+5, vector<int>(w+5, 0));
    REP(i, h) 
    {
        REP(j, w)
        {
            if(j == 0) ww[i][j] = (s[i][j] == '.' ? 1 : 0);
            else
            {
                ww[i][j] = (s[i][j] == '.' ? ww[i][j-1]+1 : 0);
            }
        }
    }
    REP(i, w) 
    {
        REP(j, h)
        {
            if(j == 0) hh[j][i] = (s[j][i] == '.' ? 1 : 0);
            else
            {
                hh[j][i] = (s[j][i] == '.' ? hh[j-1][i]+1 : 0);
            }
        }
    }

    REP(i, h) FOR(j, 1, w) if(ww[i][w-j] != 0 && ww[i][w-j-1] != 0) ww[i][w-j-1] = ww[i][w-j];
    REP(i, w) FOR(j, 1, h) if(hh[h-j][i] != 0 && hh[h-j-1][i] != 0) hh[h-j-1][i] = hh[h-j][i];
    //REP(i, h) REP(j, w) cout << hh[i][j] << " \n"[j==w-1];

    int ans = 0;
    REP(i, h) REP(j, w) ans = max(ans, ww[i][j] + hh[i][j] - 1);
    cout << ans << endl;
}

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

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

  // 昇順にソート済みの入力
  std::vector<int> v(N);
  REP(i,N)v[i] = i;

  std::vector<double> x(N);
  std::vector<double> y(N);

  REP(i,N)
  {
    cin >> x[i] >> y[i];
  }

  double res = 0;

  int kai = 0;

  do {

    double kyori = 0;
    for(int i = 0; i < N-1; ++i)
    {
      double x2 = (x[v[i]] - x[v[i+1]]) * (x[v[i]] - x[v[i+1]]);
      double y2 = (y[v[i]] - y[v[i+1]]) * (y[v[i]] - y[v[i+1]]);
      kyori +=  sqrt(x2 + y2);
    }
    res += kyori;
    ++kai;
  } while (std::next_permutation(v.begin(), v.end()));

  res /= (double)kai;

  printf("%.12f\n",res);

  return 0;    
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N; cin >> N;
  int a[N+1],b[N+1],c[N+1];
  for(int i=1;i<=N;++i){
    cin >> a[i] >> b[i] >> c[i];
  }
  int dp[N+1][3];
  REP(j,3){ dp[0][j] = 0; }
  for(int i=1;i<=N;++i){
    dp[i][0] = max(  dp[i-1][1]+a[i], dp[i-1][2]+a[i]  );  // aを選択する場合
    dp[i][1] = max(  dp[i-1][0]+b[i], dp[i-1][2]+b[i]  );  // bを選択する場合
    dp[i][2] = max(  dp[i-1][0]+c[i], dp[i-1][1]+c[i]  );  // cを選択する場合
  }
  int ans = max( {dp[N][0], dp[N][1], dp[N][2]} );
  cout << ans << "\n";
}

Measured memory_bytes: 5960
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;


const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 1001001001;

vector<vector<int>> list;

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

    /*
    for(int i = 0; i < n; i++) {
        for(int v : list[i]) {
            cout << v << ' ';
        }
        cout << endl;
    }
     */

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);

    // bfs
    dist[0] = 0;
    q.push(0);
    // cout << q.size() << endl;
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(int u : list[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;  // 普段のbfs と違うところ
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) {
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10628
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

while True:
    lst = []
    S = raw_input()
    if S == '.':
        break
    lst.append(S)
    while True:
        S = raw_input()
        if S == '.':
            break
        lst.append(S)
    
    upper = []
    flag = False

    for i in range(len(lst)):
        S = lst[i]
        if '=' in S:
            try:
                exec(S)
            except:
                flag = True
            for elem in upper:
                for key in elem[0]:
                    if key >= elem[1]:
                        flag = True
                        break
            if flag:
                print i + 1
                break
        else:
            P = S.split('[')
            name = P[0]
            num = int(P[1][:-1])
            exec(name + ' = {}')
            upper.append((globals()[name], num))
    
    if not flag:
        print 0


Measured memory_bytes: 5336
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
typedef pair<int, int>P;


int main()
{
    ll a, b, k;
    cin >> a >> b >> k;


    if (a <= k)
    {
        b = b - (k - a);
        a = 0;
       
    }
    else
        a -= k;

    if (b <= 0)
        b = 0;
    if (a <= 0)
        a = 0;

    cout << a << " "<< b << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 1e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, m;

void solve()
{
	int x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << '\n';
}

signed main()
{
	io();
	int tt = 1;
//	cin >> tt;
	while (tt--)
		solve();
}
//overflows!!!

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <initializer_list>
#include <string>
using namespace std;

#define int long long

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }

signed main()
{
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    int l = lcm(N, M);
    int g = gcd(N, M);
    bool ok = true;
    int i = 0, j = 0;
    while (i < N && j < M)
    {
        if (S[i] != T[j])
            ok = false;
        i += l / M;
        j += l / N;
    }
    if (ok)
        cout << l << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
// Aizu 1121: Kanglish:Analysis on Artificial Language
// 2017.9.15 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#define HASHSIZ 101
typedef struct { int c, k; } HASH;
HASH hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int lookup(char a, char b)
{
	int c = (a << 8) + b;
	HASH *p = hash + c % HASHSIZ;
	while (p->c) {
		if (p->c == c) return p->k;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(char a, char b, int k)
{
	int c = (a << 8) + b;
	HASH *p = hash + c % HASHSIZ;
	while (p->c) {
		if (p->c == c) return;
		if (++p == hashend) p = hash;
	}
	p->c = c, p->k = k;
}

char s[12][3] = {"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts" };
int tbl[38][38], c[38], f[38];
char buf[103], *p;

int nxchar()   // -2: eof, -1: ' ', >=0 ch
{
	int k;
	if (*p == 0) return -2;
	if (*p <= ' ') { p++; return -1; }
	if (*(p+1) <= ' ') return *p++ - 'a';
	if ((k = lookup(*p, *(p+1))) > 0) { p += 2; return k; }
	return *p++ - 'a';
}

int main()
{
	int n, k, a, b, x;
	char t[15];

	for (a = 0; a < 12; a++) insert(s[a][0], s[a][1], a+26);
	fgets(t, 10, stdin); n = atoi(t);
	while (n-- > 0) {
		fgets(buf, 100, stdin);	p = buf; a = -1;
		if (*buf >= ' ') { a = b = nxchar();
			while (b != -2) {
				b = nxchar();
				if (b >= 0) {
					if (a >= 0 && b >= 0) tbl[a][b]++;
					a = b;
				} else a = -1;
			}
		}
	}
	for (a = 0; a < 38; a++) {
		for (x = k = 0, b = 0; b < 38; b++) {
			if (tbl[a][b] > k) k = tbl[a][b], x = b;
		}
		c[a] = x, f[a] = k;
	}
	for (a = 0; a < 38; a++) {
		if (a < 26) printf("%c ", a+'a');
		else printf("%s ", s[a-26]);
		if (c[a] < 26) printf("%c %d\n", c[a]+'a', f[a]);
		else printf("%s %d\n", s[c[a]-26], f[a]);
	}
	return 0;
}

Measured memory_bytes: 1796
// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("a.txt","r",stdin);
    double r,area, pi=3.14159;
    cin>>r;
    area=2*pi*r;
    cout<<area;
    //printf("%lf\n",area);

}


Measured memory_bytes: 3816
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1000000007;
ll m;
ll Pow(ll n) {
	if (n == 1) 
	{
		return m;
	}
	ll p = Pow(n/2)%mod;
	p *= p;
	p %= mod; 
	if (n % 2 == 1)
	{
		p *= m;
	}
	return p % mod;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll  n;
	cin >> m >> n;
	//for (int i = 1; i < 1000; i++)
	{
		cout << Pow(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct p
{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1,tail,n;

void enqueue(P x)
  {
    Q[tail]=x;
    if(tail>=LEN)
      tail=0;
    else 
      tail++;
  }
  

P dequeue()
{
  P x;
  x=Q[head];
  if(head>=LEN)
    head=0;
  else 
    head++;
  
  return x;
}





main()
{
  int i,q;
  int sum=0;
  scanf("%d %d",&n,&q);
  
  for(i=1;i<=n;i++)
    {
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
}
  tail=i;

  while(head != tail)
    {
      if(Q[head].t>q)
	{
	  sum+=q;
	  Q[head].t-=q;
	  enqueue(dequeue(Q[head]));
	}
      else 
	{
	  sum+=Q[head].t;
	  printf("%s %d\n",Q[head].name,sum);
	  dequeue(Q[head]);
	}
    }
   return 0;
}  
  

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

i64 cnt[10][10];

void solve() {
  auto left = [](int x) {
    while (x >= 10) x /= 10;
    return x;
  };
  int n;
  cin >> n;
  reps(i, n) {
    int l = left(i);
    int r = i % 10;
    if (l && r) cnt[l][r]++;
  }
  i64 ans = 0;
  reps(i, 9) reps(j, 9) {
    ans += cnt[i][j] * cnt[j][i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
using namespace std;
int main()
 {
	 int n,i,j;
	long long int points=0;
	int a[55];
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<n;i++)
	{
		for(j=i+1;j<=n;j++)
			points+=a[i]*a[j];
	}
	cout<<points;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int n;
  vector<int> v;
  vector<int>::reverse_iterator it;
  for(;;){
    cin >> n;
    if(n < 0) break;
    if(n == 0){
      cout << "0" << endl;
      continue;
    }
    v.clear();
    while(n != 0){
      v.push_back(n%4);
      n /= 4;
    }
    it = v.rbegin();
    while(it != v.rend()){
      cout << (*it);
      it++;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
h,w,m = map(int,input().split())
br = [[i, 0] for i in range(h)]
bc = [[i, 0] for i in range(w)]
bsr = [set() for i in range(h)]
bsc = [set() for i in range(w)]
for _ in range(m):
    i, j = map(int,input().split())
    br[i-1][1] += 1
    bc[j-1][1] += 1
    bsr[i-1].add(j-1)
    bsc[j-1].add(i-1)
br.sort(key=lambda x: x[1], reverse=True)
bc.sort(key=lambda x: x[1], reverse=True)
rmax = br[0][1]
cmax = bc[0][1]
for i,bi in br:
    if bi < rmax:
        break
    for j, bj in bc:
        if bj < cmax:
            break
        if not j in bsr[i]:
            print(rmax + cmax)
            exit()

print(rmax + cmax - 1)

Measured memory_bytes: 312224
#!python3.4.3

temp = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') # len: 26
n = int(input())
s = list(input())
result = ''

for c in s:
    index = temp.index(c)
    if index + n < len(temp):
        result += temp[index + n]
    else:
        result += temp[(len(temp) - (index + n)) * -1]
print(result)

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

long long MOD=1000000007LL;

int main(){
	int N;
	string S;
	cin >> N >> S;
	
	if(S[0]=='W' || S[2*N-1]=='W'){
		cout << "0" << endl;
		return 0;
	}
	
	vector<int> SS(2*N);
	for(int i=0;i<2*N;i++){
		if(S[i]=='W')SS[i]=0;
		else SS[i]=1;
	}
	
	vector<int> A(2*N);
	A[0]=1;
	long long ans=1;
	int c=1;
	int use1=1,use2=0;
	for(int i=1;i<2*N-1;i++){
		if(A[i-1]==1 && (c%2)!=SS[i]){
			A[i]=1;
			c++;
			use1++;
			if(use1>N)ans=0;
		}
		else if(A[i-1]==1 && (c%2)==SS[i]){
			A[i]=2;
			ans*=c;
			ans%=MOD;
			c--;
			use2++;
			if(use2>use1)ans=0;
		}
		else if(A[i-1]==2 && (c%2)==SS[i]){
			A[i]=2;
			ans*=c;
			ans%=MOD;
			c--;
			use2++;
			if(use2>use1)ans=0;
		}
		else if(A[i-1]==2 && (c%2)!=SS[i]){
			A[i]=1;
			c++;
			use1++;
			if(use1>N)ans=0;
		}
		//cout << ans << endl;
		if(ans==0)break;
	}
	if(use1!=N || use2!=(N-1))ans=0;
	for(int i=1;i<=N;i++){
		ans*=i;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll sum = 0;
	rep(i, n) sum ^= a[i];

	rep(i, n) cosp(sum ^ a[i]);
	co();

	return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
long long s[3];
int main() {
    scanf("%lld%lld%lld", &s[0], &s[1], &s[2]);
    sort(s, s + 3);
    printf("%lld\n", (s[0] & 1 && s[1] & 1 && s[2] & 1) ? s[0] * s[1] : 0);
    return 0;
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n+1] = {};
	for(int i=0;i<n;i++){
		cin >> a[i+1];
	}
	int b[n+1] = {};
	int m = 0;
	for(int i=n;i>0;i--){
		int sum = 0;
		int j = 2;
		while(i*j <= n){
			sum += b[i*j];
			j++;
		}
		if(sum % 2 != a[i]){
			b[i]++;
			if(b[i] == 1){
				m++;
			}
		}
	}
	// keisan
	cout << m << endl;
	if(m){
		for(int i=1;i<=n;i++){
			if(b[i]){
				cout << i << ' ';
			}
		}
	}
	// syutsuryoku
}

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

class PaizaSample
{

    

    static void Main()
    {
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
            {
                break;
            }

            List<int> list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }

            int search = int.Parse(Console.ReadLine());

            int step = 0;
            while (true)
            {
                step++;
                if (list[(list.Count - 1) / 2] == search)
                {
                    break;
                }
                else if (list[(list.Count - 1) / 2] > search)
                {
                    list.RemoveRange((list.Count - 1) / 2, list.Count / 2 + 1); 
                }
                else
                {
                    list.RemoveRange(0, (list.Count - 1) / 2 + 1);
                }

                if (list.Count == 0)
                {
                    break;
                }
            }

            Console.WriteLine(step);
        }

       // Console.ReadKey();

    }
}

Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  int D,T,S;
  cin>>D>>T>>S;
  
  if(D<=T*S){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

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

        List<Character> sList = new ArrayList<>();
        List<Character> tList = new ArrayList<>();
        for (char c : s.toCharArray()) { sList.add(c); }
        for (char c : t.toCharArray()) { tList.add(c); }
        Collections.sort(sList);
        Collections.sort(tList, Collections.reverseOrder());

        StringBuilder sSorted = new StringBuilder();
        StringBuilder tReverseSorted = new StringBuilder();
        for (char c : sList) { sSorted.append(c); }
        for (char c : tList) { tReverseSorted.append(c); }

        System.out.println(sSorted.toString().compareTo(tReverseSorted.toString()) < 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.nextInt();
        var syusseki_no_key = new int[n];
        var syusseki_no_value = new int[n];
        for (int i = 0; i < n; i++)
        {
            syusseki_no_key[i] = i + 1;
            syusseki_no_value[i] = sc.nextInt();
        }

        Array.Sort(syusseki_no_value, syusseki_no_key);

        for (int i = 0; i < n; i++)
        {
            Console.Write(syusseki_no_key[i]);
            if (i == n - 1) Console.Write("\n");
            else Console.Write(" ");
        }
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 25052
import math


def main():
    # n = int(input())
    a, b, t = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    print(t // a * b)




if __name__ == '__main__':
    main()


Measured memory_bytes: 61072
from functools import lru_cache

@lru_cache(maxsize=1<<10)
def solve(p, q, a, n):
    def _solve(num, dem, d, m, s):
        if num == 0:
            return 1
        if d == 0:
            return 0
        if num * a // m < dem:
            return 0
        return sum((_solve(num*i-dem, dem*i, d-1, m*i, i)
                    for i in range(s, min(dem*n//num, a//m)+1)), 0)
    return _solve(p, q, n, 1, 1)

if __name__ == "__main__":
    ans = []
    while True:
        p, q, a, n = [int(i) for i in input().split()]
        if p == 0:
            break
        ans.append(solve(p, q, a, n))
    print(*ans, sep="\n")

Measured memory_bytes: 8700
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int dp[101][100001];
    int main()
    {   
         IOS;
         int n,m,i,j,k;
         cin>>n>>k;
         vector<int> v(n+1);
         for(i=1;i<=n;i++)
             cin>>v[i];
      for(i=0;i<=k;i++)
      {
      	if(i<=v[1])
      		dp[1][i]=1;
      }
         for(i=2;i<=n;i++)
         {
            ll sum=0;
         	for(j=0;j<=k;j++)
         	{

         		   sum+=dp[i-1][j];
         			if(j-(v[i]+1)>=0)
         				sum-=dp[i-1][j-v[i]-1];
         			sum+=MOD;sum%=MOD;
         			dp[i][j]=sum;
         	}
         }
         cout<<dp[n][k];
    }

Measured memory_bytes: 39296
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=1e5+5;
ll a[N];
int main()
{
ll n;
cin>>n;
for(ll i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
ll ans=0;
ll pos=n/2;
for(ll i=a[n/2];i>=0;i--)
{
	if(a[pos-1]<i)
	ans++;
	else
	break;
}
cout<<ans;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
    }
    ll cnt=0;
    for(int i=n-1;i>=0;i--){
        if((cnt+a[i])%b[i]!=0){
            cnt+=b[i]-(cnt+a[i])%b[i];
        }
    }
    OUT(cnt);
	return 0;
}

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

/* 
 * So basically you want to find the fastest way to perform the operations 
 * Before reading this solution 
 * You should understand how deque works (Google it :D)
 * If you understand how a deque works you should understand this solution 
 * So first thing you should notice is that we don't really need to reverse the whole string 
 * All we need to know is where the front is currently and where the back is currently 
 * So in my code I have a variable swapped 
 * If swapped is true you know that the end has become the front and the front has become the end 
 * So if swapped is true and you get an end operation then it should go to the front and vice-versa 
 * And if swapped isn't true then you should perform the operations as usual 
 * You can look at the code to understand it better 
 * Solution runs in O(Q log n) time
 * Hope this helps!
 */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  deque<char> deck;
  for (const char& ch : s) 
    deck.push_back(ch);
  int ops;
  cin >> ops;
  bool swapped = false;
  while (ops--) {
    int op;
    cin >> op;
    if (op == 1) swapped = !swapped; // this is just a fancy way of changing the value of swapped (true -> false) and (false -> true)
    else {
      int f;
      char ch;
      cin >> f >> ch;
      if (f == 1) {
        if (swapped)
          deck.push_back(ch); // if swapped this should now go to the back instead of the front 
        else
          deck.push_front(ch); // if not swapped this should go to the front as usual
      } else {
        if (swapped)
          deck.push_front(ch); // if swapped this should now go to the front instead of the back
        else 
          deck.push_back(ch); // if not swapped this should go to the back as usual 
      }
    }
  }
  if (swapped)  // if swapped you need to print the result in reverse
    reverse(deck.begin(), deck.end());
  for (char& ch : deck)
    cout << ch;
  cout << '\n';
  return 0;
}

Measured memory_bytes: 4012
n, m, l = map(int, input().split())

A = []
B = []
C = [[] for i in range(n)]

for i in range(n):
    tmp_row = list(map(int, input().split()))
    A.append(tmp_row)

for i in range(m):
    tmp_row = list(map(int, input().split()))
    B.append(tmp_row)

for i in range(n):
    for j in range(l):
        ab = sum([A[i][k] * B[k][j] for k in range(m)])
        if j == (l - 1):
            print(ab)
        else:
            print(ab, end = ' ')

Measured memory_bytes: 8568
import math
import numpy as np

n,k = map(int,input().split())
a = np.array(list(map(int,input().split())))

# 最小値を見つけて、そこから何回の操作で全部最小値にできるか
# 最小値の場所をxとすると、math.ceil(x/k-1) + math.ceil(n-x/k-1)
# これだとkが大きいときに、違う答えが出ちゃう。一度に(k-1)個しか変えられないのは間違いない

#最小値の位置
x = np.argmin(a)

ans = math.ceil((n-1)/(k-1))
print(ans)





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

// a~b段目(いずれも壊れていない)の移動方法が何通りか
ll solve(ll a,ll b,vector<ll> &fib){
  if (a>b) return 0;
  const ll div = 1000000007;
  ll n = b-a;
  return fib.at(n) % div;
  /* A1 = 1, A2 = 2, A3 = 3, A4 = 5, ...
   An = An-1 + An-2
   
  */
}

int main() {
  ll n,m; cin >>n >>m;
  const ll div = 1000000007;
  ll ans = 1;
  
  vector<ll> fib(n+1);
  fib.at(0) = 1; fib.at(1) = 1;
  for (int i=2; i<n+1; i++){
    fib.at(i)=(fib.at(i-1)+fib.at(i-2)) % div;
  }
  
  if (m==0){
    ans = ans * solve(0,n,fib) % div;
  }else{
	vector<ll> a(m);
 	for (int i=0; i<m; i++) cin >>a.at(i);
  	for (int i=0; i<m-1; i++){
      ans = ans * solve(a.at(i)+1,a.at(i+1)-1,fib) % div;
    }
  	ans = ans * solve(0,a.at(0)-1,fib) % div;
  	ans = ans * solve(a.at(m-1)+1,n,fib) % div;
  }
  
  cout <<ans <<endl;
}


Measured memory_bytes: 1792