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

public class Main {

	private static final BigDecimal BORROWING = BigDecimal.valueOf(100000);
	private static final BigDecimal RATE = new BigDecimal("1.05");
	private static final int SCALE = 3;
	
	public static void main(String[] args) throws Exception{
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		scan.close();
		System.out.println(calc(BORROWING, RATE, n).toPlainString());
	}
	
	private static BigDecimal calc(BigDecimal start, BigDecimal rate, int n){
		BigDecimal ans = start;
		for (int i = 0; i < n; i++) {
			ans = calcParWeek(ans, rate);
		}
		return ans;
	}
	

	private static BigDecimal calcParWeek(BigDecimal start, BigDecimal rate){
		
		return start.multiply(RATE).movePointLeft(SCALE).setScale(0, RoundingMode.UP)
				.movePointRight(3);
		
	}

}

Measured memory_bytes: 17224
from collections import deque
n,m=map(int,input().split())
l=[[] for i in range(n+1)]
lb=[[] for i in range(n+1)]
d0={}#gから逆走して3の倍数回でいけるか
d1={}
d2={}
for i in range(n):
  d1[i+1],d2[i+1],d0[i+1]=0,0,0
for i in range(m):
  a,b=map(int,input().split())
  l[a].append(b)
  lb[b].append(a)
s,t=map(int,input().split())
q0=deque([t])
q1=deque([])
q2=deque([])
bool1=True
now=0
ans=-1
while q0 or q1 or q2:
  if now%3==0:
    while q0:
      a=q0.popleft()
      d=lb[a]
      for i in d:
        if d1[i]==1:
          pass
        else:
          d1[i]=1
          q1.append(i)
  elif now%3==1:
    while q1:
      a=q1.popleft()
      d=lb[a]
      for i in d:
        if d2[i]==1:
          pass
        else:
          d2[i]=1
          q2.append(i)
  elif now%3==2:
    while q2:
      a=q2.popleft()
      d=lb[a]
      for i in d:
        if i==s and bool1:
          ans=(now+1)//3
          bool1=False
        if d0[i]==1:
          pass
        else:
          d0[i]=1
          q0.append(i)
  now=now+1
print(ans)

Measured memory_bytes: 63268
<?php
$N = intval(trim(fgets(STDIN)));

$W = [];
for ($i = 0; $i < $N; $i++) {
    array_push($W,trim(fgets(STDIN)));
}

# 重複チェック
# array_uniqueがどの程度の速度のものかは調べてない
# けど、処理対象のサイズがせいぜい１００件なので、多分大丈夫
if ($W !== array_unique($W)){
    die('No');
}

# 繋がってるかチェック
for ($i = 1; $i < $N; $i++) {
    // 繋がってるかチェック
    if (substr($W[$i - 1], -1, 1) !== substr($W[$i], 0, 1)) {
        die('No');
    }
}

echo 'Yes';
?>


Measured memory_bytes: 4604
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
	int N;
	cin >> N;
	vector<int> Ais;
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;
		Ais.push_back(Ai);
	}
	sort(Ais.begin(), Ais.end());
	vector<int> add;
	vector<int> subtract;
	for (int i = 0; i < Ais.size(); i++) {
		int Ai = Ais[i];
		if (i == 0) {
			subtract.push_back(Ai);
		} else if (i == Ais.size() - 1) {
			add.push_back(Ai);
		} else {
			if (Ai >= 0) {
				add.push_back(Ai);
			} else {
				subtract.push_back(Ai);
			}
		}
	}
	int add_sum = 0;
	for (int n : add) {
		add_sum += n;
	}
	int subtract_sum = 0;
	for (int n : subtract) {
		subtract_sum += n;
	}
	cout << add_sum - subtract_sum << endl;
	int value = 0;
	if (add.size() >= 2) {
		value = subtract.back();
		subtract.pop_back();
		while (add.size() >= 2) {
			cout << value << " " << add.back() << endl;
			value = value - add.back();
			add.pop_back();
		}
		cout << add.back() << " " << value << endl;
		value = add.back() - value;
	} else {
		value = add[0];
	}
	while (subtract.size() > 0) {
		cout << value << " " << subtract.back() << endl;
		value = value - subtract.back();
		subtract.pop_back();
	}
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  int d=0;
  for(int i=1; i<N; i++){
    if(S[i]=='E'){
      d++;
    }
  }
  int m=d;
  
  for(int i=1; i<N; i++){
    if(S[i-1]=='W'){
      d++;
    }
    if(S[i]=='E'){
      d--;
    }
    m=min(m,d);
  }
  cout << m << endl;
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> button(n);
    for (int i = 0; i < n; i++){
        cin >> button[i];
        button[i]--;
    }
    long long x = 0;
    long long flag = 0;
    while(true){
        if (x == 1){
            cout << flag << endl;
            return 0;
        }
        x = button[x];
        flag++;
        if (flag > n){
            cout << -1 << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    if(!S.substring(0, 1).equals("A")){
      System.out.println("WA");
    } else if(!S.substring(2, S.length()-1).contains("C")) {
      System.out.println("WA");
    } else  {
      String newS = S.substring(1, S.length()).replaceFirst("C", "c");
      if(!newS.equals(S.substring(1, S.length()).toLowerCase())) {
        System.out.println("WA");
      } else {
        System.out.println("AC");
      }
    } 
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S[0]==S[1] && S[1] !=S[2] && S[2]==S[3] ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
  string str;
  cin>>str;
  int i = 0;
  if(str[0] == 'R') i++;
  if(str[1] == 'R') i++;
  if(str[2] == 'R') i++;
  if(i != 2)
    cout<<i<<"\n";
  else
  {
    if(str[1] == 'S')
      cout<<1<<"\n";
    else
      cout<<2<<"\n";
  }
}
  
  

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

typedef pair<int, int> P;

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

  int n = s.size();
  stack<int> st;
  int sum = 0;
  vector<int> rs(n+1, -1);
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == '\\' ) {
      st.push(i);
    } else if ( s[i] == '/' && st.size() ) {
      int p = st.top(); st.pop();
      sum += i-p;
      rs[p] = i;
    }
  }

  vector<int> pools;
  int sum2 = 0;
  int l = 0, r = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( rs[i] == -1 ) continue;
    if ( rs[i] < r ) sum2 += rs[i]-i;
    else {
      if ( sum2 ) pools.push_back(sum2);
      sum2 = rs[i]-i;
      l = i; r = rs[i];
    }
  }

  if ( sum2 ) pools.push_back(sum2);

  cout << sum << endl;
  cout << pools.size();
  for ( int i: pools ) cout << " " << i;
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[100010];
vector<int> vec[100010];
vector<int> ve[100010];
vector<int> vec2;
bool bl[100010];
int ans;

void dfs(int v, int k) {
	bl[v] = true;
	ve[k].push_back(a[v]);
	for (int i = 0; i < (int)vec[v].size(); i++) {
		if (!bl[vec[v][i]])dfs(vec[v][i], k);
	}
}

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	int kk = 0;
	for (int i = 0; i < n; i++) {
		if (!bl[i]) {
			kk++;
			dfs(i, kk);
		}
	}
	if (n < (kk - 1) * 2) {
		cout << "Impossible" << endl;
		return 0;
	}
	if (kk == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= kk; i++) {
		sort(all(ve[i]));
		ans += ve[i][0];
		for (int j = 1; j < (int)ve[i].size(); j++)vec2.push_back(ve[i][j]);
	}
	sort(all(vec2));
	for (int i = 0; i < kk - 2; i++)ans += vec2[i];
	cout << ans << endl;
}

Measured memory_bytes: 11768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    cout << 1 - n << endl;
}

Measured memory_bytes: 3632
import sys

N = int(sys.stdin.readline().strip())
vs = [int(a) for a in sys.stdin.readline().strip().split(" ")]

M = 1000000000 + 7

ret = 0
sum = 0
for j in range(1, N):
    sum += vs[j - 1]
    ret += (vs[j] * sum) % M
    ret = ret % M
print(ret)


Measured memory_bytes: 31756
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;


int main() 
{	
	int dp[1001][1001];
	char A[1001][1001];
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> A[i][j];
		}
	}
	memset(dp, 0, sizeof(dp));
	dp[0][1] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if(A[i][j] != '#')
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
			else
				dp[i][j] = 0;
		}
	}
	cout << dp[n][m];
}

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

int main(){
    ll n;
    cin >> n;
    ll minf = 10000000000;
    ll k = 1;
    while(k * k <= n){
        if (n%k == 0){
            ll x = max(to_string(n/k).size(), to_string(k).size());
            minf = min(minf, x);
        }
        k ++;
    }
    cout << minf << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    N %= 10;
    if (N == 0 || N == 1 || N == 6 || N == 8) print("pon");
    else if (N == 3) print("bon");
    else print("hon");
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc168/abc168_a && sh shellscripts/submit_cpp.sh
*/


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

int main(){
    int a, b, x; cin >> a >> b >> x;
    if(2*x >= a*a*b){
        cout << fixed << setprecision(8) << atan(2.0*(b-x/(1.0*a*a))/(1.0*a))*180/M_PI << endl;
    }else{
        cout << fixed << setprecision(8) << atan((1.0*a*b*b)/(2.0*x))*180/M_PI << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int k, s;
  cin >> k >> s;

  int res = 0;

  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <=k; ++y) {
      int z = s - x - y;

      if (z >= 0 && z <= k) res++;
    }
  }
  
  cout << res << "\n";
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

inline int f(int n, int i, int L, const vector<int>& sum_rev){
    return (sum_rev[i - n] - sum_rev[i]) + L * (n - 1);
}

int dp[50010];
int sum_dp[50010];

int main(){
    int W, N;
    while(cin >> W >> N && N){
        vector<int> x(N);
        REP(i, N) cin >> x[i];

        vector<int> sum_rev(N + 1);
        sum_rev[N] = 0;
        for(int i = N - 1; i >= 0; i--){
            sum_rev[i] = sum_rev[i + 1] + x[i];
        }

        int lb_L = 0, ub_L = W; // ub
        while(ub_L - lb_L > 1){
            int L = (lb_L + ub_L) / 2;
            dp[0] = 1;
            dp[1] = 0;
            sum_dp[1] = 1;
            sum_dp[2] = 1;

            for(int i = 2; i < N; i++){
                dp[i] = 0;
                sum_dp[i] = sum_dp[i - 1] + dp[i - 1];
 
                int lb = 1, ub = min(i, (W + L)/(L + 1) + 1); // ub  true ??
                while(ub - lb > 1){
                    int n = (ub + lb) / 2;
                    if(f(n, i, L, sum_rev) >= W){
                        ub = n;
                    }else{
                        lb = n;
                    }
                }
                int begin_n = ub;

                //printf("dp[%d] : begin %d \n", i, begin_n);
                if(f(begin_n, i, L, sum_rev) < W){
                    continue;
                }

                lb = begin_n, ub = i + 1; // lb
                while(ub - lb > 1){
                    int n = (ub + lb) / 2;
                    if(f(n, i, 1, sum_rev) <= W){
                        lb = n;
                    }else{
                        ub = n;
                    }
                }
                int end_n = lb; 

                //printf("dp[%d] : end %d \n", i, end_n);
                if(f(end_n, i, 1, sum_rev) > W) {
                    continue;
                }

                int begin = i - end_n;
                int end = i - begin_n;
                // [begin, end]
                if(sum_dp[end + 1] - sum_dp[begin] > 0){
                    dp[i] = 1;
                }
                //printf("dp[%d] : [dp[%d], dp[%d]] (%d) -> %d\n", i, begin, end, sum_dp[end + 1] - sum_dp[begin], dp[i]);
            }

            bool ok = false;
            for(int n = 1; n <= N && (n - 1) + sum_rev[N - n] <= W; n++) {
                //printf("n - 1 + sum_rev[%d] = %d\n", i, n - 1 + sum_rev[i]);
                if(dp[N - n]){
                    ok = true;
                    break;
                }
            }
            //printf("L %d  is %d\n", L, ok);

            if(ok){
                ub_L = L;
            }else{
                lb_L = L;
            }
        }

        cout << ub_L << endl;
    }
    return 0;
}

Measured memory_bytes: 1836
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;

int main() {
  Int n;
  cin >> n;
  vector<Int> a(n);
  for (Int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  if (n % 2 == 0) {
    Int res = 0;
    for (Int i = 0; i < n; i++) {
      if (i < n / 2) {
        res -= a[i] * 2;
      }
      else {
        res += a[i] * 2;
      }
    }
    dump(res + a[n / 2 - 1] - a[n / 2]);
  }
  else {
    Int res1 = 0;
    Int res2 = 0;
    for (Int i = 0; i < n; i++) {
      if (i < n / 2) {
        res1 -= a[i] * 2;
      }
      else {
        res1 += a[i] * 2;
      }
    }
    res1 -= a[n / 2] + a[n / 2 + 1];
    for (Int i = 0; i < n; i++) {
      if (i <= n / 2) {
        res2 -= a[i] * 2;
      }
      else {
        res2 += a[i] * 2;
      }
    }
    
    res2 += a[n / 2] + a[n / 2 - 1];
   //  cout << res1 << " " << res2 << endl;
    dump(max(res1, res2));
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
using namespace std;


const int N = 3e5 + 10;
ll n, m;
bool vis1[200], vis2[200];
string str[200];

void check(ll a) {
    bool ok = true;
    char c = '.';
    for (int j = 0; j < m; j++) {
        if (str[a][j] != c) {
            ok = false;
            break;
        }
    }
    if (ok) vis1[a] = 1;
}

void check1(ll a) {
    bool ok = true;
    char c = '.';
    for (int j = 0; j < n; j++) {
        if (str[j][a] != c) {
            ok = false;
            break;
        }
    }
    if (ok) vis2[a] = 1;
}

int main(int argc, char** argv) {
    cin >> n>>m;
    for (int i = 0; i < n; i++) {
        cin >> str[i];
    }
    for (int i = 0; i < n; i++)check(i);
    for (int i = 0; i < m; i++)check1(i);
    for (int i = 0; i < n; i++) {
        if (vis1[i])continue;
        bool ok = false;
        for (int j = 0; j < m; j++) {
            if (vis2[j])continue;
            else cout << str[i][j], ok = true;
        }
        if (ok)
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
	int a[10][10];
	bool b[10][10];
	for0(i, 9)for0(j, 9) { cin >> a[i][j]; b[i][j] = 1; }
	int cnt[11];
	for0(i, 9) {
		for1(j, 9)cnt[j] = 0;
		for0(j, 9)cnt[a[i][j]]++;
		for0(j, 9)if (cnt[a[i][j]] > 1)b[i][j] = 0;
	}
	for0(j, 9) {
		for1(i, 9)cnt[i] = 0;
		for0(i, 9)cnt[a[i][j]]++;
		for0(i, 9)if (cnt[a[i][j]] > 1)b[i][j] = 0;
	}
	for0(x, 9) {
		for1(i, 9)cnt[i] = 0;
		for0(y, 9)cnt[a[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3]]++;
		for0(y, 9)if (cnt[a[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3]] > 1)b[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3] = 0;
	}
	for0(i, 9) {
		for0(j, 9)cout << (b[i][j] ? ' ' : '*') << a[i][j];
		cout << endl;
	}
}
signed main() {
	int q; cin >> q; while (q--) { solve(); if (q >= 1)cout << endl; }
}


Measured memory_bytes: 3072
import math
n = int(input())
a = list(map(int, input().split()))

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a
r = [0] * (n+1)
sosu = [False for i in range(10**6+1)]

for i in range(n):
  r[i+1] = math.gcd(r[i],a[i])
if r[-1] != 1:
  print ('not coprime')
  exit()

for i in range(n):
  ary = set(prime_factorize(a[i]))
  for j in ary:
    if sosu[j]:
      print ('setwise coprime')
      exit()
    sosu[j] = True
print ('pairwise coprime')

Measured memory_bytes: 226920
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;


int main(){
	//freopen("in.txt", "r", stdin);
    int x,a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll N;
    cin >> N;
    ll M = N - 1;
    ll ans = 0;
    for(ll i = 1; i * i <= M; i++) {
        if(M % i == 0) ans += (i * i == M ? 1 : 2);
    }

    for(ll i = 2; i * i <= N; i++) {
        if(N % i) continue;
        ll n = N;
        while(n % i == 0)
            n /= i;
        if(n % i == 1) ans++;
        n = N;
        ll j = N / i;
        if(j == i) continue;
        while(n % j == 0)
            n /= j;
        if(n % j == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m=map(int, input().split())
h=list(map(int, input().split()))
 
t=[0]*n
 
for i in range(m):
    a, b=map(int, input().split())
 
    t[a-1]=max(t[a-1], h[b-1])
    t[b-1]=max(t[b-1], h[a-1])
 
ans=0
 
for i in range(n):
    if h[i]>t[i]:
        ans+=1
 
print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin >>n;
    bool flg=true;
    for (int i = 0; i < n; ++i) {
        int a;cin >>a;
        if(a%2==1)flg=false;
    }
    if(flg)puts("second");
    else puts("first");
}


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CManagement {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n-1) {
        int b; cin >> b;
        b--;
        a[b]++;
      }
      rep(i, n) {
        cout << a[i] << '\n';
      }
    }
};

signed main() {
  CManagement solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int a=1;
  // ここにプログラムを追記
  for (int i = 0; i < N; i++){
    if(i<N-1){if(S.at(i)!=S.at(i+1)) a++;}
  }
  cout << a << endl; 
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pi pair<ll,ll>
#define mp make_pair
#define srtin1 cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
#define strin2 getline(cin, text);
#define fi first
#define se second
#define pb push_back
#define mod (ll)1000000007
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mxn 311111
#define mxn2 1111111
#define test cout<<"vaibhav";
#define dd double
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0; i<n; ++i){
            cin >> a[i];
    }
    vector<int>ans;
    while(a.size()>0){
        int f=0;
        for(int i=a.size()-1; i>=0; --i){
                if(a[i] == i+1){
                    ans.pb(i+1);
                    a.erase(a.begin() + i);
                    f=1;
                    break;
                }
        }
        if(!f && a.size()){
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    for(int i=0; i<n; ++i)cout << ans[i] << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

ll solve(int n, int k, vector<int> const & t, vector<ll> const & d) {
    map<int, int> max_d;
    REP (i, n) {
        if (not max_d.count(t[i]) or d[max_d[t[i]]] < d[i]) {
            max_d[t[i]] = i;
        }
    }

    reversed_priority_queue<pair<ll, int> > que;
    ll sum = 0;
    for (auto it : max_d) {
        int i = it.second;
        que.emplace(d[i], i);
        sum += d[i];
    }
    int que_size = que.size();

    vector<bool> used(n);
    int cnt_used = 0;
    auto update_que = [&]() {
        while (que_size > k) {
            assert (not que.empty());
            int i = que.top().second;
            que.pop();
            if (used[t[i]]) continue;
            -- que_size;
            sum -= d[i];
        }
    };

    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) {
        return d[i] > d[j];
    });

    ll answer = 0;
    ll acc = 0;
    for (int i : order) {
        if (not k) break;
        if (not used[t[i]]) {
            // use i trivially
            acc += d[i];
            sum -= d[i];
            used[t[i]] = true;
            ++ cnt_used;
            -- que_size;
            -- k;

        } else {
            // ignore i
            update_que();
            chmax(answer, acc + sum + (ll)(cnt_used + que_size) * (cnt_used + que_size));

            // use i
            acc += d[i];
            -- k;
        }
    }
    update_que();
    chmax(answer, acc + sum + (ll)(cnt_used + que_size) * (cnt_used + que_size));
    return answer;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> t(n);
    vector<ll> d(n);
    REP (i, n) {
        cin >> t[i] >> d[i];
        -- t[i];
    }
    cout << solve(n, k, t, d) << endl;
    return 0;
}


Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 100000000
#define N 10000
ll tra[10000];

int main()
{
    ll t;
    cin>>t;
    ll sum=0;
    map<ll,ll>mp;
    for(int i=0;i<t-1;i++)
    {
        ll a;
        cin>>a;
       mp[a]++;
    }
    for(int i=1;i<=t;i++)
    {
        cout<<mp[i]<<endl;
    }

}


Measured memory_bytes: 16132
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
const Int INF = 1e17;
struct edge{
  Int w,u,v,to;
  edge(){}
  edge(Int w,Int u,Int v,Int to):w(w),u(u),v(v),to(to){}
  bool operator<(const edge &a)const{
    if(w!=a.w) return w<a.w;
    if(u!=a.u) return u<a.u;
    return v<a.v;
  }
};
struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(Int n):n(n),r(n,1),p(n){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    if(x==p[x]) return x;
    return p[x]=find(p[x]);
  }
  Int same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=p[x];
  }
};
struct LowLink{
  Int n,cnt;
  vector<vector<edge> > G;
  vector<Int> sum,used,pre,low,par;
  
  LowLink(Int n):n(n),cnt(0),G(n),sum(n),used(n),pre(n),low(n),par(n){}

  void add_edge(Int u,Int v,Int w){
    G[u].emplace_back(w,u,v,v);
    G[v].emplace_back(w,u,v,u);
  }

  void dfs(Int v,Int p,Int d=0){
    pre[v]=low[v]=d;
    used[v]=1;
    for(auto e:G[v]){
      Int u=e.to;
      if(!used[u]){
	par[u]=v;
	dfs(u,v,d+1);
	low[v]=min(low[v],low[u]);
	sum[v]+=sum[u]+e.w;
      }else if(u!=p){
	low[v]=min(low[v],pre[u]);
        sum[u]+=e.w;
      }      
    }
  }
};



signed main(){
  Int n;
  cin>>n;
  LowLink G(n);
  for(Int i=0;i<n;i++){
    Int u,v;
    cin>>u>>v;
    u--;v--;
    G.add_edge(u,v,0);
  }
  UnionFind uf(n);
  G.dfs(0,-1);

  using P = pair<Int, Int>;
  set<P> br;
  for(Int i=1;i<n;i++)
    if(G.low[i]==G.pre[i]) br.emplace(i,G.par[i]),br.emplace(G.par[i],i);
  
  for(Int v=0;v<n;v++){
    for(auto e:G.G[v]){
      Int u=e.to;
      if(!br.count(P(u,v))) uf.unite(u,v);
    }
  }
    
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    if(uf.same(a,b)) cout<<2<<endl;
    else cout<<1<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 36348
/*..............Bismillahir Rahmanir Rahim.............*/
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

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

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

inline int Int(){int x ; scanf("%d",&x) ; return x ;}
inline ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
inline float Float(){float x ; scanf("%f",&x) ; return x ;}
inline double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mp          make_pair
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     pie         acos(-1.0)
#define     Fast_Read   ios_base::sync_with_stdio(false); cin.tie(nullptr);  cout.tie(nullptr);

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/


inline void Yes(){printf("Yes\n");}
inline void No(){printf("No\n");}
inline void YES(){printf("YES\n");}
inline void NO(){printf("NO\n");}

int main(){
    //Fast_Read
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    string ch;
    while(test--){
        cin >> ch;
        if(ch[2] == ch[3] and ch[4] ==  ch[5]) Yes();
        else No();
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define fi first
#define se second
#define esp 1e-15
#define inf 1000000001
#define mod 1000000007
#define N 1000010
#define base 311097
typedef long long ll;
typedef long double ld;
const long long oo = (ll)1e18;
using namespace std;
int n, m;
string a[55];
string b[55];

bool check(int x, int y) {

    for (int i = 0; i < m; i++)
        for (int j = 0; j < m; j++) {
            if (a[x + i][y + j] != b[i][j]) return false;

         //   cout << a[x + i][y + j] << " " << b[i][j] << "\n";
        }
    return true;
}

int main() {
   //  freopen("in.in", "r", stdin);

  //  freopen("in2.in", "r", stdin);
   // freopen("ou.ou", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    for (int i = 0; i < n - m + 1; i++)
        for (int j = 0; j < n - m + 1; j++)
            if (check(i, j)) {
                //cout << i << " " << j << "\n";

                cout << "Yes";
                return 0;
            }
    cout << "No";

    /**/ return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 998244353;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    com_init();
    ll n, m, k; cin >> n >> m >> k;
    ll sum = 0;
    ll x = mul_mod(m, pow_mod(m - 1, n - (k + 1)));
    rep (i, n - (k + 1), n) {
        sum = mod(sum + mul_mod(x, com_mod(n - 1, i)));
        x = mul_mod(x, m - 1);
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 73936
#include <cstdio>           // printf(), scanf()

#define MAX_N 100
using namespace std;

static const int INF = 100000000;
static const double EPS = 1e-10;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point
{
public:
	int x, y;

	Point(int x = 0, int y = 0): x(x), y(y) {}
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
};

typedef Point Vector;

Point ps[MAX_N];
int n;

double
norm(Vector a)
{
	return a.x * a.x + a.y * a.y;
}

double
dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}

double
cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

int
ccw(Point p0, Point p1, Point p2)
{
	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;

	if (cross(a, b) < -EPS)
		return CLOCKWISE;

	if (dot(a, b) < -EPS)
		return ONLINE_BACK;

	if (norm(a) < norm(b))
		return ONLINE_FRONT;

	return ON_SEGMENT;
}

bool
solve()
{
	if (n == 3)
		return true;

	int dir = INF;
	int i = 0;
	do {
		int t = ccw(ps[i % n], ps[(i + 1) % n], ps[(i + 2) % n]);
		i = (i + 1) % n;
		if (dir == INF && (t == COUNTER_CLOCKWISE || t == CLOCKWISE))
		{
			dir = t;
			continue;
		}

		if (t != ONLINE_FRONT && dir != t)
			return false;

	} while (i != 0);

	return true;
}

int
main(int argc, char** argv)
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d %d", &ps[i].x, &ps[i].y);

	printf("%d\n", solve() ? 1 : 0);
	return 0;
}

Measured memory_bytes: 2748
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int is_valid(int k, int W){
	int i;
	for(i = 0; i < W - 2; i++){
		if(((k | (1 << i)) == k) && ((k | (1 << (i + 1))) == k)){
			return 0;
		}
	}
	return 1;
}

signed main(){
	int H, W, K, i, j, k;
	scanf("%lld%lld%lld", &H, &W, &K);
	int **dp = (int **)malloc(sizeof(int *) * (H + 1));
	for(i = 0; i <= H; i++){
		dp[i] = (int *)malloc(sizeof(int) * W);
		for(j = 0; j < W; j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(i = 1; i <= H; i++){
//		printf("i = %lld\n", i);
		for(k = 0; k < (1 << (W - 1)); k++){
//			printf("k = %lld\n", k);
			if(is_valid(k, W) == 1){
				for(j = 0; j < W; j++){
//					printf("j = %lld\n", j);
					if((k | (1 << j)) == k){
						if(j < W - 1){
							dp[i][j] = MOD(dp[i][j] + dp[i - 1][j + 1]);
						}
					}
					else if((k | (1 << (j - 1))) == k){
						if(j > 0){
							dp[i][j] = MOD(dp[i][j] + dp[i - 1][j - 1]);
						}
					}
					else{
						dp[i][j] = MOD(dp[i][j] + dp[i - 1][j]);
					}
				}
			}
		}
	}
/*	for(i = 0; i <= H; i++){
		for(j = 0; j < W; j++){
			printf("%lld ", dp[i][j]);
		}
		printf("\n");
	}
*/	printf("%lld\n", dp[H][K - 1]);
	return 0;
}

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

int n, t;

int main(){
	scanf("%d%d", &n, &t);
	int now = 0, ans = 0;
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		if (now + t < x){
			ans += t;
		}
		else{
			ans += x - now;
		}
		now = x;
	}
	return printf("%d\n", ans + t), 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    SORT(a);
    if (a[0] == a[1] && a[1] != a[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    SORT_INV(a);
    if (a[0] == a[1] && a[1] != a[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> points(n, vector<int>(3));
    for(int i = 0; i < n; ++i){
        cin >> points[i][0] >> points[i][1] >> points[i][2];
    }
  	int dp_a, dp_b, dp_c;
    dp_a = points[0][0];
    dp_b = points[0][1];
    dp_c = points[0][2];
    for(int i = 1; i < n; ++i){
        int curr_a, curr_b, curr_c;
        curr_a = max(dp_b, dp_c) + points[i][0];
        curr_b = max(dp_a, dp_c) + points[i][1];
        curr_c = max(dp_a, dp_b) + points[i][2];
        dp_a = curr_a;
        dp_b = curr_b;
        dp_c = curr_c;
    }
    cout << max(dp_a, max(dp_b, dp_c)) << endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[m];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		for (int i = 0; i < m; i++) {
			b[i] = sc.next();
		}
		for (int l = 0; l < n - m + 1; l++) {
			for (int k = 0; k < n - m + 1; k++) {
				int count = 0;
				for (int i = 0; i < m; i++) {
					for (int j = 0; j < m; j++) {
						if (a[i + k].charAt(j + l) == b[i].charAt(j)) {
							count++;
						}
					}
				}
				if (count == m * m) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21716
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	a-=b;
	a-=b;
	cout<<max(0LL,a);
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;
 
 
#define F(i, a) for (int i = 0; i < (a); i++)
#define Fd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define Fs(i, a, j) for (ll i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define ll long long
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define int long long
#define pii pair < int , int >
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/


void solve() {
    int n,m; cin >> n >> m;
    int row[n],col[m];
    F(i,n) row[i] = 0;
    F(i,m) col[i] = 0;
    int q; cin >> q;
    map < pair < int, int >,int > mymp;
    while (q--) {
        int x,y; cin >> x >> y;
        x--;
        y--;
        row[x] ++;
        col[y] ++;
        mymp[mp(x,y)] ++;
    }
    int mx = 0,my = 0;
    F(i,n) mx = max(mx,row[i]);
    F(i,m) my = max(my,col[i]);
    int res = 0;
    vector < int > a,b;
    F(i,n) if (mx == row[i]) a.eb(i);
    F(i,m) if (my == col[i]) b.eb(i);
    for (auto f:a) {
        for (auto g:b) {
            if (mymp.find(mp(f,g)) != mymp.end()) {
                res = 1;
            }else {
                cout << mx + my << endl;
                return;
            }
        }
    }
    cout << mx + my - res << endl;
}

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





Measured memory_bytes: 34552
import bisect
import itertools

#n桁のm値のbitを生成
def bit(n, m):
    bit_list = list(itertools.product([i for i in range(m)], repeat=n))
    return bit_list

A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]


for i in range(Q):

    insert_index = bisect.bisect_left(s,x[i])
    if insert_index >= A:
        insert_index = insert_index -1
        tmp1 = s[insert_index]
        tmp2 = s[insert_index]
        
    else:   
        tmp1 = s[insert_index]
        tmp2 = s[insert_index-1]
    
    insert_index = bisect.bisect_left(t,x[i])
    if insert_index >= B:
        insert_index = insert_index -1
        tmp3 = t[insert_index]
        tmp4 = t[insert_index]
        
    else:
        tmp3 = t[insert_index]
        tmp4 = t[insert_index-1]
    
    result = 10 ** 11
    for j, k in ([0,1], [0,0], [1,0], [1,1]):
        tmp = 0
        if j == 0:
            tmp += abs(tmp1 - x[i])
            now = tmp1
        else:
            tmp += abs(tmp2 - x[i])
            now = tmp2
                
        if k == 0:
            tmp += abs(now - tmp3)
        else:
            tmp += abs(now - tmp4)
                
        result = min(tmp, result)
        
    for j, k in ([0,1], [0,0], [1,0], [1,1]):
        tmp = 0
        
        if k == 0:
            tmp += abs(x[i] - tmp3)
            now = tmp3
        else:
            tmp += abs(x[i]- tmp4)
            now = tmp4
            
        if j == 0:
            tmp += abs(now - tmp1)
        else:
            tmp += abs(now - tmp2)
                
        result = min(tmp, result)
                
    print(result)



Measured memory_bytes: 16188
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = [_I() for i in range(N)]

"""
何個色を使えば塗れるか
最も小さい数字からはじめれば？
最も左からはじめれば？
"""

def bisect(arr, val, cmp):
    l = -1
    r = len(arr)
    while r - l > 1:
        e = (l + r) >> 1
        if cmp(arr[e], val): l = e
        else: r = e
    return r

res = [] 
for a in A:
    #  print('a res', a, res)
    if len(res) == 0:
        res.append(a)
    else:
        if a <= res[-1]:
            # 小さいので追加
            res.append(a)
        else:
            # 入れ替え
            p = bisect(res, a, lambda x, y: x > y)
            if res[p] == a:
                p = bisect(res, a-1, lambda x, y: x > y)
                res[p] = a
            else:
                res[p] = a

print(len(res))


Measured memory_bytes: 76760