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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		x -= z;
		y += z;

		int count = 0;
		while (true) {
			if (x < y * count) {
				break;
			} else {
				count++;
			}
		}

		System.out.println(--count);

		sc.close();
	}
}

Measured memory_bytes: 21972
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab = sorted(ab, key=lambda x: x[1])

ans, tmp = 0, 0
for a, b in ab:
    if a >= tmp:
        tmp = b
        ans += 1
print(ans)


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

int main() {
#ifdef LOCAL
  freopen("a.txt", "r", stdin);
  // freopen("main.txt","w",stdout);
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#endif
  int n, m;
  cin >> n >> m;
  if (n == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

typedef long long ll;
const ll DIV = pow(10,9) + 7;

int power(int a){
  ll mul = 1;
  for(int i = 1; i <= a; i++){
    mul = mul * i % DIV;
  }
  return mul;
}

int main(){
  int k;
  cin >> k;
  cout << power(k) << endl;
}

Measured memory_bytes: 256
cand_num, tenka = map(int, input().split(" "))
candles = list(map(int, input().split(" ")))
mini = 10 ** 9

for i in range(cand_num - tenka + 1):
    if candles[i] * candles[tenka + i - 1] >= 0:
        temp = max(abs(candles[i]), abs(candles[tenka + i - 1]))
    else:
        temp = min(abs(candles[i]), abs(candles[tenka + i- 1])) * 2 + max(abs(candles[i]), abs(candles[tenka + i - 1]))
    mini = temp if mini > temp else mini
print(mini)

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

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

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

    vector<ll> b(n);
    REP(i, n) b[i] = sum ^ a[i];

    REP(i, n) {
        cout << b[i];
        if (i != n - 1) cout << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 6336
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n;
    cin>>n;
    double ans=0,m;
    string c;
    rep(i,n){
    	cin>>m;
    	cin>>c;
    	if(c[0]=='J')ans+=m;
    	else ans+=m*380000.0;
    }
    cout<<setprecision(10)<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<iomanip>

using namespace std;

int main(void) {
	int n;
	int a[200];
	int i;
	int f = 0;
	int x = 0;

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

	while (1) {

		for (i = 0; i < n; i++) {
			if (a[i] % 2 == 1)
				f = 1;
		}
		if (f == 1)
			break;

		for (i = 0; i < n; i++) {
			a[i] /= 2;
		}
		x++;
	}
	cout << x;
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# S = str(input())
# T = str(input())
total = {}
s = [0]*N
for i in range(N):
    s[i] = str(input())
    if not (s[i] in total):
        total[s[i]] = 1
    else:
        total[s[i]] += 1
M = int(input())
t = [0]*M
for i in range(M):
    t[i] = str(input())
    if not (t[i] in total):
        total[t[i]] = -1
    else:
        total[t[i]] -= 1

ar = total.values()
ans = max(ar)
print(ans if ans>0 else 0)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> l(n);
  rep(i,n)cin>>l[i];
  int res=0;
  rep(i,n){
    for(int j=i+1;j<n;++j){
      for(int k=j+1;k<n;++k){
        int mx=l[i];
        mx=max(mx,l[j]);
        mx=max(mx,l[k]);
        int sm=l[i]+l[j]+l[k]-mx;
        if(sm>mx){
          if(l[i]!=l[j]&&l[j]!=l[k]){
            if(l[i]!=l[k])++res;
          }
        }
      }
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3632
S = input()

str1 = int(S[0:2])
str2 = int(S[2:4])

MMYY = False
YYMM = False

# MMYY
if 1 <= str1 and str1 <= 12 and 0 <= str2 and str2 <= 99:
    MMYY = True
# YYMM
if 0 <= str1 and str1 <= 99 and 1 <= str2 and str2 <= 12:
    YYMM = True

if MMYY and YYMM:
    print("AMBIGUOUS")
elif MMYY:
    print("MMYY")
elif YYMM:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input().strip()

ANS=0
flag=0

for s,t in ST:
    if flag==1:
        ANS+=int(t)
        
    if s==X:
        flag=1

print(ANS)


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

string str;

int main(){
    cin >> str;

    int cc=0;

    while(str.size()){
        str.pop_back();

        if(str.size()%2!=0)
            continue;

        string t;

        for(int i=0;i<(int)str.size()/2;i++)
            t.push_back(str[i]);
        if(t+t == str)
            cc=max(cc,(int)t.size()*2);
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func perm(N int, G [][]bool, size int, used []bool, order []int) int {
	if size == N {
		return 1;
	}
	ans := 0
	for i := 0; i < N; i++ {
		if used[i] {
			continue
		}
		if G[order[size - 1]][i] == false {
			continue
		}
		used[i] = true;
		order[size] = i;
		ans += perm(N, G, size + 1, used, order)
		used[i] = false;
	}
	return ans;
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	M := io.NextInt()
	G := make([][]bool, N)
	for i := 0; i < N; i++ {
		G[i] = make([]bool, N)
	}
	for i := 0; i < M; i++ {
		a := io.NextInt()
		b := io.NextInt()
		a--
		b--
		G[a][b] = true;
		G[b][a] = true;
	}
	used := make([]bool, N)
	order := make([]int, N)
	for i := 0; i < N; i++ {
		used[i] = false;
	}
	used[0] = true;
	order[0] = 0;
	ans := perm(N, G, 1, used, order);
	io.PrintLn(ans)
}

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

using namespace std;
const int MAXN=1e5+7;
int par[MAXN];
struct Node
{
    int u,v,w;
};
bool cmp1(Node a,Node b)
{
    return a.u<b.u;
}
bool cmp2(Node a,Node b)
{
    return a.v<b.v;
}
bool cmp3(Node a,Node b)
{
    return a.w<b.w;
}
int n;
Node a[MAXN];
vector <Node> edges;
void Input()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i].u>>a[i].v;
        a[i].w=i;
    }
}
void Init()
{
    sort(a+1,a+1+n,cmp1);
    for(int i=2; i<=n; i++)
        edges.push_back({a[i].w,a[i-1].w,abs(a[i].u-a[i-1].u)});
    sort(a+1,a+1+n,cmp2);
    for(int i=2; i<=n; i++)
        edges.push_back({a[i].w,a[i-1].w,abs(a[i].v-a[i-1].v)});
    sort(edges.begin(),edges.end(),cmp3);
    memset(par,-1,sizeof(par));
}
int root(int u)
{
    return par[u]<0 ? u : (par[u]=root(par[u]));
}
bool Merge(int u,int v)
{
    if((u=root(u))==(v=root(v)))
        return false;
    if(par[u]>par[v])
        swap(u,v);
    par[u]+=par[v];
    par[v]=u;
    return true ;
}
long long ans;
void Output()
{
    for(int i=0;i<(int)edges.size();i++)
        if(Merge(edges[i].u,edges[i].v))
        ans+=edges[i].w;
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Init();
    Output();
    return 0;
}


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

int main() {
    int a, b, d, r;
    double f;

    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    cout << d << " " << r << " " << fixed << setprecision(10) << f << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll x, y;
    cin >> x >> y;

    ll res = 1;
    while(x * 2 <= y){
        x *= 2;
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <tuple>
#include <unordered_map>
using namespace std;
const int mod = 1000000007;

int main() {
		
	int n, t;
	cin >> n >> t;
	vector<int> times(n);
	for (int i = 0; i < n; ++i) {
		cin >> times[i];
	}
	int previous = times[0] + t;
	int water = 0;
	for (int i = 1; i < n; ++i) {
		if (times[i] >= previous) {
			water += t;
		}
		else if (times[i] < previous) {
			water += times[i] - times[i - 1];
		}
		previous = times[i] + t;
	}
	water += t;
	cout << water << endl;
	
	

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int a,b,c,d,p;
    cin >> a >> b >> c >> d >> p;
    int x=p*a;
    int y=p>c?b+(p-c)*d:b;
    cout << min(x,y) << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS

ll arr[100000];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,w; cin >> n >> w;
	
	vector<ll> pesos(n,0);
	vector<ll> costo(n,0);
	int costoT = 0;
	for(int i = 0; i < n; i++){
		cin >> pesos[i] >> costo[i];
		costoT+= costo[i];
	}
	for(int i = 0; i <= costoT; i++){
		arr[i] = 100000000000;
	}
	arr[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = costoT;j >= costo[i]; j--){
			arr[j] = min(arr[j], arr[j-costo[i]] + pesos[i]);
		}
	}
	ll mx = 0;
	for(ll i = 0; i <= costoT; i++){
		if(arr[i] <= w) mx = max(i,mx);
	}
	cout << mx << endl;

	return 0;
}


Measured memory_bytes: 1024
N, K, S = map(int, input().split())

ans = []

for i in range(N):
    if i < K:
        ans.append(str(S))
    else:
        ans.append(str(((S % 10**9) + 1)))
        # if S == 10 ** 9:
        #     ans.append(str(1))
        # else:
        #     ans.append(str(S+1))

print(" ".join(ans))


Measured memory_bytes: 13464
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

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

    if (X < A)
    {
        cout << 0;
    }
    else
    {
        cout << 10;
    }

    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.rbegin(), v.rend());
  int a = 0, b = 0;
  rep(i,n){
    if(i%2==0)
      a += v[i];
    else
    {
      b += v[i];
    }
  }
  cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 3544
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll n, m, q;
vll a, b, c, d;
ll recurse(ll idx, vll &got, ll prev) {
  if(idx == n) {
    ll ct = 0;
    for(ll i = 0; i < q; i++) {
      if(got[b[i]] - got[a[i]] == c[i]) ct+= d[i];
    }
    return ct;
  }
  ll ans = 0;
  for(ll i = prev; i <= m; i++) {
    vll curr = got;
    curr.pb(i);
    ans = max(ans, recurse(idx + 1, curr, i));
  }
  return ans;
}

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> m >> q;
  a.resize(q), b.resize(q), c.resize(q), d.resize(q);
  for(ll i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vll ans;
  ll res = recurse(0, ans, 1);
  cout << res << endl;
  return 0;
} //good night.

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

using namespace std;
int main(){
	int arr[10002];
	int n=1;
	cin>>arr[n];
	while(arr[n]!=0){
		cout<<"Case "<<n<<": "<<arr[n]<<endl;
		n++;
		cin>>arr[n];
	}
	}


Measured memory_bytes: 3116
def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))

    pay = N
    while True:
        if any(c in D for c in map(int, str(pay))):
            pay += 1
            continue
        print(pay)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <tuple>
#include <time.h>
using namespace std;

int main() {
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	if (n < 10) {
		cout << n;
		return 0;
	}
	if (n < 100) {
		cout << 9;
		return 0;
	}
	if (n < 1000) {
		cout << 9 + n - 100 + 1;
		return 0;
	}
	if (n < 10000) {
		cout << 909;
		return 0;
	}
	if (n < 100000) {
		cout << 909 + n - 10000 + 1;
		return 0;
	}
	cout << 909 + n - 10000;
	return 0;
}


Measured memory_bytes: 888
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)

def count_train(x):
    tmp = 0
    for a, f in zip(A, F):
        tmp += max(0, a - (x // f))
        if tmp > K:
            return tmp
    return tmp

ng = -1
ok = 10 ** 18
while ok - ng > 1:
    mid = (ok + ng) // 2
    if count_train(mid) <= K:
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 113716
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

LL gcd(LL x, LL y){
  LL sm, la, work;
  if(x<y) {
    la = y;
    sm = x;
  }
  else{
    la = x;
    sm = y;
  }

  while(1){
    work= la%sm;
    if(work==0)break;
    la=sm;
    sm=work;
  }
  return sm;
}

int main(){
  int n, k;
  cin>>n>>k;
  int a[n];
  int g;
  int m=0;
  REP(i, n){
    cin>>a[i];
    m=max(m, a[i]);
    if(i==0)g=a[i];
    else g=gcd(g, a[i]);
  }
  if(k%g==0 &&k<=m)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

  return 0;
}


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

int rui(int N,int K){
    int A=1;
    if(K==0){
        return 1;
    }
    else{
        rep(i,K){
            A=A*N;
        }
        return A;
    }
}

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

int main(){
    int N;
    cin>>N;
    vector<int>list;
    rep(i,5){
        list.push_back(rui(9,i+1));
    }
    rep(j,6){
        list.push_back(rui(6,j+1));
    }
    sort(list.begin(),list.end());
    reverse(list.begin(),list.end());
    vector<int>dp(N+1,1e9+7);//k円出すときの最短路
    dp[0]=0;
    for(int i=1;i<N+1;i++){
        dp[i]=1+dp[i-1];
        rep(j,list.size()){
            if(i>=list[j]){
                chmin(dp[i],dp[i-list[j]]+1);
            }
        }
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p pair<ll,ll>
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
ll mod= 1e9+7;
ll a[200005];
void init()
{
     a[1]=1;
     for(int i=2;i<=200000;i++)
      {
           a[i] = a[i-1]+i ;
      }
}

int main()
{     
      init();
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n+1;i++)
      {   if(i==n+1){ans++;continue;}
         ans+=  ( a[n]-a[n-i] -a[i-1] +1   )%mod;

      }
    cout<<ans%mod<<endl;
       

    return 0;
}



Measured memory_bytes: 5196
read a b
n=0
if [ "${a:0:1}" = "-" -a  "${b:0:1}" = "-" ]
then
	n=$(( $(( a - b )) * -1 ))
	if [ "$(( n % 2 ))" = "1" ]
	then
		echo Positive
		exit
	elif [ "$(( n % 2 ))" = "0" ]
	then
		echo Negative
		exit
	fi
elif [ "${a}" = "0" ] || [ "${b}" = "0" ] || [ "${a:0:1}" = "-" -a "${b:0:1}" != "-" ] || [ "${a:0:1}" != "-" -a "${b:0:1}" = "-" ]
then
	echo Zero ;exit
else
	echo Positive ;exit
fi


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

using namespace std;

int main()
{
   int n;
  scanf("%d",&n);
  int t,a;
  scanf("%d%d",&t,&a);
  float h[n];
  int i,num;
  for(i=0;i<n;++i)
      scanf("%f",&h[i]);
  
  float ans,min=10000000000;
  for(i=0;i<n;++i)
  {
    ans=t-(h[i])*0.006;
    if(min>abs(ans-a))
    { min=abs(ans-a);
       num=i+1;
    }
  }
  
  printf("%d",num);
}

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

using namespace std;

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

int W, H;
int A[22][22];
int sx, sy, gx, gy;
void dfs(int x, int y, int cnt, int &ans, vector<vector<int>> maze) {
    if (cnt > 10) return;
    if (cnt > ans) return;
    // cout << x << " " << y << endl;
    if (x == gx && y == gy) {
        ans = min(ans, cnt);
        return;
    }
    int nx = x, ny = y;
    if (nx + 1 < H && maze[nx + 1][y] != 1) {
        while (nx < H && maze[nx][y] != 1) {
            // cout << "!" << maze[nx][y] << endl;
            if (nx == gx && y == gy) ans = min(ans, cnt + 1);
            nx++;
        }
        // cout << "!" << nx << " " << y << endl;
        vector<vector<int>> tmp = maze;
        if (nx != H) {
            tmp[nx][y] = 0;
            dfs(nx - 1, y, cnt + 1, ans, tmp);
        }
    }

    nx = x;
    if (nx - 1 >= 0 && maze[nx - 1][y] != 1) {
        while (nx >= 0 && maze[nx][y] != 1) {
            if (nx == gx && y == gy) ans = min(ans, cnt + 1);
            nx--;
        }
        vector<vector<int>> tmp = maze;
        if (nx != -1) {
            tmp[nx][y] = 0;
            dfs(nx + 1, y, cnt + 1, ans, tmp);
        }
    }

    ny = y;
    if (ny + 1 < W && maze[x][ny + 1] != 1) {
        while (ny < W && maze[x][ny] != 1) {
            if (x == gx && ny == gy) ans = min(ans, cnt + 1);
            ny++;
        }
        vector<vector<int>> tmp = maze;
        if (ny != W) {
            tmp[x][ny] = 0;
            dfs(x, ny - 1, cnt + 1, ans, tmp);
        }
    }

    ny = y;
    if (ny - 1 >= 0 && maze[x][ny - 1] != 1) {
        while (ny >= 0 && maze[x][ny] != 1) {
            if (x == gx && ny == gy) ans = min(ans, cnt + 1);
            ny--;
        }
        vector<vector<int>> tmp = maze;
        if (ny != -1) {
            tmp[x][ny] = 0;
            dfs(x, ny + 1, cnt + 1, ans, tmp);
        }
    }
}
bool solve() {
    cin >> W >> H;
    if (W == 0) return false;
    vector<vector<int>> maze(H, vector<int>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
            maze[i][j] = A[i][j];
            if (A[i][j] == 2) {
                sx = i;
                sy = j;
            }
            if (A[i][j] == 3) {
                gx = i;
                gy = j;
            }
        }
    }
    int ans = 100;
    dfs(sx, sy, 0, ans, maze);
    if (ans <= 10)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3228
import string

N = int(input())
S = input()

string_list = list(string.ascii_uppercase)

for i in S:
    if string_list.index(i) + N <=25:
        print(string_list[string_list.index(i) + N ], end='')
    else:
        print(string_list[string_list.index(i) + N  - 26], end='')

Measured memory_bytes: 4984
import static java.lang.System.*;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int num[] = new int[count];
		for(int a = 0; a < count; a++) {
			int  b = sc.nextInt();
			num[a] = b;
		}
		for(int a = count - 1; a >= 0; a--) {
			if(a == 0) {
				out.println(num[a]);
			}else {
				out.print(num[a] + " ");
			}
		}
	}
}


Measured memory_bytes: 26304
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();
		int A[] = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (A[i] < A[j]) {
					int tmp = A[i];
					A[i] = A[j];
					A[j] = tmp;
				}
			}
		}

		double sum = 0;

		for(int i = 0; i < N; i++) {
			sum += A[i];
		}

		if (A[M - 1] < (sum / (4 * M))) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}

	return;

	}
}


Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=1e9+7;
const int N=25010;
const int M=410;
inline void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
inline int Pow(int x,int y) { int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res; }
int n,m,k,a[N],tot;
int buc[M];
namespace task1 {
	void get_dp(int dp[]) {
		static int f[N][M];
		for(int i=1;i<=k;++i) buc[i]=0;
		int len=0;
		for(int i=m;i>=1;--i) {
			if(buc[a[i]]) { len=i; break; }
			buc[a[i]]++;
		}
		len=min(m-len,k);
		
		memset(f,0,sizeof(f));
		f[0][len]=1;
		for(int i=1;i<=n-m;++i) {
			int sum=0;
			for(int j=k-1;j>=1;--j) {
				if(j+1<k) Add(f[i][j+1],1ll*f[i-1][j]*(k-j)%mod);
				Add(sum,f[i-1][j]);
				Add(f[i][j],sum);
			}
//			for(int j=1;j<k;++j) if(f[i-1][j]) {
//				if(j+1<k) Add(f[i][j+1],1ll*f[i-1][j]*(k-j)%mod);
//				for(int t=1;t<=j;++t)
//					Add(f[i][t],f[i-1][j]);
//			}
		}
		for(int i=0;i<=n-m;++i)
			for(int j=1;j<k;++j)
				Add(dp[i],f[i][j]);
	}
	int f[N],g[N];
	void main() {
		get_dp(f);
		reverse(a+1,a+m+1);
		get_dp(g);
		int res=0;
		for(int i=0;i<=n-m;++i)
			res=(res+1ll*f[i]*g[n-m-i])%mod;
		printf("%d",(tot-res+mod)%mod);
	}
}
bool check_unique(int *a,int m) {
	for(int i=1;i<=k;++i) buc[i]=0;
	for(int i=1;i<=m;++i) {
		if(buc[a[i]]) return 0;
		buc[a[i]]++;
	}
	return 1;
}
int f[N][M][2];
int main() {
	rd(n),rd(k),rd(m);
	for(int i=1;i<=m;++i) rd(a[i]);
	tot=n-m+1; for(int i=m+1;i<=n;++i) tot=1ll*tot*k%mod;
	for(int i=1;i+k-1<=m;++i) if(check_unique(a+i-1,k)) {
		printf("%d",tot);
		return 0;
	}
	if(!check_unique(a,m)) task1::main();
	else {
		f[1][1][0]=k;
		f[1][1][1]=m==1 ? k : 0;
		for(int i=2;i<=n;++i) {
			for(int d=0;d<2;++d) {
				int sum=0;
				for(int j=k-1;j>=1;--j) {
					if(j+1<k) Add(f[i][j+1][d],1ll*f[i-1][j][d]*(k-j)%mod);
					Add(sum,f[i-1][j][d]);
					Add(f[i][j][d],sum);
				}
			}
//			for(int j=1;j<k;++j)
//				for(int d=0;d<2;++d) if(f[i-1][j][d]) {
//					if(j+1<k) Add(f[i][j+1][d],1ll*f[i-1][j][d]*(k-j)%mod);
//					for(int t=1;t<=j;++t)
//						Add(f[i][t][d],f[i-1][j][d]);
//				}
			for(int j=m;j<k;++j)
				Add(f[i][j][1],f[i][j][0]);
		}
		int res=0;
		for(int j=1;j<k;++j) Add(res,f[n][j][1]);
		int inv=1;
//		cerr<<tot<<' '<<res<<endl;
		for(int i=k;i>k-m;--i) inv=1ll*inv*i%mod;
		res=1ll*res*Pow(inv,mod-2)%mod;		
		printf("%d",(tot-res+mod)%mod);
	}
	return 0;
}

Measured memory_bytes: 82176
N=int(input())
*A,=map(int,input().split())

i1=len([i for i in A if i%2!=0])
i4=len([i for i in A if i%4==0])
i2=min(1,N-i1-i4)

# print(i1,i2,i4)
print('Yes' if (i1+i2-1)<=i4 else 'No')

Measured memory_bytes: 20032
#include <stdio.h>

main(void)
{
	int a,n,i;
	
	long long int min=1000000 , max=-1000000 , sum=0;
	a=0;
	
	scanf("%d",&n);
	
	for(a=1;a<=n;a++){
		scanf("%d",&i);
		if(i<min) min=i;
		if(i>max) max=i;
		sum+=i;
	}
	printf("%d %d %lld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>) {
    val s = readInputLine()
    
    if (s == "A") {
        println("T")
    } else if (s == "T") {
        println("A")
    } else if (s == "C") {
        println("G")
    } else if (s == "G") {
        println("C")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

void solve()
{
    string s;cin>>s;
    vector<vector<ll> >dp(s.size()+1,vector<ll>(13,0));dp[0][0]=1;
    REP(i,s.size()){
        int x=(s[i]=='?'?-1:s[i]-'0');
        REP(j,10)if(x==-1||x==j)REP(k,13)(dp[i+1][(k*10+j)%13]+=dp[i][k])%=1000000007;
    }
    cout<<dp[s.size()][5]<<endl;
}

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

Measured memory_bytes: 13648
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  int N,ans1=0,ans2=0;
  bool check[8]={};
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  rep(i,N){
    if(a[i]<3200) check[a[i]/400]=1;
    else ans1++;
  }
  rep(i,8) if(check[i]==1) ans1++,ans2++;
  if(ans2==0) ans2=1;
  cout << ans2 << " " << ans1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
#include <vector>
#include <memory>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG


class LongestCommonSubsequence {
public:
  LongestCommonSubsequence(string s0, string s1) :
    s0_(s0),
    s1_(s1)
    {
      size_ = s0_.length() * s1_.length();
      pLongest_ = new int [size_];
      for (int i = 0; i < size_; i++)
        pLongest_[i] = kInvalid;
    }

  ~LongestCommonSubsequence()
  {
    if (pLongest_)
      free(pLongest_);
  }

  int getLCSlen();
  void printLength();

  const int kInvalid = -1;

private:
  string s0_;
  string s1_;
  int *pLongest_;
  int size_;

  int getIndex(int x, int y);
  int getLCSlenOf(int n0, int n1);
};

/*********************************
Input:
  x[0], x[1], x[2], ..., x[n-1]
  y[0], y[1], y[2], ..., y[m-1]

Algorithm:
  if x[n-1] == y[m-1]
    LCS(n-1, m-1) = LCS(n-2,m-2) + 1

  if x[n-1] != y[m-1]
    LCS(n-1, m-1) = max(LCS(n-2, m-1), LCS(n-1, m-2))

  LCS(0, *) = LCS(*, 0) = 0;

  a b c b d a b
  b d c a b a
*********************************/

int LongestCommonSubsequence::getLCSlen()
{
  int n0 = s0_.length() - 1;
  int n1 = s1_.length() - 1;
  return getLCSlenOf(n0, n1);
}


int LongestCommonSubsequence::getLCSlenOf(int n0, int n1)
{
  DPRINTF("n0 %d  n1 %d\n", n0, n1);

  assert(-1 <= n0 && n0 < static_cast<int>(s0_.length()));
  assert(-1 <= n1 && n1 < static_cast<int>(s1_.length()));

  if (n0 < 0  || n1 < 0)
    return 0;

  const int idx = getIndex(n0, n1);

  if (pLongest_[idx] != kInvalid)
    return pLongest_[idx];

  if (s0_[n0] == s1_[n1])
    pLongest_[idx] = getLCSlenOf(n0 - 1, n1 - 1) + 1;
  else
    pLongest_[idx] = max(getLCSlenOf(n0 - 1, n1), getLCSlenOf(n0, n1 - 1));

  return pLongest_[idx];
}


int LongestCommonSubsequence::getIndex(int x, int y)
{
  return y * s0_.length() + x;
}


void LongestCommonSubsequence::printLength()
{
  for (int i = 0; i < s0_.length(); i++)
    for (int j = 0; j < s1_.length(); j++)
      DPRINTF("pLongest_[%d][%d] %d\n", i, j, pLongest_[getIndex(i, j)]);
}


int main()
{
  int numOfPair;
  cin >> numOfPair; cin.ignore();

  DPRINTF("num of pair %d\n", numOfPair);

  for (int i = 0; i < numOfPair; i++)
  {
    string str0, str1;
    cin >> str0 >> str1; cin.ignore();

    DPRINTF("str0 %s  str1 %s\n", str0.c_str(), str1.c_str());

    LongestCommonSubsequence lcs(str0, str1);
    cout << lcs.getLCSlen() << endl;

#if (1) && DEBUG
    lcs.printLength();
#endif
  }

  return 0;
}


Measured memory_bytes: 7188
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;

  vector<ll> C(N - 1);
  vector<ll> S(N - 1);
  vector<ll> F(N - 1);
  for (ll i = 0; i < N - 1; i++) {
    cin >> C[i];
    cin >> S[i];
    cin >> F[i];
  }

  vector<ll> ans(N, 0);
  for (ll i = 0; i < N - 1; i++) {
    ll t = 0;
    for (ll j = i; j < N - 1; j++) {
      // 駅jを出発する時刻
      if (t < S[j]) {
        t = S[j];
      } else if (t % F[j] == 0) {
        t += 0;
      } else {
        t = t + F[j] - t % F[j];
      }

      // 次の駅に着く時刻
      t += C[j];
    }

    ans[i] = t;
  }

  for (auto a : ans) {
    cout << a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll X,K,D; cin>>X>>K>>D; X=abs(X);
	ll ans=INF;
	if(K<1e18/D) ans=min(ans, abs(X-K*D));
	if(X*1.0L/D<=K){
		ll diff=X/D;
		if((K-diff)%2==0) ans=min(ans, min(X%D, abs(X%D-2*D)));
		else ans=min(ans, min(X%D+D, abs(X%D-D)));
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    for (int i = N - 1; i > 0; --i) {
        if (H[i] - H[i - 1] < -1) {
            cout << "No" << '\n';
            return 0;
        } else if (H[i] - H[i - 1] == -1) {
            --H[i - 1];
        }
    }
    cout << "Yes" << '\n';
}

Measured memory_bytes: 640
#include<cstdio>

int main() {
    int S;
    scanf("%d",&S);
    int h = S / 3600;//時間
    S %= 3600;// S = S % 3600
    int m = S / 60;//分
    int s = S % 60;//秒

    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000
#define NOTFOUND -1
int Max = 0;
// nまでの文字列をいくつか選んで最長共通部を作ったときの長さ
//int dp[MAX];

bool 
IsInTargetString(string strFind, string strTgt)
{
    int idx;
    string strTmp = strTgt;

    for (int i = 0; i < strFind.size(); i++)
    {
        idx = strTgt.find(strFind[i]);
        if (idx != string::npos) {
            strTmp = strTgt.substr(idx+1);
            // cout << "idx = " << idx << " strFind = " << strFind
            // << " strTmp = " << strTmp <<  "\n";
        } else {
            return false;
        }
        strTgt = strTmp;
    }
    //cout <<  "\n";
    return true;
}

int
SearchCommonSubsequence(string strSet1, string strSet2)
{
    //vector<vector<bool>> dp(MAX, vector<bool>(MAX));

    // dp[i+1][j+1] = strSet1のi 文字目までとstrSet2のj文字目まででの LCS の長さ
    vector<vector<int>> dp(MAX, vector<int>(MAX));
    dp[0][0] = 0;
    string strRes = "";


    for (int i = 0; i < strSet1.size(); i++)
    {
        for (int j = 0; j < strSet2.size(); j++)
        {
            if(strSet1[i] == strSet2[j]) {
                dp[i+1][j+1] = max({dp[i][j] + 1,dp[i+1][j], dp[i][j+1]});
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
        
    // for(int i=0; i<strSet1.size(); i++) {
    //     string strTmp = strRes;
    //     strTmp += strSet1[i];

    //     //if(strSet2.find(strTmp) != string::npos) {
    //     if(IsInTargetString(strTmp, strSet2)) {
    //         // 見つかった場合は更新a
    //         strRes = strTmp;
    //     } else {
    //         // 見つからなかった場合はそのまま
    //     }
    //     dp[i] = strRes.size();
    //     //cout << strRes << ", " << strSet1[i] << "\n";
    // }

    //auto itr = std::max_element(dp.begin(), dp.end());
    //return *itr;
    return dp[strSet1.size()][strSet2.size()];
}

int main()
{
    string strSet1, strSet2;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> strSet1 >> strSet2;

        if(strSet1.size() > strSet2.size()) swap(strSet1, strSet2);
        cout << SearchCommonSubsequence(strSet1, strSet2) << "\n";
    }    
    return 0;
}



Measured memory_bytes: 18812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 1

int main()
{	
	ios_base::sync_with_stdio(0);
	int n,m,a,b;
	while(cin>>n>>m){
		vector<int> arr(n,0);
		int ok = 0;
		for(int i=1; i<=m; i++){
			cin>>a>>b;
			if(a==1 || a==n){
				arr[b-1]++;
				if(arr[b-1]==2) ok = 1;
			}
			if(b==1 || b==n){
				arr[a-1]++;
				if(arr[a-1]==2) ok = 1;
			}
		}
		if(ok) cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
	}
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    int i,j,a,b,c;
    scanf("%d",&i);
    
    for(j=0;j<i;j++){
        scanf("%d %d %d",&a,&b,&c);
        
        if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
            printf("YES\n");
        else 
            printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 1912
# coding: utf-8
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
c = 1
pn = 0
qn = 0
lst = [i for i in range(1, N+1)]
for i in itertools.permutations(lst, N):
    if i == P:
        pn = c
    if i == Q:
        qn = c
    c += 1
print(abs(pn - qn))

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

int main() {
  int s; 
  cin >> s;
  int Y=s/100, M=s%100;
  if(Y>0 && Y<13 && M<13 && M>0) 
    cout << "AMBIGUOUS";
  else if (M>0 && M<13) 
    cout << "YYMM";
  else if(Y<13 && Y>0)
    cout << "MMYY";
  else
    cout <<"NA";
}


Measured memory_bytes: 256
def main():
    X , Y = map(float, input().split())
    a = 2.0 * X - Y / 2.0
    b = Y / 2.0 - X
    c = a % 1
    d = b % 1
    #print(c.is_integer())
    #print(d.is_integer())
    if c.is_integer() == True and d.is_integer() == True and a > 0 and b > 0 :
        print("Yes")
    elif c.is_integer() == True and d.is_integer() == True and a == 0 and b > 0 :
        print("Yes")
    elif c.is_integer() == True and d.is_integer() == True and a > 0 and b == 0 :
        print("Yes")
    else :
        print("No")



if __name__ == '__main__':
    main()

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

struct UnionFind {
  vector<int> d; // 親の番号、但し根の場合はサイズのマイナス
  UnionFind(int n): d(n,-1) {}
  int root(int x) { // 根を見つける
    if (d[x] < 0) return x;
    return d[x] = root(d[x]); // 経路圧縮
  }
  bool unite(int x, int y) { // 結合
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);} // 親が一緒
  int size(int x) { return -d[root(x)];} // サイズ
};

struct Road
{
    int start;
    int end;
    int cost;
};


int main(){
    int n; // 頂点数
    cin>>n;
    vector<int> x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    vector<int> index(x.size());
    iota(index.begin(), index.end(), 0); // indexに0から順に代入
    sort(
        index.begin(),
        index.end(),
        [&](int a, int b){return x[a] < x[b];}
    );
    vector<int> indexy(x.size());
    iota(indexy.begin(), indexy.end(), 0); // indexに0から順に代入
    sort(
        indexy.begin(),
        indexy.end(),
        [&](int a, int b){return y[a] < y[b];}
    );
    vector<Road> roads((n-1)*2);
    rep(i,n-1){
        Road road={index[i],index[i+1],abs(x[index[i]]-x[index[i+1]])};
        roads[i]=road;
        road={indexy[i],indexy[i+1],abs(y[indexy[i]]-y[indexy[i+1]])};
        roads[n-1+i]=road;
    }
    sort(
        roads.begin(),
        roads.end(),
        [&](Road a, Road b){return a.cost < b.cost;}
    );

    UnionFind uf(n); // 初期化
    ll cost=0;
    rep(i,(n-1)*2){
        Road road=roads[i];
        if(!uf.same(road.start,road.end)){
            cost+=road.cost;
            uf.unite(road.start,road.end);
        }
        if(uf.size(0)==n) break;
    }
    cout<<cost<<endl;
    return 0;
}



Measured memory_bytes: 7476
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s,t;
    int a,b;
    R(s,t);
    R(a,b);
    string d;
    R(d);
    if(s==d)a--;
    else b--;
    W(a,b);
    return 0;
}


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

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

	long long cnt = 0;
	for(long a=1; a<N; a++){
		for(long b=1; b<N; b++){
			if(a*b >= N) break;
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int a,b;
    cin >> a >> b;
    int ans;
    if(a >= 13){
        ans = b;
    }else if(a >= 6){
        ans = b / 2;
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b, c, r;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  if (a == b)
    r = c;
  else if (b == c)
    r = a;
  else
    r = b;
  std::cout << r;
  return 0;
}

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


int main(){
	char ch;
	cin >> ch;
	if(ch=='A') cout << "T";
	else if(ch=='T') cout << "A";
	else if(ch=='C') cout << "G";
	else cout << "C";
	cout << endl;
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m;
	cin >> n >> m;

	vector<vector<int> > G;
	vector<vector<int> > rev;
	G.resize(n);
	rev.resize(n);

	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		G[a].emplace_back(b);
		rev[b].emplace_back(a);
	}

	vector<int> vis;
	
	set<int> st;

	function<void(int, int, int)> dfs = [&] (int u, int s, int f) {
		vis[u] = 1;
		st.emplace(u);
		for(auto v : G[u]) {
			if(v != s && st.count(v)) {
				st.erase(u);
				return;
			}
		}
		for(auto v : rev[u]) {
			if(v != f && st.count(v)) {
				st.erase(u);
				return;
			}
		}
		for(auto v : G[u]) {
			if(v == s) {
				cout << st.size() << '\n';
				for(auto x : st) {
					cout << x + 1 << '\n';
				}
				exit(0);
			}
		}
		for(auto v : G[u]) {
			if(vis[v] == 0) {
				dfs(v, s, u);
			}
		}
		st.erase(u);
	};

	for(int i = 0; i < n; ++i) {
		st.clear();
		vis.assign(n, 0);
		dfs(i, i, -1);
	}
	
	cout << -1 << '\n';

	return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var S, T []byte
	fmt.Scan(&S, &T)
	var ok, replaced bool
	for i := len(S) - 1; i >= 0; i-- {
		for j := i; j >= 0; j-- {
			ok = true
			t := S[j : i+1]
			if len(string(S[j:i+1])) == len(string(T)) {
				for k := 0; k < len(t); k++ {
					if T[k] != t[k] && t[k] != '?' {
						ok = false
						break
					}
				}
			} else {
				ok = false
			}
			if ok {
				for k := 0; k < len(t); k++ {
					S[j+k] = T[k]
					replaced = true
				}
				for k := 0; k < len(S); k++ {
					if S[k] == '?' {
						fmt.Print("a")
					} else {
						fmt.Print(string(S[k]))
					}
				}
				fmt.Println()
				return
			}
		}
	}
	if !replaced {
		fmt.Println("UNRESTORABLE")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a > b) swap(a,b);
  if(a > c) swap(a,c);
  if(b > c) swap(b,c);
  cout << a << ' ' << b << ' ' << c << '\n';
  return 0;
}


Measured memory_bytes: 3104