akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int t = 1;
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[][] ans = new int[N][N];
			int ord = 1;
			for (int i = 0; i < N; ++i) {
				int r = (i % 2 == 0 ? i : 0);
				int c = (i % 2 == 0 ? 0 : i);
				int dr = (i % 2 == 0 ? -1 : 1);
				int dc = (i % 2 == 0 ? 1 : -1);
				for (int j = 0; j <= i; ++j) {
					ans[r][c] = ord;
					++ord;
					r += dr;
					c += dc;
				}
			}
			System.out.println("Case " + t + ":");
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					System.out.printf("%3d", i + j < N ? ans[i][j] : N * N + 1 - ans[N - 1 - i][N - 1 - j]);
				}
				System.out.println();
			}
			++t;
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool f(vi a,int x){
	set<int> st;
	st.insert(0);
	for(auto i:a){
		set<int> ST;
		for(auto it=st.begin();it!=st.end();it++){
			ST.insert(*it+i);
			ST.insert(*it-i);
		}
		st=ST;
	}
	return st.find(x)!=st.end();
}

int n,x,y;
string s;

int main(){
	cin>>s>>x>>y;
	n=s.size();
	int B=0,d=0;
	vi a[2];
	for(int i=0;i<n;i++){
		if(s[i]=='T'){
			a[B].push_back(d);
			B^=1;
			d=0;
		}
		else d++;
	}
	a[B].push_back(d);
	vi b;
	x-=a[0][0];
	for(int i=1;i<a[0].size();i++) b.push_back(a[0][i]);
	if(f(b,x)&&f(a[1],y)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int abs(int a){ return a > 0 ? a : -a; }
int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
int lcm(int a, int b){ return a/gcd(a,b)*b; }

vector<int> mul(vector<int> a, vector<int> b){
	vector<int> res(a.size()+b.size()-1, 0);
	for(int i=0;i<a.size();i++)
		for(int j=0;j<b.size();j++)
			res[i+j] += a[i]*b[j];
	return res;
}

vector<int> pow(vector<int> vi, int p){
	vector<int> res(1,1);
	for(int i=0;i<p;i++)
		res = mul(res, vi);
	return res;
}

vector<int> add(vector<int> a, vector<int> b){
	vector<int> res(max(a.size(), b.size()), 0);
	for(int i=0;i<a.size();i++) res[i] += a[i];
	for(int i=0;i<b.size();i++) res[i] += b[i];
	return res;
}

int getDigit(string &str, int &idx){
	int res = 0;
	while(idx<str.size() && isdigit(str[idx]))
		res = 10*res+str[idx++]-'0';
	return res;
}

vector<int> parseExpr(string&, int&);

vector<int> parseFact(string &str, int &idx){
	vector<int> res(1, 0);
	if(isdigit(str[idx])){
		res[0] = getDigit(str,idx);
	} else if(str[idx]=='x') {
		res.push_back(1);
		idx++;
	} else if(str[idx]=='('){
		idx++;
		res = parseExpr(str, idx);
		idx++;
	}
	if(idx < str.size() && str[idx]=='^'){
		idx++;
		res = pow(res, getDigit(str, idx));
	}
	return res;
}

vector<int> parseTerm(string &str, int &idx){
	vector<int> res(1, 1);
	while(idx < str.size() && str[idx]!='-' && str[idx]!='+' && str[idx]!=')')
		res = mul(res, parseFact(str, idx));
	return res;
}

vector<int> parseExpr(string &str, int &idx){
	vector<int> res(1, 0);
	while(idx < str.size() && str[idx]!=')'){
		bool m = (str[idx]=='-');
		if(str[idx]=='-'||str[idx]=='+') idx++;
		vector<int> vi = parseTerm(str, idx);
		if(m) for(int i=0;i<vi.size();i++) vi[i] *= -1;
		res = add(res, vi);
	}
	return res;
}

void normalize(vector<int> &vi){
	while(!vi.empty() && vi.back() == 0) vi.pop_back();
	if(vi.empty()) return ;
	int g = vi.back();
	for(int i=0;i<vi.size();i++)
		if(vi[i]!=0) g = gcd(g, abs(vi[i]));
	for(int i=0;i<vi.size();i++) vi[i] /= g;
	if(vi.back()<0)
		for(int i=0;i<vi.size();i++) vi[i] *= -1;
}

void print(vector<int> vi){
	for(int i=vi.size()-1;i>=0;i--){
		if(vi[i]==0) continue;
		if(i==0||abs(vi[i])>1){
			if(i==vi.size()-1) printf("%d", vi[i]);
			else               printf("%+d", vi[i]);
		} else if(i!=vi.size()-1){
			if(vi[i]>0) printf("+");
			else        printf("-");
		}
		if(i > 0) printf("x");
		if(i > 1) printf("^%d", i);
	}
	puts("");
}

vector<int> gcm(vector<int> a, vector<int> b){
	while(true){
		normalize(a);
		normalize(b);
		if(a.empty()) break;
		int L = lcm(a.back(), b.back());
		if(a.size() < b.size()) swap(a, b);
		a = mul(a, vector<int>(1, L/a.back()));
		b = mul(b, vector<int>(1, L/b.back()));
		for(int idxA = a.size()-1,idxB = b.size()-1;idxA>=0 && idxB>=0;idxA--,idxB--)
			a[idxA] -= b[idxB];
	}
	return b;
}


int main(){
	string str;
	while(cin >> str){
		if(str == ".") break;
		int idx = 0;
		vector<int> a = parseExpr(str, idx);
		cin >> str;
		idx = 0;
		vector<int> b = parseExpr(str, idx);
		print(gcm(a, b));
	}
}

Measured memory_bytes: 0
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)
j=1
while j<=m and b[j]+b[j-1]<=k:
  b[j]+=b[j-1]
  j+=1
  

j-=1
books=j
#print(books,b)

i=1
while i<n+1:
  a[i]+=a[i-1]
  while j>=0 and a[i]+b[j]>k:
    j-=1
  if(j!=-1) and a[i]+b[j]<=k:
    books=max(books,j+i)
    
    
    i+=1
    #print(books,b[:j+1],a[:i])
  else:
    break
print(books)
  

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

int main(){
    int i,j;
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            printf("%dx%d=%d\n", i,j,i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 1096
a,b,c=map(int,input().split())
M=[]
for i in range(1,b):
  M.append((a*i)%b)
N=sorted(set(M))

from fractions import gcd as bltin_gcd

if bltin_gcd(a, b) == 1:
  print('YES')
else:
  if a == b:
    if c == 0:
      print('YES')
    else:
      print('NO')
  else:
    x=N[1]
    if c%x == 0:
      print('YES')
    else:
      print('NO')

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

class UnionFind {
 private:
  std::vector<size_t> parents;
  std::vector<size_t> ranks;
  std::vector<size_t> sizes;

 public:
  UnionFind(size_t n) : parents(n), ranks(n), sizes(n, 1) {
    for (size_t i = 0; i < n; i++) parents[i] = i;
  }
  void Unite(size_t a, size_t b) {
    a = Find(a);
    b = Find(b);
    if (a == b) return;
    if (ranks[a] < ranks[b]) {
      parents[a] = b;
    } else {
      parents[b] = a;
      if (ranks[a] == ranks[b]) ranks[a]++;
    }
    sizes[Find(a)] = sizes[a] + sizes[b];
  }
  int Find(size_t a) { return parents[a] == a ? a : parents[a] = Find(parents[a]); }
  int Size(size_t a) { return sizes[Find(a)]; }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  vector<int> r(n);
  UnionFind uf(n);
  while (m--) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    uf.Unite(p, q);
    r[p]--, r[q]--;
  }
  for (int i = 0; i < n; i++) r[i] += uf.Size(i) - 1;
  while (k--) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    if (uf.Find(p) == uf.Find(q)) {
      r[p]--, r[q]--;
    }
  }

  for (auto e : r) cout << e << ' ';
  cout << endl;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  for(int i=0; i<K; i++) {
    if(i%2 ==0 && A%2 !=0) { A--; B += A/2; A /=2;}
    else if(i%2 ==0 && A%2 ==0) { B += A/2; A /=2;}
    else if(i%2 !=0 && B%2 !=0) { B--; A += B/2; B /=2;}
    else if(i%2 !=0 && B%2 ==0) { A += B/2; B /=2;}
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 3652
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  const int n = getInt();

  pair<double, double> ans[2];
  ans[0] = ans[1] = make_pair(-1.0, 0.0);

  int prevA[2] = { -1, -1 };
  int prevF[2] = { 0, 0 };
  int prevX;
  int prevY;

  REP(i,n){
    const int f = getInt();
    const int a = getInt();
    const int t = getInt();
    const int x = getInt();
    const int y = getInt();

    if(prevA[t] != -1 && prevA[t] != a){
      ans[t] = max(ans[t],
                   make_pair(sqrt((prevX - x) * (prevX - x) + (prevY - y) * (prevY - y)),
                             -(f - prevF[t]) / 60.0));
    }

    prevA[t] = a;
    prevF[t] = f;
    prevA[!t] = -1;
    prevF[!t] = f;
    prevX = x;
    prevY = y;
  }

  REP(i,2){
    if(ans[i].first < 0) printf("-1 -1\n");
    else printf("%.8f %.8f\n", ans[i].first, -ans[i].second);
  }

  return 0;
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,i,b,c,t,m,n;
    cin>>m>>n;
    stack<int>s[m];
    while(n--)
    {
        cin>>a>>b;
        if(a==0)
        {
            cin>>c;
            s[b].push(c);
        }
        else if(a==1)
        {
            if(!s[b].empty())
            cout<<s[b].top()<<endl;
        }
        else
        {
            if(!s[b].empty())
            s[b].pop();
        }

    }
}


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

void printLCS( string s1, string s2, int m, int n )
{
   int L[m+1][n+1];

   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }

   int index = L[m][n];
   char LCS[index+1];
   LCS[index] = '\0';
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      if (s1[i-1] == s2[j-1])
      {
          LCS[index-1] = s1[i-1];
          i--; j--; index--;
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }

   cout <<LCS<<endl;
}

int main()
{
  string s1,s2;
  cin>>s1>>s2;
  printLCS(s1, s2, s1.size(), s2.size());
  return 0;
}



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

using namespace std;

const int N = 1e5; // Maximum stones as per problem

int n, stones[N];

int memo[N]; // Memoization Table

int jumps(int ind) {
    if (ind == (n - 1)) return 0; // If we are last stone, then the answer will be 0.
    if (ind >= n) return INT_MAX; // Checking the boundary condition


    // If you are done with the whole function, then only read
    // Since we stored the minimum cost for a stone, now we will use the stored cost
    // We are initializing the table to -1, if the value stored is not -1, then we have calculated the minimum cost
    // So just return that cost
    if (memo[ind] != -1) return memo[ind]; // If reading for first time, then ignore this line

    // Calculate the cost for jumping to next stone (ind + 1) and recursively doing it for next stone
    int oneJump = abs(stones[ind] - stones[ind + 1]) + jumps(ind + 1);

    // Initializing the twoJumps because there can be a case in which there can be only one stone.
    int twoJumps = INT_MAX;

    // Checking if there are more than 2 stones
    if (ind + 2 < n) {
        // Calculate the cost for jumping to next to next stone (ind + 2) and recursively doing it for next to next stone
        twoJumps = abs(stones[ind] - stones[ind + 2]) + jumps(ind + 2);
    }

    // Storing the minimum cost in the memoization table and returning the minimum cost
    // After this,  go to the ignored line.
    return memo[ind] = min(oneJump, twoJumps);
}


int main() {
    // Initializing the memoization table to -1
    memset(memo, -1, sizeof(memo));

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

    // We will start from first stone
    cout << jumps(0) << endl;

    return 0;
}

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

using ll = long long;
using namespace std;

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

   vector <ll> v(n);
   ll even = 0;
   ll odd = 0;
   for(int i = 0; i < n; i++) {
      cin >> v[i];
      v[i] %= 2;
      even += v[i] == 0;
      odd += v[i] == 1;
   }

   if(odd == 0) {
      if(p == 1) {
         cout << 0 << endl;
      } else {
         cout << (1LL << n) << endl;
      }
   } else {
      cout << (1LL << (n - 1)) << endl;
   }
}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   }
 
   return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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 fir first
#define sec second
#define pb push_back
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 int mod = 1000000007;

int main(){
	int d,g;
    cin >> d >> g;
    vector<P> M(d);
    for (int i = 0; i < d; i++) {
        int p,c;
        cin >> p >> c;
        M[i] = make_pair(p, c);
    }
    int ans = INF;
    for (int bit = 0; bit < (1<<d); bit++) {
        int score = 0, num = 0;
        rep(i,d){
            if(bit&(1<<i)){
                score += M[i].fir * (i+1) * 100 + M[i].sec;
                num += M[i].fir;
            }
        }
        if(score >= g){
            chmin(ans, num);
            continue;
        }
        for (int i = d-1; i >= 0; i--) {
            if(bit&(1<<i))continue;
            int j = 0;
            while(score < g && j < M[i].fir){
                score += (i+1)*100;
                num++;
                j++;
                if(j == M[i].fir) score += M[i].sec;
            }
            break;
        }
        if(score >= g){
            chmin(ans, num);
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    int cnt = 0, n = s.length();
    for(int i=0;i<n;++i) {
        if(s[i] == '0') ++cnt;
    }

    cout << 2*min(cnt, n-cnt) << endl;
}


Measured memory_bytes: 512
using System;
namespace AtCoder
{

    class Program
    {
        static void Main(string[] args)
        //static void dummy()
        {
            // 入力データパース
            string szTotal = Console.ReadLine();
            int total = int.Parse(szTotal);

            string szLine = null;
            string[] szSplittedLine = null;
            int[] _listA = new int[total];
            int[] _listB = new int[total];
            for ( int i = 0;i<total;++i)
            {
                szLine = Console.ReadLine();
                szSplittedLine = szLine.Split(' ');
                int a = int.Parse(szSplittedLine[0]);
                int b = int.Parse(szSplittedLine[1]);

                _listA[i] = a;
                _listB[i] = b;
            }

            // ここから何とかする
            // まず一番最後の要素から確定させていく
            long nPressedMin = 0;
            for( int i=total - 1; i >= 0; --i)
            {
                long a = _listA[i] + nPressedMin;
                int b = _listB[i];

                // これはすでに倍数になってる
                if( a % b == 0) { continue; }

                long nPressedThisTime = b - (a % b);

                

                nPressedMin += nPressedThisTime;
            }

            Console.WriteLine(nPressedMin);
        }
    }
}


Measured memory_bytes: 7584
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int[][string] m;
    string s;
    while ((s = readln.chomp) != null) {
        auto ss = s.split;
        auto name = ss[0];
        auto page = ss[1].to!int;

        m[name] ~= page;
    }

    foreach (k; m.keys.sort) {
        writeln(k);
        auto v = m[k].sort.map!(to!string).array.join(" ");
        writeln(v);
    }

}

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

int main() {
	int n;
	cin >> n;
	vector<ll> l(n);
	rep(i, n) cin >> l[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				int a = l[i];
				int b = l[j];
				int c = l[k];
				if (a == b || b == c || c == a) continue;
				if (a + b > c && b + c > a && c + a > b) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var D = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(D);

            Console.WriteLine(D[N / 2] - D[N / 2 - 1]);
        }
    }
}

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int main()
{
    ll t;
    cin >> t;
    cin >> s;
    if(s.size() <= t) cout << s;
    else
    {
        for(ll i = 0;i < t;i ++) cout << s[i];
        cout << "...";
    }
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int r[100000];
int main() {
	int X;
	int K;
	cin >> X;
	cin >> K;
	rep(i, K) cin >> r[i];
	int Q;
	cin >> Q;
	int L = 0, R = X, C = 0;
	int j = 0;
	int prev = 0;
	rep(i, Q) {
		int t, a;
		cin >> t >> a;
		while (j < K&&r[j] <= t) {
			int T = r[j] - prev;
			if (j % 2 == 0) {
				if (T > C) L = min(L + (T - C), R);
				C = max(C - T, 0);
			}
			else {
				if (T > X - ((R - L) + C)) R = max(R - (T - (X - ((R - L) + C))), L);
				C = min(C + T, X);
			}
			prev = r[j];
			j++;
		}
		int T = t - prev;
		if (j % 2 == 0) {
			if (T > C) L = min(L + (T - C), R);
			C = max(C - T, 0);
		}
		else {
			if (T > X - ((R - L) + C)) R = max(R - (T - (X - ((R - L) + C))), L);
			C = min(C + T, X);
		}
		prev = t;
		if (a <= L) {
			cout << C << endl;
		}
		else if (R <= a) {
			cout << (R - L) + C << endl;
		}
		else {
			cout << (a - L) + C << endl;
		}
	}
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#define F(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define vi vector<int>
#define vll vector<long long>
#define pb(x) .push_back(x)
using namespace std;
void printVector(vector<int> v)
{
    char ch = ' ';
    for(int i=0;i<v.size();i++)
    {
        printf("%d",v[i]);
        printf("%c",ch);
    }

}


int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // int t; scanf("%d",t);
    // while(t--)
    // {
        
    // }
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x!=0)
    cout<<(n/x+1)*t;
    else
    {
        cout<<(n/x)*t;
    }
    
 return 0;
}

Measured memory_bytes: 3196
a, b, c = map(int, input().split())
sum = 0
# for i in range(1, 100):
#     sum += 3*i
#     print(sum % 7)
for n in range(1, b+1):
    sum += a
    if sum % b == c:
        print('YES')
        exit()
print('NO')


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

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

int main(){
    int N;
    cin >> N;
    map<int, int> R, B; //R's key is b, B's key is c
    rep(i, N){
        int a, b;
        cin >> a >> b;
        R[b] = a;
    }
    rep(i, N){
        int c, d;
        cin >> c >> d;
        B[c] = d;
    }

    int ans = 0;
    while(B.size() != 0){
        int c = (*B.begin()).first;
        int d = B[c];
        B.erase(c);

        int b = -1;
        for(auto i : R){
            if(i.first < d && i.second < c){
                b = i.first;
            }
        }

        if(b != -1){
            ans++;
            R.erase(b);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
($A,$B,$C)=glob<>;
if($A&1|$B&1|$C&1){
	print 0
}elsif($A==$B&$B==$C){
	print-1
}else{
	++$i,($A,$B,$C)=(($B+$C)/2,($C+$A)/2,($A+$B)/2)until$A&1|$B&1|$C&1;
	print$i
}


Measured memory_bytes: 768
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<VL> parts(3, VL(N));
  FOR(v, parts) {
    FOR(x, v) {
      cin >> x;
    }
    sort(v.begin(), v.end());
  }
  VL smaller(N);
  VL greater(N);
  int a = 0;
  REP(i,0,N) {
    ll b = parts[1][i];
    while(a < N && parts[0][a] < b) {
      a++;
    }
    smaller[i] = a;
  }
  int c = 0;
  for(int i = N-1; i>= 0; i--) {
    ll b = parts[1][i];
    while(c < N && parts[2][N-c-1] > b) {
      c++;
    }
    greater[i] = c;
  }
  ll ans = 0;
  REP(i,0,N) {
    ans += smaller[i] * greater[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4208
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation
#include <set>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

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

  
  set<int> P;
  int p;
  rep(i,N){
    cin >> p;
    P.insert(p);
  }
  
  int found = 0,ret = 0;
  if(N==0){
    ret = X;
    found = 1;
  }
  int sa = 0, nl, nr;
  while(!found){
    nl = X - sa;
    nr = X + sa;
    if(!P.count(nr)){
      ret = nr;
      found = 1;
    }
    if(!P.count(nl)){
      ret = nl;
      found = 1;
    }
    sa++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<i64> ccount(26);
  REP(i, N) { ccount[S[i] - 'a']++; }
  mint ans = 1;
  REP(i, 26) { ans *= ccount[i] + 1; }
  ans -= 1;
  cout << ans << endl;
}


Measured memory_bytes: 3712
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ERedScarf {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        int a[n],val=0;
        for (int i=0;i<n;i++){
            cin>>a[i];
            val^=a[i];
        }
        for (int i=0;i<n;i++){
            a[i]^=val;
            cout<<a[i]<<" ";
        }
	}
};


int main() {
	ERedScarf solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4416
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
from itertools import accumulate
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

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

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())
L = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

x = 1
for l in L:
    x = lcm(x, l)

print(x)

Measured memory_bytes: 64828
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
print(S[:len(S)-8])


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

using namespace std;

using int64 = long long;

bool ask(int x)
{
  cout << x << endl;
  string s;
  cin >> s;
  if(s[0] == 'V') exit(0);
  return (s[0] == 'M');
}

int main()
{
  int N;
  cin >> N;
  int low = 1, high = N - 2;
  auto L = ask(0), R = ask(N - 1);
  while(true) {
    int mid = (low + high) / 2;
    auto M = ask(mid);
    if((mid - low) % 2 == 1) {
      if(L == M) {
        low = mid + 1;
        L = M;
      } else {
        high = mid - 1;
        R = M;
      }
    } else {
      if(L != M) {
        low = mid + 1;
        L = M;
      } else {
        high = mid - 1;
        R = M;
      }
    }
  }
}



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

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i = min(a,b); i >= 1; i--){
        if(a%i == 0 && b%i == 0) cnt++;
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e6+9, M = (1<<31), OO = 0x3f3f3f3f;

int main()
{
  int p,q,r;
  scanf("%d%d%d",&p,&q,&r);
  printf("%d\n",min(p+q,min(q+r,r+p)));
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 256
d, g = map(int, input().split())
P, C = [], []
for i in range(d):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

num = float("inf")
for i in range(1 << d):
    cnt = 0
    rec = 0
    for j in range(d):
        if i & 1 << j:
            cnt += P[j]
            rec += P[j] * (j + 1) * 100
            rec += C[j]

    k = d - 1
    while k >= 0 and rec < g:
        if i & 1 << k:
            k -= 1
            continue
        else:
            q = 0
            while q < P[k] and rec < g:
                cnt += 1
                rec += (k + 1) * 100
                q += 1
        k -= 1

    if rec >= g:
        num = min(num, cnt)

print(num)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int H,W;
  cin >> H >> W;
  string s[H];
  REP(i,H){
    cin >> s[i];
  }
  int ss[H][W];
  REP(i,H){
    REP(j,W){
      ss[i][j] = 0;
    }
  }
  REP(i,H){
    REP(j,W){
      if(s[i][j] == '#'){
	
	if(i-1 >= 0){
	  if(j-1 >= 0){
	    ss[i-1][j-1]++;
	  }
	
	  ss[i-1][j]++;
	  
	  if(j+1 <= W-1)
	    ss[i-1][j+1]++;
	}
	
	if(j - 1 >= 0){
	  ss[i][j-1]++;
	  
	  
	  
	  
	  if(i+1 <= H-1)
	    ss[i+1][j-1]++;
	}
	if(j+1 <= W-1)
	  ss[i][j+1]++;
	if(i+1 <= H-1){
	  ss[i+1][j]++;
	
	}
	
	if(j+1 <= W-1 && i+1 <= H-1){
	ss[i+1][j+1]++;
	}
      }
      

    }
  }
  REP(i,H){
    REP(j,W){
      if(s[i][j] != '#'){
	cout << ss[i][j];
      }
      else{
	cout << '#';
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n, answer;
  cin >> n;
  int w[n], sum[n];
  cin >> w[0];
  sum[0] = w[0];
  for(int i = 1; i < n; i++){
    cin >> w[i];
    sum[i] = sum[i-1] + w[i];
  }
  answer = abs(sum[n-1] - sum[0] * 2);
  for(int i =1; i < n; i++){
    int temp = abs(sum[n-1] - sum[i] *2);
    if(temp < answer)
      answer = temp;
  }
  cout << answer;
}  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

ll r;
int k;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p) {
        int x = 0;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i);
            x++;
        }
        int y = k - x - 1 - (p >= 0);
        if (y < 0) {
            r = 0;
        } else {
            //cout << ((ll)f0[k - 1] * f1[k - x - 1] % P) << endl;
            r *= (ll)f0[y + x] * f1[y] % P;
            r %= P;
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n >> k;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    init(k);

    r = k;
    g.dfs(0, -1);

    cout << r << endl;

    //全ての頂点について近傍に同じ色がないようにする
    //葉ノードを選んで根としそこを塗るのはK通り 根は関係ないか
    //根を塗ってK通りで、子それぞれについて1色だけ封じられていて
    //子がx個あったら1+x個をK色で いや根は決まってる
    //(k-1)*(k-2)*...*(k-x)

    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll bubbleSort(vl &a,ll n){
    ll cnt=0;
    bool flg=1;
    while(flg){
        flg=0;
        rfore(i,1,n-1){
            if(a[i]<a[i-1]){
                cnt++;
                swap(a[i],a[i-1]);
                flg=1;
            }
        }
    }
    return cnt;
}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    ll cnt=bubbleSort(a,n);
    rep(i,n){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}

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



Measured memory_bytes: 3216
#include <stdio.h>

int main(){
  int N,A,B;
  scanf("%d%d%d",&N,&A,&B);
  
  int train=0,taxi=0;
  train = N * A;
  taxi = B;
  printf("%d",min(train,taxi));
}

int min(int a, int b){
  if(a>=b){
    return b;
  }else{
    return a;
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> ame(2, vector<int>(n, 0));
    for(int i=0;i<2;i++)
        for(int j=0;j<n;j++){
            cin >> ame[i][j];
        }

    vector<vector<int>> dp(2, vector<int>(n, 0));
    dp[0][0] = ame[0][0];

    for(int i=1;i<n;i++){
        dp[0][i] = dp[0][i-1] + ame[0][i];
    }
    dp[1][0] = dp[0][0] + ame[1][0];
    for(int i=1;i<n;i++){
        dp[1][i] = max(dp[1][i-1], dp[0][i]) + ame[1][i];
    }

    cout << dp[1][n-1] << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define inf 1000000007
int main(){
    int n;
    cin >> n;
    int max_distance = -inf;
    int R_min;
    cin >> R_min;
    int R_curr;
    
    for(int i=1;i<n;i++){
        cin >> R_curr;
        if(max_distance<R_curr-R_min) max_distance = R_curr-R_min;
        if(R_min>R_curr)R_min = R_curr;
    }
    cout << max_distance << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int>> dp(5010, vector<int>(5010));
    dp[n-1][n-1] = 1;
    for (int i = n-1; i >= 0; i--)
    {
        for (int j = n-1; j >= 0; j--)
        {
            if(s[i] == s[j]){
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            ans = max(ans, min(dp[i][j], j-i));
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98560
#include<stdio.h>
#include<math.h>

int operate(int a, int b, int op){
	switch(op){
	case 0:
		return a+b;
	case 1:
		return a-b;
	case 2:
		return a*b;
	default:
		return 0;
	}
}

char opchar(int op){
	switch(op){
	case 0:
		return '+';
	case 1:
		return '-';
	case 2:
		return '*';
	default:
		return 0;
	}
}

int solve(const int* a){
	int op, brace;
	int rslt;
	int success=0;
	int i,j,k,l;

	for(i=0;i<4;++i){
		for(j=0;j<4;++j){
			if(j==i) continue;
			for(k=0;k<4;++k){
				if(k==i || k==j) continue;
				for(l=0;l<4;++l){
					if(l==i || l==j || l==k) continue;

					for(brace=0;brace<5;++brace){
						for(op=0;op<27;++op){
							switch(brace){
							case 0:
								rslt=operate(operate(operate(a[i],a[j],op%3),a[k],(op/3)%3),a[l],(op/9)%3);
								if(rslt==10){
									success=1;
									printf("( ( %d %c %d ) %c %d ) %c %d\n", a[i],opchar(op%3),a[j],opchar((op/3)%3),a[k],opchar((op/9)%3),a[l]);
								}
								break;
							case 1:
								rslt=operate(operate(a[i],operate(a[j],a[k],(op/3)%3),op%3),a[l],(op/9)%3);
								if(rslt==10){
									success=1;
									printf("( %d %c ( %d %c %d ) ) %c %d\n", a[i],opchar(op%3),a[j],opchar((op/3)%3),a[k],opchar((op/9)%3),a[l]);
								}
								break;
							case 2:
								rslt=operate(operate(a[i],a[j],op%3),operate(a[k],a[l],(op/9)%3),(op/3)%3);
								if(rslt==10){
									success=1;
									printf("( %d %c %d ) %c ( %d %c %d )\n", a[i],opchar(op%3),a[j],opchar((op/3)%3),a[k],opchar((op/9)%3),a[l]);
								}
								break;
							case 3:
								rslt=operate(a[i],operate(operate(a[j],a[k],(op/3)%3),a[l],(op/9)%3),op%3);
								if(rslt==10){
									success=1;
									printf("%d %c ( ( %d %c %d ) %c %d )\n", a[i],opchar(op%3),a[j],opchar((op/3)%3),a[k],opchar((op/9)%3),a[l]);
								}
								break;
							case 4:
								rslt=operate(a[i],operate(a[j],operate(a[k],a[l],(op/9)%3),(op/3)%3),op%3);
								if(rslt==10){
									success=1;
									printf("%d %c ( %d %c ( %d %c %d ) )\n", a[i],opchar(op%3),a[j],opchar((op/3)%3),a[k],opchar((op/9)%3),a[l]);
								}
								break;
							}
							if(success) return;
						}
					}
				}
			}
		}
	}
	printf("0\n");
	return;
}


int main(){
	int a[4];
	int i,j,k,l;
	char buf[32];

	while(1){
		fgets(buf,31,stdin);
		sscanf(buf,"%d %d %d %d", a,a+1,a+2,a+3);
		if(!(a[0] || a[1] || a[2] || a[3]))break;
		solve(a);
	}


	return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N;  cin >> N;

	ROP(h, 3500){
		ROP(n, 3500){
			if((4*h*n - N*n - N*h) > 0 && N*h*n % (4*h*n - N*n - N*h) == 0){
				cout << h << " " << n << " " << N*h*n / (4*h*n - N*n - N*h) << endl;
				return 0;
			}
		}
	}


	return 0;
}

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

string G(string s, int a, int b) {
    string ret = "";
    for (int i=0; i<(int)s.size(); ++i) {
        if (s[i] == ' ') {
            ret += ' ';
        } else {
            ret += char('a' + (a * ((s[i] - 'a') + b)) % 26);
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    string s;
    while (n) {
        getline(cin, s);
        if (s.size() == 0) continue;
        n --;
        string ans = "";
        for (int a=1; a<26; ++a) {
            if (a % 2 == 0 || a % 13 == 0) continue;
            for (int b=0; b<26; ++b) {
                string t = G(s, a, b);
                if (t.find("this") != string::npos || t.find("that") != string::npos) {
                    ans = t;
                    break;
                }
            }
            if (ans != "") break;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(void){
    int n, d, x;
    std::cin >> n;
    std::cin >> d >> x;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++) std::cin >> a[i];

    int sum = n;
    for(int i = 0; i < n; i++){
        int couter = 1;
        while(couter*a[i] + 1 <= d){
            sum++;
            couter++;
        }
    }

    std::cout << sum + x;
    return 0;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
import sys
sys.setrecursionlimit(10**7)

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))
# ---
N, M = mii()
edge = defaultdict(list)
memo = defaultdict(int)
done = defaultdict(bool)


def dp(v):
    if done[v]:
        return memo[v]
    ret = 0
    for to in edge[v]:
        ret = max(ret, dp(to) + 1)
    done[v] = True
    memo[v] = ret
    return ret


for i in range(M):
    x, y = mii()
    edge[x].append(y)
ans = 0
for v in range(1, N+1):
    ans = max(ans, dp(v))

print(ans)



Measured memory_bytes: 87404
sx,sy,tx,ty = map(int,input().split())

dx=tx-sx
dy=ty-sy

s="U"*dy+"R"*dx+"D"*dy+"L"*(dx+1)+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"

print(s)

Measured memory_bytes: 9156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String X = sc.next();
		String Y = sc.next();
		
		if(X.compareTo(Y) > 0) {
			System.out.println(">");
		} else if(X.compareTo(Y) == 0) {
			System.out.println("=");
		} else {
			System.out.println("<");
		}
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string u;
  rep(i, n) { u += s[i]; u += t[i]; }
  cout << u << endl;
}


Measured memory_bytes: 256
def main():
    s = str(input())
    N = int(input())
    l = len(s)
    string = []
    for i in range(l):
        for j in range(min(5,l-i)):
            a = s[i:i+j+1]
            string.append(a)

    string = list(set(string))
    string.sort()
    print(string[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 5068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int,int> P;

int main(){
    int n;
    
    while(cin >> n,n){
        vector<P> v;
        int sh,sm,ss,th,tm,ts,Max=0,Min = 99999,totals,totalt;
        for(int i = 0 ; i < n ; i++){
            scanf("%d:%d:%d" ,&sh , &sm , &ss);
            totals = sh*3600+sm*60+ss;
            v.push_back(P(totals,1));
            scanf("%d:%d:%d" ,&th , &tm , &ts);
            totalt = th*3600+tm*60+ts;
            v.push_back(P(totalt,-1));
        }
        sort(v.begin(),v.end());
    
        int ans = 0,tmp = 0;
        for(int i = 0 ; i < v.size() ; i++){
                tmp += v[i].second;
                ans = max(ans,tmp);
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1496
#include <iostream>
using namespace std;
string s;
long long n,ans,t;
int main(void){
    cin>>s;
    n=s.size();
    t=n-1;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='B'){
            ans+=t-i;
            t--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
# coding:utf-8
import sys

def main():
    a,b = map(int, input().split())
    count = 1
    cosuu = 0

    if b == 1:
        print(0)
        sys.exit()

    while count < b:
        count += a
        count = count - 1
        cosuu += 1
    print(cosuu)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060