akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    ll n;
    n = readll();
    ll ans = n / 2;
    if (n & 1)
    {
        ans++;
    }
    printf("%lld\n", ans );
    return 0;
}




Measured memory_bytes: 256
/* low_link.cpp
    グラフの関節点・橋の列挙をする

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

struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;
using P = pair<long, long>;

struct LowLink {
    const Graph &G;
    vector<int> used, ord, low;
    vector<int> aps;  // articulation points
    vector<P> bridges;

    LowLink(const Graph &G_) : G(G_) {
        used.assign(G.size(), 0);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < G.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }

    int dfs(int id, int k, int par) {
        used[id] = true;
        ord[id] = k++;
        low[id] = ord[id];
        bool is_aps = false;
        int count = 0;
        for (auto &e : G[id]) {
            if (!used[e.to]) {
                count++;
                k = dfs(e.to, k, id);
                low[id] = min(low[id], low[e.to]);
                if (par != -1 && ord[id] <= low[e.to]) is_aps = true;
                if (ord[id] < low[e.to]) bridges.emplace_back(id, e.to);
            } else if (e.to != par) {
                low[id] = min(low[id], ord[e.to]);
            }
        }
        if (par == -1 && count >= 2) is_aps = true;
        if (is_aps) aps.push_back(id);
        return k;
    }
};

int main() {
    long long V, E;
    cin >> V >> E;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back({t});
        G[t].push_back({s});
    }

    LowLink lowlink(G);

    sort(lowlink.aps.begin(), lowlink.aps.end());
    for (auto i : lowlink.aps) {
        cout << i << endl;
    }
    return 0;
}



Measured memory_bytes: 5100
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int wa = a + b;
        int sa = a - b;
        int seki = a * b;
        
        int maxWaSa = Math.max(wa, sa);
        System.out.println(Math.max(seki, maxWaSa));
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    string S, T; cin >> S >> T;
    int n = S.size();
    int m = T.size();
    int sum = INF32;
    for (int i = 0; i < n; ++i) {
        int tmp = 0;
        for (int j = 0; j < m; ++j) {
            if(i+j >= n) {
                tmp = INF32;
                break;
            }
            if(S[i+j] != T[j] ) ++tmp;
        }
        sum = min(sum, tmp);
    }
    cout << sum << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

typedef long long ll;

struct Edge {
    ll s,t;
    ll w;
    bool operator < (const Edge& tgt) const {
	return w > tgt.w;
    }
};

ll Prim(const vector<vector<Edge>>& G) {
    const ll V = G.size();
    priority_queue<Edge> edges;
    
    vector<int> used(V,0);
    edges.push( Edge{-1,0,0} );
    ll ans = 0;
    while( edges.size() ) {
	Edge e = edges.top(); edges.pop();

	if( used[e.t] == 1 ) continue;
	used[e.t] = 1;
	ans += e.w;

	for(auto& nxt : G[e.t]) {
	    if( used[nxt.t] == 1 ) continue;
	    edges.push(nxt);
	}
    }
    return ans;
}


int main () {

    ll V; cin >> V;
    vector<vector<Edge>> G(V);
    for(int i=0; i<V; i++) {
	for(int j=0; j<V; j++) {
	    ll w; cin >> w;
	    if( w != -1 ) {
		G[i].push_back( Edge{i,j,w} );
	    }
	}
    }
    cout << Prim(G) << endl;
    return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n, ans = 0, a[5],count=0;
	string s;

	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	vecll now(5, 0);

	forll(i, 0, 5)
		if (n / a[i] == 0)
			now[i] == 0;
		else
			now[i] == 1;

	count = max((n-1) / a[0] + now[0], (n - 1) / a[1] + now[1]);

	forll(i, 2, 5)
	{
		count = max(count, (n - 1) / a[i] + now[i]);
	}

	count += 5;
	
	cout << count;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,N):
        self.table = [i for i in range(N)]
        self.size = [1] * N
        self.rank = [0] * N
    
    def find(self,x):
        if self.table[x] == x:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]
    
    def unite(self,x,y):
        x,y = self.find(x),self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.table[x] = y
            self.size[y] += self.size[x]
        else:
            self.table[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self,x,y):
        return self.table[x] == self.table[y]

    def count(self,x):
        return self.size[x]

N,K,L = map(int,input().split())
uf_road = UnionFind(N)
uf_rail = UnionFind(N)
for k in range(K):
    p,q = map(int,input().split())
    uf_road.unite(p-1,q-1)
for l in range(L):
    r,s = map(int,input().split())
    uf_rail.unite(r-1,s-1)

d = {}
for i in range(N):
    k = (uf_road.find(i),uf_rail.find(i))
    if k in d.keys():
        d[k] += 1
    else:
        d[k] = 1

ans = []
for i in range(N):
    k = (uf_road.find(i),uf_rail.find(i))
    ans.append(d[k])
print(*ans)

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

namespace ConsoleApp15
{
    class Class8
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<int, int> nums = new Dictionary<int, int>();
            for(int i = 1; i <= N; i++)
            {
                int num = i;
                for(int j = 2; num > 1; j++)
                {
                    while (num % j == 0)
                    {
                        num /= j;
                        if (nums.ContainsKey(j))
                        {
                            nums[j]++;
                        }
                        else
                        {
                            nums[j] = 2;
                        }
                    }
                }
            }

            long ans = 1;
            foreach(int i in nums.Values)
            {
                ans *= i;
                ans %= 1000000007;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l, a, b, c, d;
		
		l = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		
		if (a % c == 0) {
			a = a / c;
		} else {
			a = a / c + 1;
		}
		
		if (b % d == 0) {
			b = b / d;
		} else {
			b = b / d + 1;
		}
		
		System.out.println(l - Math.max(a,  b));
	}
}

Measured memory_bytes: 17220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    map<ll,ll> m;
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        ll val;
        cin>>val;
        m[val]++;
        sum+=val;
    }
    ll mo;
    cin>>mo;
    for(int i=1;i<=mo;i++)
    {
        ll u,v;
        cin>>u>>v;
        sum-=u*m[u];
        sum+=v*m[u];
        m[v]+=m[u];
        m[u]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 9584
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    int sCount = 0;
    int ans = 0;
    for (char c: s) {
        if (c == 'S') {
            sCount++;
        } else {
            if (sCount > 0) {
                sCount--;
            } else {
                ans++;
            }
        }
    }

    cout << (ans + sCount) <<endl;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

const int N = 2e5 + 5;
int n, T;
vector <pair <int, int> > v1;
vector <int> v0; vector <ll> sum0;
ll f[35][N];

bool comp(pair <int, int> a, pair <int, int> b) {
	return 1LL * b.first * (1 + a.second) < 1LL * a.first * (1 + b.second);
}

int F(int rem) {
	return upper_bound(sum0.begin(), sum0.end(), rem) - sum0.begin();
}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> T;
	for (int i = 0; i < n; ++ i) {
		int a, b; cin >> a >> b;
		if (a) v1.push_back(make_pair(a, b));
		else v0.push_back(b);
	}
	sort(v0.begin(), v0.end());
	sum0.resize(v0.size());
	for (int i = 0; i < v0.size(); ++ i) {
		if (i) sum0[i] = sum0[i - 1];
		sum0[i] += 1 + v0[i];
	}
	sort(v1.begin(), v1.end(), comp);
	for (int i = 0; i <= 30; ++ i)
		for (int j = 0; j <= v1.size(); ++ j)
			f[i][j] = T + 5;
	f[0][0] = 0;
	for (int i = 0; i < 30; ++ i) {
		for (int j = 0; j < v1.size(); ++ j) {
			f[i][j + 1] = min(f[i][j + 1], f[i][j]);
			f[i + 1][j + 1] = min(f[i + 1][j + 1], 1LL * (1 + v1[j].first) * (1 + f[i][j]) + v1[j].second);
		}
	}
	int ans = 0;
	for (int i = 0; i <= 30; ++ i) {
		for (int j = 0; j <= v1.size(); ++ j) {
			if (f[i][j] <= T) ans = max(ans, i + F(T - f[i][j]));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 51056
//kid_kb//

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
//    cin>>t;
    t=1;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        rep(i,0,n)cin>>arr[i];
        ll maxi=*max_element(arr,arr+n);
        if(k==0){cout<<maxi<<endl;return 0;}
        
        ll ub=maxi;
         ll lb=1;
         ll ans;
         while(lb<=ub){
             ll mid=(ub+lb)/2;
             
             ll req = 0;
       
             for(int i = 0; i < n; i++)
             {
                 req += (arr[i]-1)/ mid;
             }
             if(req<=k){
                 ans=mid;
                 ub=mid-1;
             }
             else lb=mid+1;
         }
         
        cout<<ans<<endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 5128
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int h, w;
  cin >> h >> w;
  VS s(h);
  REP(i, h) {
    cin >> s[i];
  }
  VVI vertical(w, VI(h));
  VVI horizontal(h, VI(w));
  // Scan done.

  // Code begin.
  REP(x,w) {
    int idx = 0;
    REP(y,h) {
      if (s[y][x] == '#') {
        FOR(i,idx,y) {
          vertical[x][i] = y - idx;
        }
        idx = y + 1;
        continue;
      }
      if (y==h-1) {
        FOR(i,idx,h) {
          vertical[x][i] = y - idx + 1;
        }
      }
    }
  }

  REP(y,h) {
    int idx = 0;
    REP(x,w) {
      if (s[y][x] == '#') {
        FOR(i,idx,x) {
          horizontal[y][i] = x - idx;
        }
        idx = x + 1;
        continue;
      }
      if (x==w-1) {
        FOR(i,idx,w) {
          horizontal[y][i] = x - idx + 1;
        }
      }
    }
  }

  int maxim = 0;
  REP(y, h) {
    REP(x,w) {
      maxim = max(maxim, vertical[x][y] + horizontal[y][x] - 1);
    }
  }

  cout << maxim << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  i64 x = 1, y = 1;
  rep(i, 0, n) {
    i64 t, a;
    cin >> t >> a;

    i64 n = max(x / t + !!(x % t), y / a + !!(y % a));
    x = n * t;
    y = n * a;
  }
  cout << x + y << endl;
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pq.push(x);
	}
	
	while(m > 0) {
		int x = pq.top(); pq.pop();
		pq.push(x/2);
		m--;
	}
	
	ll ans = 0;
	while(!pq.empty()) {
		ans += pq.top(); pq.pop();
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N;
    cin >> N;
    set<string> ids;
    for(int i=0; i<N; i++){
        string id;
        cin >> id;
        ids.insert(id);
    }
    
    int M;
    bool locked = true;
    cin >> M;
    while(M--){
        string id;
        cin >> id;
        if(ids.count(id)){
            if(locked)
                cout << "Opened by " << id << endl;
            else
                cout << "Closed by " << id << endl;
            locked ^= true;
        }else{
            cout << "Unknown " << id << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1232
a=input()
a_1=int(a.split()[0])
b_1=int(a.split()[1])
a=input()
a_2=int(a.split()[0])
b_2=int(a.split()[1])
a=input()
a_3=int(a.split()[0])
b_3=int(a.split()[1])

num=[]
num.append(a_1)
num.append(a_2)
num.append(a_3)
num.append(b_1)
num.append(b_2)
num.append(b_3)

count_a=0
count_b=0
count_c=0
count_d=0

for i in(num):
  if(i==1): count_a+=1
  elif(i==2): count_b+=1
  elif(i==3): count_c+=1
  elif(i==4): count_d+=1

if(count_a>2 or count_b>2 or count_c>2 or count_d>2):
  print('NO')
else:
  print('YES')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N,L;cin>>N>>L;
  vs S(N);rep(i,N)cin>>S[i];
  sort(all(S));
  for(auto x:S)cout<<x;
  cout<<endl;
}





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

int main(){
  int N;
  cin >> N;
  string s=to_string(N);
  int sum=0;
  for(int i=0;i<s.size();i++){
    sum+=s.at(i)-'0';
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<ll> v;
    for(int i=0;i<n;i++){
        ll t;
        cin>>t;
        v.pb(t);
    }
    ll ans=1;
    for(int i=0;i<n;i++){
        ans=lcm(ans,v[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,T=map(int,input().split())
List = []
for i in range (N):
  List.append(list(map(int, input().split())))
res = 1001
for i in range(N):
  if List[i][1] <= T:
    res = min(res,List[i][0])
if res == 1001:
  print("TLE")
else:
  print(res)

Measured memory_bytes: 9136
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
      cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
    low[v] = ord[v] = now_ord
    now_ord += 1
    visited[vis_i], vis_i = v, vis_i + 1
    for e in range(idx[v], idx[v + 1]):
        to = G[e, 1]
        if ord[to] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, to)
            low[v] = min(low[v], low[to])
        else:
            low[v] = min(low[v], ord[to])
    if low[v] == ord[v]:
        while True:
            u, vis_i = visited[vis_i - 1], vis_i - 1
            ord[u] = N
            ids[u] = group_num
            if u == v:
                break
        group_num += 1
    return now_ord, group_num, vis_i


@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
    idx = np.searchsorted(G[:, 0], np.arange(N + 1))
    low = np.zeros(N, np.int64)
    ord = np.zeros(N, np.int64) - 1
    now_ord = 0
    group_num = 0
    visited, vis_i = np.empty(N, np.int64), 0
    ids = np.zeros(N, np.int64)
    for v in range(N):
        if ord[v] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, v)
    return group_num, group_num - ids - 1

@njit((i8, i8, i8[:]), cache=True)
def main(N, D, XY):
    # X を True として、two sat に帰着する
    X, Y = XY[::2], XY[1::2]
    G, g = np.empty((4 * N * N, 2), np.int64), 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if abs(X[i] - X[j]) < D:
                # i True implies j False
                G[g], g = (i, j + N), g + 1
            if abs(X[i] - Y[j]) < D:
                # i True implies j True
                G[g], g = (i, j), g + 1
            if abs(Y[i] - X[j]) < D:
                # i False implies j False
                G[g], g = (i + N, j + N), g + 1
            if abs(Y[i] - Y[j]) < D:
                # i False implies j True
                G[g], g = (i + N, j), g + 1
    G = G[:g]
    G = G[np.argsort(G[:,0])]
    n_comp, comp = scc(N + N, G)
    ans = np.empty(N, np.int64)
    for i in range(N):
        if comp[i] < comp[i + N]:
            ans[i] = Y[i]
        elif comp[i] > comp[i + N]:
            ans[i] = X[i]
        else:
            print('No')
            return
    print('Yes')
    for x in ans:
        print(x)

N, D = map(int, readline().split())
XY = np.array(read().split(), np.int64)

main(N, D, XY)


Measured memory_bytes: 108080
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >>a>>b;
    if(a == b){
        cout << "a == b" << endl;
    } else if(a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
    return 0; 
}


Measured memory_bytes: 3104
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

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



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
# ITP1_10
# ミンコフスキー距離
# # ただし、0.00001 以下の誤差があってもよいものとします。



n = STDIN.gets.split(" ").map(&:to_i)
x = STDIN.gets.split(" ").map(&:to_i)
y = STDIN.gets.split(" ").map(&:to_i)


# n = 3
# x = %w( 1 2 3 ).map(&:to_i)
# y = %w( 2 0 4 ).map(&:to_i)



# p n,x,y


# マンハッタン距離
man = x.each_with_index.map {|a, index|
  (x[index] - y[index]).abs
}.sum


# ユークリッド距離
euc = x.each_with_index.map {|a, index|
  (x[index] - y[index]).abs**2
}.sum**(1/2.0)


# ミコンフスキー距離(p=3)
mic_3 = x.each_with_index.map {|a, index|
  (x[index] - y[index]).abs**3
}.sum**(1/3.0)


#
# チェビシェフ距離
cheby = x.each_with_index.map { |_, index|
  (x[index] - y[index]).abs
}.max


puts [man, euc, mic_3, cheby]



Measured memory_bytes: 6932
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int main(){
	vi sosu(300010);
	sosu[0]=sosu[1]=1;
	for(int i=2;i*i<=300010;i++)if(sosu[i]==0&&(i%7==1||i%7==6)){
		for(int j=i*2;j<300010;j+=i)sosu[j]=1;
	}
	int n;
	while(cin>>n,n-1){
		cout<<n<<":";
		rep(i,n+1)if(sosu[i]==0&&(i%7==1||i%7==6)&&n%i==0)cout<<" "<<i;
		cout<<endl;
	}
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, M, x, ans = 0;
	int a;
	
	while (1) {
		scanf("%d %d", &N, &M);
		if (N == 0 && M == 0) {
			break;
		}
		x = M / N;
		for (int i = 0; i < N; i++) {
			scanf("%d", &a);
			if (x > a) ans += a;
			else ans += x;
		}
		printf("%d\n", ans);
		ans = 0;
	}

	return 0;
}




Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <iomanip>

#define NUM_S 6

class Dice {
public:
	Dice(const int n[NUM_S]);

	int roll(char);
	int rollF();
	int rollR();
	int rollL();
	int rollB();
	int rollCwise();

	int getTop();
	int getF();
	int getR();
	int getL();
	int getB();
	int getBottom();

	void show();

private:
	int top, front, right, left, back, bottom;
};
using namespace std;


int main(void){
	int surface[NUM_S];
	int q, top, front;
	
	for (int i = 0; i < NUM_S; i++) {
		cin >> surface[i];
	}

	Dice dice(surface);

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> top >> front;
		if (dice.getR() == top || dice.getL() == top) {
			dice.rollR();
		}
		while (dice.rollF() != top) {
		}
		while (dice.getF() != front) {
			dice.rollCwise();
		}
		cout << dice.getR() << "\n";
	}

	return 0;
}


Dice::Dice(const int n[NUM_S]) {
	top = n[0];
	front = n[1];
	right = n[2];
	left = n[3];
	back = n[4];
	bottom = n[5];
}

int Dice::roll(char c) {
	if (c == 'S') {
		return rollF();
	}
	else if (c == 'E') {
		return rollR();
	}
	else if (c == 'W') {
		return rollL();
	}
	else if (c == 'N') {
		return rollB();
	}
	else {
		return 0;
	}
}

int Dice::rollF() {
	int buf = top;
	top = back;
	back = bottom;
	bottom = front;
	front = buf;
	return top;
}

int Dice::rollR() {
	int buf = top;
	top = left;
	left = bottom;
	bottom = right;
	right = buf;
	return top;
}

int Dice::rollL() {
	int buf = top;
	top = right;
	right = bottom;
	bottom = left;
	left = buf;
	return top;
}

int Dice::rollB() {
	int buf = top;
	top = front;
	front = bottom;
	bottom = back;
	back = buf;
	return top;
}

int Dice::rollCwise() {
	int buf = left;
	left = front;
	front = right;
	right = back;
	back = buf;
	return top;
}

int Dice::getTop() {
	return top;
}

int Dice::getF() {
	return front;
}

int Dice::getR() {
	return right;
}


int Dice::getL() {
	return left;
}


int Dice::getB() {
	return back;
}


int Dice::getBottom() {
	return bottom;
}


void Dice::show() {
	cout << top << "\n";
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

lint n;
int ans;

void dfs(lint t, bool a, bool b, bool c){
    if(t > n) return;
    if(a && b && c) ++ans;
    dfs(t*10+3, true, b, c);
    dfs(t*10+5, a, true, c);
    dfs(t*10+7, a, b, true);
}

int main(){
    scanf("%lld", &n);
    dfs(0, false, false, false);
    printf("%d\n", ans);
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  // double table[n][n];
  // rep(i, n) rep(j, n) table[i][j] = 0;
  ll dp[n];
  dp[0] = 1000;
  reps1(i, n) dp[i] = 0;
  reps1(i, n) {
    rep(j, i) {
      ll tmp = dp[i-j-1] / a[i-j-1];
      chmax(dp[i], dp[i-j-1] - tmp * a[i-j-1] + tmp * a[i]);
      chmax(dp[i], dp[i-j-1]);
      // cout << i << " " << j << " " << tmp << " " << tmp + a[i] * (tmp / a[i]) << " " << dp[i-j-1] - tmp * a[i-j-1] + tmp * a[i] << endl;
    }
  }

  cout << dp[n-1] << endl;
  /*
  rep(i, n) {
    cout << dp[i] << endl;
  }
  */

  return 0;
}


Measured memory_bytes: 3620
main = do
  s <- read <$> getLine
  let a = div s 100
  let b = mod s 100
  putStrLn $ func a b

func :: Int -> Int -> String
func a b
  | (a < 1) || (a > 12) = if (b > 0) && (b <= 12)
                             then "YYMM"
                             else "NA"
  | (a > 0) && (a <= 12) = if (b > 0) && (b <= 12)
                             then "AMBIGUOUS"
                             else "MMYY"


Measured memory_bytes: 508
def lower_bound(al, key):
    """
    一般に左側が満たしておらず、右側は満たしている判定基準(境目は一つ)ならlower_boundになる
    (条件を満たすもののうち、最小のインデックスを返す)
    単調にさえなっていれば、左右が逆になっていても検索には使える(ng/okも一緒に逆にする必要がある)
    """
    def isOk(a):
        # alの中でkey以上のアイテムのうち最小のインデックスを返す
        # upper_boundにする時にはa>key
        return a>key

    ng = -1
    ok = len(al)

    while abs(ok-ng)>1:
        mid = (ok+ng)//2

        if isOk(al[mid]):
            ok = mid
        else:
            ng = mid

    return ok

n = int(input())
s = list(input())

d = {"R":[],"G":[],"B":[]}

for i in range(n):
    d[s[i]].append(i)

res = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]==s[j]:
            continue
        if s[i]=="R":
            if s[j]=="G":
                k = "B"
            else:
                k = "G"
        elif s[i]=="G":
            if s[j]=="R":
                k = "B"
            else:
                k = "R"
        else:
            if s[j]=="G":
                k = "R"
            else:
                k = "G"
        
        x = lower_bound(d[k],j)
        if x<0 or x>=len(d[k]):
            continue
        ki = j + (j-i)
        res += len(d[k])-x
        if ki<n and s[ki]==k:
            if s[ki]==k:
                res -= 1
print(res)

Measured memory_bytes: 71732
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N_MAX (50)

void solve_main()
{
	DWORD N, tmpN, amariN;
	DWORD countDigit = 0;
	QWORD qwAns = 0;
	cin >> N;
	tmpN = N;

	REP (i, 1, N + 1) {
		DWORD dwDigit = 0;
		DWORD tmpI = i;
		while (tmpI != 0) {
			tmpI /= 10;
			dwDigit++;
		}
		if (1 == (dwDigit % 2)) {
			qwAns++;
		}
	}
	cout << qwAns << endl;
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

void dfs(int v,int p,vector<vector<int> > &G,vector<int> &c){
    for(auto nv :G[v]){
        if(nv==p)continue;
        c[nv]+=c[v];
        dfs(nv,v,G,c);
    }
}

int main(){
    int N,Q;cin >> N >> Q;
    vector<vector<int> > G(N,vector<int>());
    vector<int> counter(N,0);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i,Q){
        int p,x;
        cin >> p >> x;
        p--;
        counter[p]+=x;
    }

    dfs(0,-1,G,counter);

    rep(i,N)cout << counter[i] << endl;

    return 0;
}

Measured memory_bytes: 29696
def main():
    img_a_row, img_b_row = map(int, input().split())
    img_a = [input() for _ in range(img_a_row)]
    img_b = [input() for _ in range(img_b_row)]
    answer = False
    for i in range(img_a_row - img_b_row + 1):
        for j in range(img_a_row - img_b_row + 1):
            count = 0
            for k in range(img_b_row):
                if img_a[i + k][j:j+img_b_row] == img_b[k]:
                    count += 1
            if count == img_b_row:
                answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()



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

int main()
{
    ios::sync_with_stdio(false);
    int a,b;
    while(cin>>a>>b){
        if(a==2||b==2)
            cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String W = scanner.next().toLowerCase();
        String tmp;
        int count = 0;
        while(!(tmp = scanner.next()).equals("END_OF_TEXT")){
            if(tmp.equalsIgnoreCase(W)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  
  vector<int> b(n);
  for(int i=0; i<n; i++) {
    b.at(a.at(i)-1) = i;
  }
  
  for(int i=0; i<n; i++) {
    cout << b.at(i) + 1;
    if(i<n-1)
      cout << " ";
    else if(i==n-1)
      cout << endl;
  }
}

Measured memory_bytes: 1664
from collections import deque
import sys
readline = sys.stdin.readline
N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, readline().split())
    G[u-1].append(v-1)
S, T = map(int, readline().split())
S -= 1; T -= 1

INF = 10**9
U = [[INF]*N for i in range(3)]
U[0][S] = 0
que = deque([(S, 0)])
while que:
    v, t = que.popleft()
    u = (t+1) % 3
    d = U[t][v]
    if t == 2:
        d += 1
    Uu = U[u]
    for w in G[v]:
        if Uu[w] != INF:
            continue
        que.append((w, u))
        Uu[w] = d
print(U[0][T] if U[0][T] < INF else -1)

Measured memory_bytes: 23848
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


# 整数(x, y)最大公約数を求める
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


# 整数(x, y)の最小公倍数を求める
def lcm(x, y):
    return (x // gcd(x, y)) * y


n = II()
T = [II() for _ in range(n)]

ans = 1
for t in T:
    ans = lcm(ans, t)

print(ans)


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

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
typedef long long int lli;

using namespace std;

int main(){
  string s;
  cin >> s;
  int g = 0, p = 0;
  int win = 0, lose = 0;
  REP(i, 0, s.size()) {
    int hand = -1;
    if (g == p) {
      hand = 0;
      g++;
    } else {
      if (s[i] == 'g') {
	hand = 1;
	p++;
      } else {
	hand = 1;
	p++;
      }
    }    
    if (s[i] == 'g' && hand == 1) win++;
    else if (s[i] == 'p' && hand == 0) lose++;
  }
  cout << win - lose << endl;
  return 0;
}


Measured memory_bytes: 512
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
n,m,l,*L=map(int,open(0).read().split())
abc=L[:3*m];st=L[3*m+1:]
town=[[float("inf")]*n for _ in range(n)]
for a,b,c in zip(*[iter(abc)]*3):
	if c<=l:
		town[a-1][b-1]=c
fw=floyd_warshall(town,0)
ti=floyd_warshall(np.where(fw<=l,1,fw),0)
for s,t in zip(*[iter(st)]*2):
	if ti[s-1,t-1]==float("inf"):
		print(-1)
	else:
		print(int(ti[s-1,t-1]-1))

Measured memory_bytes: 40792
#include <algorithm>
#include <complex>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = 0;
  for (auto c : s) {
    if (c == '+') {
      ++n;
    }
    if (c == '-') {
      --n;
    }
  }
  cout << n << endl;
  return 0;
}


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

using namespace std;

long long n, mi, mo;
 
int main()
{
	cin >> n >> mi >> mo;
	mi = mi * (n - 2);
	mo = mo * (n - 2);
	if (mo - mi + 1 < 0)
	{
		cout << 0;
		return 0;
	}
	cout << mo - mi + 1;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int one[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n;
    cin>>n;
    cout<<one[n]<<endl;
    return 0;
}

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

using namespace std;

const int MAXN = 100 + 5;

int n, a[MAXN << 1];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	n <<= 1;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	
	sort(a + 1, a + n + 1);
	
	int ans = 0;
	for (int i = 1; i <= n; i += 2)
		ans += a[i];
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a[3],l[10],ans=1e9;
vector<int>vv;

void make(vector<int>v){
    int b[3]={0},c[3]={0};
    for(int i=0;i<n;i++){
        if(v[i]==0)b[0]+=l[i],c[0]++;
        if(v[i]==1)b[1]+=l[i],c[1]++;
        if(v[i]==2)b[2]+=l[i],c[2]++;
    }
    sort(b,b+3);
    int sum=0;
    for(int i=0;i<3;i++){
        if(c[i]>1)sum+=10*(c[i]-1);
        if(c[i]==0)return;
    }
    ans=min(ans,abs(a[0]-b[0])+abs(a[1]-b[1])+abs(a[2]-b[2])+sum);
    return;
}

void dfs(int now,vector<int>v){
    if(now==n){
        make(v);
        return;
    }
    for(int i=0;i<4;i++){
        vector<int>nw=v;
        nw.eb(i);
        dfs(now+1,nw);
    }
    return;
}

void input(){
	cin>>n;
    for(int i=0;i<3;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>l[i];
	return;
}

void solve(){
    sort(a,a+3);
	dfs(0,vv);
    cout<<ans<<endl;
	return;
}

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

Measured memory_bytes: 256
using System;

namespace AOJ_Progran
{
    class Program
    {
        static void Main(string[] args)
        {
            int first, second, third;
            int[] mountains = new int[10];
            for(int i =0;i<10;i++)
            {
                mountains[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(mountains);
            first = mountains[9];
            second = mountains[8];
            third = mountains[7];

            Console.WriteLine(first);
            Console.WriteLine(second);
            Console.WriteLine(third);

        }
    }
}

Measured memory_bytes: 9140
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, C, X;
int D[30][39];
int t[3][30];

int main(void)
{
  cin >> N >> C;
  REP(i, C) REP(j, C) cin >> D[i][j];
  REP(i, N) REP(j, N)
  {
    cin >> X;
    t[(i + j) % 3][X - 1]++;
  }

  int res = 1 << 30;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      if (i == j) continue;
      for (int k = 0; k < C; k++) {
        if (i != k && j != k) {
          int tt = 0;
          REP(l, C) tt += D[l][i] * t[0][l];
          REP(l, C) tt += D[l][j] * t[1][l];
          REP(l, C) tt += D[l][k] * t[2][l];
          if (tt < res) res = tt;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,m,x,y,X[101],Y[101],i,j,k,z=0,a=0,b=0;
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(i=0;i<n;i++){
		scanf("%d",&X[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&Y[i]);
	}
	for(i=x+1;i<y+1;i++){
		for(j=0;j<n;j++){
			if(i<=X[j]){
				a=1;
			}
		}
		if(a==0){
			for(j=0;j<m;j++){
				if(i>Y[j]){
					z=1;
				}
			}
		}else{
			z=1;
		}
		if(z==0){
			b=1;
		}
		a=0;
		z=0;
	}
	if(b==1){
		printf("No War\n");
	}else{
		printf("War\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    if(n==0) cout<<"1"<<endl;
    else if(n==1) cout<<"2"<<endl;
    else if(n==2) cout<<"1"<<endl;
    else cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 1160