akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String li;
            try {
                li = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            String[] lisp = li.split(" ");
            int a = Integer.parseInt(lisp[0]);
            int b = Integer.parseInt(lisp[1]);
            int x;
            int y;
            if(a > b) {
                    x = a;
                    y = b;
                }else {
                    x  = b;
                    y = a;
                }
            while(x > 0 && y > 0) {
                int z = x % y;
                x = y;
                y = z;
                if(y == 0) {
                    System.out.println(x + " " + (a / x * b));
                }
            }
        }
    }
 } 


Measured memory_bytes: 25928
import java.util.*;
public class Main {
    private static long dp[][];
    private static int N;
    private static int A[];
    private static int B[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        System.out.println(String.format("%d", X + (Y / 2)));
    }
}


Measured memory_bytes: 21076
package main

import (
	"fmt"
	"math"
)

const inf = math.MaxInt64 / 2

func chmin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	dp := make([]int, n)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 1; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i >= j {
				chmin(&dp[i], dp[i-j]+abs(h[i]-h[i-j]))
			}
		}
	}
	fmt.Println(dp[n-1])
}


Measured memory_bytes: 5504
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for(j=p; j<r; j++){
    if(A[j]<=x){
      i++;
      t = A[i]; A[i]=A[j]; A[j]=t;

    }
  }
  t=A[i+1]; A[i+1]=A[j]; A[r]=t;
  return i+1;
}

int main(){
  int i, q;
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  q=partition(0, n-1);
  for(i=0; i<n; i++){
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d", A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2120
#include <iostream>
using namespace std;
int main()
{
    string s;
    int x=0;
    int y=0;
    cin>>s;
    for (int i=0;i<s.length();i++)
    {
        if (s[2]==s[3]&&s[4]==s[5])
            x=x+1;
        else
            y=y+1;
    }
    if (x>y)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;



int main(void){
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);
    char cake[H][W];
    bool empty[H];
    for(int i=0;i<H;i++)empty[i] = true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf(" %c ", &cake[i][j]);
            if(cake[i][j] == '#')empty[i]=false;
        }
    }
   // for(int i=0;i<H;i++){
    //    for(int j=0;j<W;j++)printf("%c ", cake[i][j]);
    //    printf("\n");
    //}
    int ans[H][W];
    int num = 1;
    bool flag = true;
    for(int i=0;i<H;i++){
        if(flag && empty[i] == false){
            flag=false;
            bool unko = false;
            for(int j=0;j<W;j++){
                if(!unko && cake[i][j]=='#')unko=true;
                else if(unko && cake[i][j] == '#')num++;
                for(int k=0;k<=i;k++)ans[k][j]=num;
            }
            num++;
        }
        else if(!flag){
            bool unko = false;
            for(int j=0;j<W;j++){
                if(empty[i])ans[i][j]=ans[i-1][j];
                else{
                    if(!unko && cake[i][j]=='#')unko=true;
                    else if(unko && cake[i][j] == '#')num++;
                    ans[i][j]=num;
                }
            }
            if(!empty[i])num++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            printf("%d ", ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node{
  int key;
  struct Node *right, *left, *parent;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int m,i,z;
  char s[10];
  scanf("%d",&m);

  for(i=0; i<m; i++){
    scanf("%s",s);
    if(strcmp(s,"insert") == 0){
      scanf("%d",&z);
      insert(z);
    }
    else if(strcmp(s,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if(z->key < x->key) {
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key ){
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 24040
n = gets.to_i
hash = {}
n.times do
  s = gets.chomp
  if hash.include?(s)
    hash[s] += 1
  else
    hash[s] = 1
  end
end
list = hash.to_a
list.sort! do |e1, e2|
  if e1[1] == e2[1]
    e1[0] <=> e2[0]
  else
    -(e1[1] <=> e2[1])
  end
end
max_count = list[0][1]
for i in 0...(list.length) do
  if list[i][1] == max_count
    puts list[i][0]
  else
    break
  end
end


Measured memory_bytes: 38656
n = int(input())
string = input()
ans = 0
if string[:n] == string[2*n-1:n-1:-1]:
  ans += 2
for b in range(1,2**n-1):
  s = []
  t = []
  for c in range(n):
    if b & 2**c:
      s.append(string[c])
    else:
      t.append(string[c])
  s = s[::-1]
  t = t[::-1]
  ltr = string[n:]
  l = len(s)
  DP = [[0 for i in range(l+1)] for j in range(n+1)]
  DP[0][0] = 1
  for i in range(1,n+1):
    x = ltr[i-1]
    for j in range(0,min(i+1,l+1)):
      if j>=1 and s[j-1] == x:
        DP[i][j] += DP[i-1][j-1]
      if i-j<=len(t) and t[i-j-1] == x:
        DP[i][j] += DP[i-1][j]
  ans += DP[-1][-1]
print(ans)


Measured memory_bytes: 60844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextLine()) {
			int row = scan.nextInt();
			int col = scan.nextInt();
			
			if(row == 0 && col == 0) break;
			
			for(int j=0; j<col; j++) {
				System.out.print("#");
			}
			System.out.println();
			
			for(int i=1; i<row-1; i++) {
				for(int j=0; j<col; j++) {
					if(j==0 || j == col-1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
						
			for(int j=0; j<col; j++) {
				System.out.print("#");
			}
			System.out.println("\n");
		}
	}
}






Measured memory_bytes: 34792
<?php

fscanf(STDIN, "%d", $N);
//$time = microtime(true);
$memo = array_fill(1,200,array_fill(1,200,0));
$ans = 0;
for($i=1;$i<=$N;$i++){
    for($j=$i;$j<=$N;$j++){
        if($memo[$i][$j] != 0){
            $temp_gcd = $memo[$i][$j];
        }else {
            $temp_gcd = (int)gmp_gcd($i, $j);
            $memo[$i][$j] = $temp_gcd;
        }
        for($k=$j;$k<=$N;$k++){
//            var_dump($temp_gcd);

            if($memo[$k][$temp_gcd] != 0){
                $plus = $memo[$k][$temp_gcd];
            }else {
                $plus = (int)gmp_gcd($temp_gcd, $k);
            }

            if($i == $j && $j == $k){
                $ans += $plus;
            }elseif($i == $j || $j == $k || $i == $k){
                $ans += $plus *3;
            }else{
                $ans += $plus * 6;
            }
        }
    }

}

echo $ans;

Measured memory_bytes: 17780
#include <stdio.h>

int main(){
  int k,x;
  int i;
  scanf("%d %d",&k,&x);
  
  for(i=k-1;i>0;i--){
	printf("%d ",x-i);
  }
  printf("%d ",x);
  for(i=1;i<k;i++){
    printf("%d ",x+i);
  }
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int q;
    cin >> s >> q;
    bool direction=true;
    int t;
    int f;
    string tmp;
    string r={};
    string l={};
    for(int i = 0; i < q; i++) {
        cin >> t;
        if(t==1) direction=!(direction);
        else{
            cin >> f >> tmp;
            if(f==1){
                if(direction) r+=tmp;
                else          l+=tmp;
            }
            else{
                if(direction) l+=tmp;
                else          r+=tmp;
            }
        }
    }
    int n=l.size();
    int m=r.size();
    if(!direction){
        for(int i = 0; i < n; i++) {
            cout << l[n-i-1];
        }
        for(int i = 0; i < s.size(); i++) {
            cout << s[s.size()-1-i];
        }
        for(int i = 0; i < m; i++) {
            cout << r[i];
        }
    }
    else{
        for(int i = 0; i < m; i++) {
            cout << r[m-i-1];
        }
        cout << s;
        for(int i = 0; i < n; i++) {
            cout << l[i];
        }
    }
    cout << "\n";
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

ll poww(ll a,ll b){
  ll ans=1;
  while(b>0){
    if(b%2==1) ans=(ans*a);
    a=(a*a);
    b=b/2;
  }
  return ans;
}

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

int main(){
   fastt;

   vector <ll> dp(100001);

   ll n,k;
   cin>>n>>k;

   vector <ll> a;

   for(ll i=1;i<=n;i++){
   	  ll x;
   	  cin>>x;
   	  a.pb(x);
   }

   dp[0]=1;

   for(ll i=1;i<=n;i++){
   	  vector <ll> temp=dp;
   	  for(ll j=1;j<=100000;j++)
   	  	temp[j]=(temp[j]+temp[j-1])%modd;
   	  for(ll kk=100000;kk>=1;kk--){
             if(kk-a[i-1]-1<0)
             	dp[kk]=(dp[kk]+temp[kk-1])%modd;
             else
             	dp[kk]=(dp[kk]+temp[kk-1]-temp[kk-a[i-1]-1]+modd)%modd;
   	  }
   }

   cout<<dp[k]<<endl;

   return 0;
}


Measured memory_bytes: 1904
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, a;
  cin >> h >> a;
  int ans = h / a;
  if (h % a) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <complex>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ FFT ------ //
const double pi = 3.14159265358979323;
const int sz = 4096; // more than 2 * n
double va[4105], vb[4105], v[4105]; complex<double> fa[4105], fb[4105];
void dft(complex<double> *x, bool rev) {
	for (int i = 0, j = 1; j + 1 < sz; j++) {
		for (int k = sz >> 1; k > (i ^= k); k >>= 1);
		if (i > j) swap(x[i], x[j]);
	}
	for (int i = 1; i < sz; i <<= 1) {
		complex<double> b = polar(1.0, (rev ? -1.0 : 1.0) * pi / i);
		for (int j = 0; j < sz; j += i << 1) {
			complex<double> mul(1.0, 0.0);
			for (int k = 0; k < i; k++) {
				complex<double> xa = x[j + k], xb = mul * x[j + k + i];
				x[j + k] = xa + xb;
				x[j + k + i] = xa - xb;
				mul *= b;
			}
		}
	}
	if (rev) for (int i = 0; i < sz; i++) x[i] /= sz;
}
void fft() {
	for (int i = 0; i < sz; i++) fa[i] = va[i]; dft(fa, false);
	for (int i = 0; i < sz; i++) fb[i] = vb[i]; dft(fb, false);
	for (int i = 0; i < sz; i++) fa[i] *= fb[i]; dft(fa, true);
	for (int i = 0; i < sz; i++) v[i] = fa[i].real();
}
// ------ Main Part ------ //
int n, pre[2009], nxt[2009], val[2009], v1[2009], v2[2009], c[2009]; string a, b;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> a >> b; n = a.size();
	if (b.find('1') == string::npos) cout << (a == b ? 0 : -1) << endl;
	else {
		int ret = 1 << 30;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				if (b[j] == '1') {
					a = a.substr(j) + a.substr(0, j);
					b = b.substr(j) + b.substr(0, j);
					break;
				}
			}
			for (int j = 0; j < n; j++) pre[j] = (b[j] == '1' ? 0 : pre[j - 1] + 1);
			for (int j = n - 1; j >= 0; j--) nxt[j] = (b[j] == '1' ? 0 : nxt[j + 1] + 1);
			fill(val, val + n, 0);
			for (int j = 0; j < n; j++) {
				if (a[j] == '0') pre[j] = nxt[j] = 0;
				val[pre[j]] = max(val[pre[j]], nxt[j]);
			}
			for (int j = n - 1; j >= 0; j--) val[j] = max(val[j], val[j + 1]);
			fill(v1, v1 + n, 1 << 30);
			fill(v2, v2 + n, 1 << 30);
			for (int j = 1; j <= n; j++) {
				v1[val[j]] = min(v1[val[j]], (j - 1) * 2 + val[j] * 2);
				v2[val[j]] = min(v2[val[j]], (j - 1) * 2);
			}
			for (int j = n - 2; j >= 0; j--) v1[j] = min(v1[j], v1[j + 1]);
			fill(c, c + n, 0);
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < n; k++) {
					va[k] = (a[n - k - 1] == (j + 48) ? 1.0 : 0.0);
					vb[k] = (b[k] == (j ^ 1) + 48 ? 1.0 : 0.0);
				}
				fft();
				for (int k = 0; k < 2 * n; k++) c[(k + 1) % n] += (int)(v[k] + 0.5);
			}
			int cl = 1 << 30;
			for (int j = 0; j < n; j++) {
				cl = min(cl, v2[j]);
				ret = min(ret, c[j] + cl + j);
				ret = min(ret, c[j] + v1[j] - j);
			}
			reverse(a.begin(), a.end());
			reverse(b.begin(), b.end());
		}
		cout << ret << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int mul = a*b;
  int n = a;
  while(n <= mul) {
    eprintf("n,a,b,c:%d,%d,%d,%d\n", n, a, b, c);
    if(n % b == c) {
      cout << "YES" << endl;
      return 0;
    }
    n += a;
  }
  cout << "NO" <<endl;

  return 0;
}


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

int h, w;
vector<int> e[1000];
vector<int> c[1000];
int dis[1000];

void dfs (int v, int ev, int ed) {
    fill(dis, dis+h*w, INF);
    queue<int> que;
    que.push(v);
    dis[v] = 0;
    while (!que.empty()) {
        int q = que.front(); que.pop();
        rep(i,e[q].size()) {
            if (q == ev && i == ed) continue;
            if (dis[e[q][i]] != INF) continue;
            dis[e[q][i]] = dis[q]+1;
            que.push(e[q][i]);
        }
    }
}

void dfs2 (int v, int x) {
    fill(dis, dis+h*w, INF);
    queue<int> que;
    que.push(v);
    dis[v] = 0;
    while (!que.empty()) {
        int q = que.front(); que.pop();
        rep(i,e[q].size()) {
            if (dis[e[q][i]] != INF) continue;
            if (dis[q]+c[q][i] > x) continue;
            dis[e[q][i]] = dis[q]+1;
            que.push(e[q][i]);
        }
    }
}

void solve() {
    rep(i,h) {
        int b;
        rep(j,w-1) {
            cin >> b;
            if (b == 0) {
                e[i*w+j].push_back(i*w+j+1);
                e[i*w+j+1].push_back(i*w+j);
            }
        }
        if (i == h-1) break;
        rep(j,w) {
            cin >> b;
            if (b == 0) {
                e[i*w+j].push_back((i+1)*w+j);
                e[(i+1)*w+j].push_back(i*w+j);
            }
        }
    }
    rep(i,h*w) {
        rep(j,e[i].size()) {
            dfs(i, i, j);
            c[i].push_back(dis[h*w-1]);
        }
    }
    int st = 0, en = 10000, mid;
    while (en-st > 1) {
        mid = (st + en) / 2;
        dfs2(0, mid);
        if (dis[h*w-1] == INF) {
            st = mid;
        } else {
            en = mid;
        }
    }
    if (en == 10000) en = -1;
    cout << en << endl;
}

int main() {
    while (cin >> h >> w) {
        if (h == 0 && w == 0) break;
        rep(i,h) rep(j,w) e[i*w+j].clear();
        rep(i,h) rep(j,w) c[i*w+j].clear();
        solve();
    }
}



Measured memory_bytes: 3268
#include <stdio.h>

int str_len(char str[128]) {
	int i = 0;

	while(str[i]) i++;

	return i;
}

/* 二つの文字列が一致すれば1,一致しなければ0をかえす */
int str_comp(char str1[128], char str2[128]) {
	int len;
	int i;

	/* 文字列の長さが一致しなかった場合 */
	if((len = str_len(str1)) != str_len(str2))
		return 0;

	for(i = 0; i < len; i++) {
		if(str1[i] != str2[i])
			return 0;
	}

	return 1;
}

/* char1からchar2への準方向への差を求める */
int deff_two_char(char char1, char char2) {
	int ans;
	if((ans = char2 - char1) < 0)
		ans += 26;

	return ans;
}

/* 文字を順方向へdeffだけずらす */
char shift_letter_deff(int deff, char c) {
	char ans = c;

	if(c - 'a' + deff > 25)
		ans += deff - 26;
	else
		ans += deff;
	
	return ans;
}

/* 単語を準方向へdeffだけずらす */
void shift_deff(int deff, char str[128]) {
	int i = 0;

	while(str[i]) {
		str[i] = shift_letter_deff(deff, str[i]);
		i++;
	}
}

/* 文字列をコピー */
void str_cp(char str1[128], char str2[128]) {
	int i = 0;

	while(str1[i]) {
		str2[i] = str1[i];
		i++;
	}

	str2[i] = '\0';
}

int main() {
	/* 使用する変数の宣言 */
	char input_str[128];
	char dev_word_str[41][80];

	int deff;
	int deff_the = -1;
	int deff_that = -1;
	int deff_this = -1;
	int count_the = 0;
	int count_that = 0;
	int count_this = 0;
	int temp_deff;

	char temp[80];

	int word_sum;
	int letter_sum[40];

	int i, j, k;

	/* 入力を受け取る */
	while(fgets(input_str, 128, stdin) != NULL) {
		/* 各変数の初期化 */
		deff_the = -1;
		deff_that = -1;
		deff_this = -1;
		count_the = 0;
		count_that = 0;
		count_this = 0;

		/* 入力された文字列を単語ごとに分ける */
		i = 0; j = 0; k = 0;
		while(input_str[i]) {
			if(input_str[i] == ' ') {
				dev_word_str[j][k] = '\0';
				letter_sum[j] = k;
				j++;
				k = 0;
			}
			else if(input_str[i] == '.')
				dev_word_str[j][k] = '\0';
			else {
				dev_word_str[j][k] = input_str[i];
				k++;
			}

			i++;
		}

		word_sum = j + 1;

		/* 文字列を比較して、the, that, thisのいずれかがあるか調べる。 */
		for(i = 0; i < word_sum; i++) {
			str_cp(dev_word_str[i], temp);
			temp_deff = deff_two_char(temp[0], 't');
			shift_deff(temp_deff, temp);
			if(str_comp("the", temp)) {
				if(!count_the || deff_the != temp_deff) {
					deff_the = temp_deff;
					count_the++;
				}
			}
			else if(str_comp("that", temp)) {
				if(!count_that || deff_that != temp_deff) {
					deff_that = temp_deff;
					count_that++;
				}
			}
			else if(str_comp("this", temp)) {
				if(!count_this || deff_this != temp_deff) {
					deff_this = temp_deff;
					count_this++;
				}
			}
		}

		/* 比較の結果をもとに、実際いくつずれているか調べる。 */
		if(count_the == 1)
			deff = deff_the;
		else if(count_that == 1)
			deff = deff_that;
		else
			deff = deff_this;
		
		/* 出力 */
		i = 0;
		while(input_str[i] != '\n') {
			if(input_str[i] == ' ')
				putchar(' ');
			else if(input_str[i] == '.')
				putchar('.');
			else
				printf("%c", shift_letter_deff(deff, input_str[i]));
			i++;
		}

		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 920
while True:
    H,W = map(int,input().split())
    if H==W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if j==0 or j==W-1 or i==0 or i==H-1:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
    print("")


Measured memory_bytes: 7004
N,P=map(int,input().split())
S=input()
amari=[0 for _ in range(P)]
amari[0]=1
cnt=0
num=0
if (P==5)or(P==2):
    for i in range(N-1,-1,-1):
        #print(S[i])
        if int(S[i])%P==0:
            cnt=cnt+i+1
else:
    for i in range(N-1,-1,-1):
        #print(S[i],pow(10,N-i-1))
        num=num+int(S[i])*pow(10,N-1-i,P)
        #print(num)
        index=num%P
        amari[index]=amari[index]+1
    #print(amari)
    for i in range(P):
        cnt=cnt+(max(0,amari[i])*max(0,amari[i]-1))/2
        
print(int(cnt))


Measured memory_bytes: 41904
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	ll n;
	cin >> n;
	if(n == 1) {
		cout << 0 << "\n";
		return 0;
	}
	int ub = sqrt(n);
	bool prime[ub+2] = {0};
	prime[0] = true; prime[1] = true;
	for(int i=2;i<=ub+1;i++) {
		for(int j=i+i;!prime[i] && j<=ub+1;j+=i)
			prime[j] = true;
	}
	/* for(int i=0;i<=ub;i++) */
	/* 	cout << i << " " << prime[i] << "\n"; */
	int count = 0;
	set<int> s;
	for(int i=2;n>1 && i <= ub+1;i++) {
		/* deb(i);deb(n); */
		if(!prime[i] && n % i == 0) {
			for(int z=i;n%z==0;z*=i) {
				/* deb(n); */
				/* deb(z); */
				count++;
				n /= z;
				s.insert(z);
			}
		}
	}
	/* if(n != 1 && !s.count(n)) */
	/* 	count++; */
	if(n > ub+1)
		count++;
	cout << count << "\n";
	return 0;
}



Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 3000

int n;
ll a[MAX_N];
ll dp[2][MAX_N + 1][MAX_N + 1];
bool visited[2][MAX_N + 1][MAX_N + 1];

ll rec(bool turn, int left, int right){
    if(visited[turn][left][right]) return dp[turn][left][right];
    visited[turn][left][right] = true;
    if(left == right){
        if(turn) return dp[turn][left][right] = a[left];
        else return dp[turn][left][right] = -a[left];
    }
    ll res;
    if(turn){
        res = -LINF;
        res = max(res, rec(!turn, left + 1, right) + a[left]);
        res = max(res, rec(!turn, left, right - 1) + a[right]);
    }else{
        res = LINF;
        res = min(res, rec(!turn, left + 1, right) - a[left]);
        res = min(res, rec(!turn, left, right - 1) - a[right]);
    }
    return dp[turn][left][right] = res;
}

signed main(){
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    cout << rec(true, 0, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 158208
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>


using namespace std;

long long modexp(long long x, long long n, long long mod)
{
    if (n == 0) {
        return 1;
    }

    if (n % 2 == 0) {
        return (modexp(x, n / 2, mod) * modexp(x, n / 2, mod)) % mod;
    }
    return (modexp(x, n / 2, mod) * modexp(x, n / 2, mod) * x) % mod;
}



int main()
{
    int n;
    cin >> n;
    
    vector<int> arr;
    int i, ele;
    for (i = 0; i < n; ++i) {
        cin >> ele;
        arr.push_back(ele);
    }
    unordered_map<int, int> m;

    if (n % 2 == 0) {
        for (i = 0; i < n; ++i) {
            m[arr[i]]++;
        }


        unordered_map<int, int>::iterator itr;
        for (itr = m.begin(); itr != m.end(); ++itr) {
            if (itr->first % 2 == 0) {
                cout << "0";
                exit(0);
            }
            if (itr->second != 2) {
                cout << "0";
                exit(0);
            }
            if (itr->first >= n || itr->first < 1) {
                cout << "0";
                exit(0);
            }
        }
        long long ans = modexp(2, n / 2, 1000000000 + 7);

        cout << ans;

        
    }

    else {
        for (i = 0; i < n; ++i) {
            m[arr[i]]++;
        }


        unordered_map<int, int>::iterator itr;
        int contains_zero = 0, count = 0;
        for (itr = m.begin(); itr != m.end(); ++itr) {
            if (itr->first % 2 == 1 &&itr->first!=0) {
                cout << "0";
                exit(0);
            }
            if (itr->second != 2 && itr->first!=0) {
                cout << "0";
                exit(0);
            }
            if (itr->first >= n || itr->first < 0) {
                cout << "0";
                exit(0);
            }
            if (itr->first == 0) {
                contains_zero = 1;
                count = itr->second;
            }
        }
        if (contains_zero != 1 || count != 1) {
            cout << "0";
            exit(0);
        }
        long long ans = modexp(2, (n-1) / 2, 1000000000 + 7);

        cout << ans;

    }
    

}

Measured memory_bytes: 4088
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	long long ans = 0;
	for(int i = 0; i < n - 1; i++){
		long long t = a[i] + a[i + 1];
		if(t > x){
			ans += t - x;
			a[i + 1] = max(a[i + 1] - (t - x), 0LL);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	char s[200001], t[200001];
	int	i, r;

	scanf("%s\n", s);
	scanf("%s\n", t);
	i = 0;
	r = 0;
	while (s[i] != '\0')
	{
		if (s[i] != t[i])
		{
			r++;
		}
		i++;
	}
	printf("%d\n", r);
	return (0);
}

Measured memory_bytes: 2088
#include <stdio.h>
#include <string.h>
#define LEN 128

void convert(char charNum[], int intNum[]) {
    int i, j = 0;
    for (i = (int)strlen(charNum) - 1; i >= 0 ; i --) {
        intNum[j] = (int)charNum[i] - 48;
        j ++;
    }
}

int main(int argc, const char * argv[]) {
    int dataSet;
    int count = 1;
    scanf("%d", &dataSet);
    char firstNum[LEN], secondNum[LEN];
    int fNum[LEN], sNum[LEN], sum[LEN];
    int i, j, k, l;
    while (count <= dataSet) {
        count ++;
        while (scanf("%s", firstNum) != EOF) {
            break;
        }
        while (scanf("%s", secondNum) != EOF) {
            break;
        }
        if (strlen(firstNum) > 80 || strlen(secondNum) > 80) {
            printf("overflow\n");
            continue;
        }
        for (i = 0; i < LEN; i ++) {
            fNum[i] = 0;
            sNum[i] = 0;
            sum[i] = 0;
        }
        convert(firstNum, fNum);
        convert(secondNum, sNum);
        for (i = 0; i < LEN; i ++) {
            sum[i] = fNum[i] + sNum[i];
        }
        for (i = 0; i < LEN; i ++) {
            if (sum[i] >= 10) {
                sum[i] %= 10;
                sum[i + 1] += 1;
            }
        }
        k = 0;
        j = LEN - 1;
        while (j >= 0) {
            if (sum[j] == 0 && j != 0) {
                k ++;
                j --;
            } else {
                break;
            }
        }
        if (k < LEN - 80) {
            printf("overflow");
        } else {
            for (l = LEN - k - 1; l >= 0; l --) {
                printf("%d", sum[l]);
            }
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 1976
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n==100000){
        printf("%d\n",9+900+90000);
    }
    else if(n>=10000 && n<100000){
        printf("%d\n",9+900+(n-10000)+1);
    }
    else if(n>=1000 && n<10000){
        printf("%d\n",9+900);
    }
    else if(n>=100 && n<1000){
        printf("%d\n",9+(n-100)+1);
    }
    else if(n>=10 && n<100){
        printf("%d\n",9);
    }
    else if(n>=1 && n<10){
        printf("%d\n",n);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<LL> a(n);
    bool flag = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        flag ^= a[i] < 0;
        a[i] = abs(a[i]);
    }
    LL sum = 0;
        for(auto x : a) sum += x;
    if(!flag)
    {
        cout << sum << endl;
    }
    else 
        cout << sum -2 * *min_element(a.begin(), a.end()) << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 3001; //check the limits, dummy
 
ll modExp(ll base, ll power, ll P) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2, P); cur = cur * cur; cur = cur % P;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % P;
        return cur;
    }
}
 
ll mul(ll A, ll B, int P) {
	return (A*B)%P;
}
 
ll add(ll A, ll B) {
	return (A+B)%MOD;
}
 
 
ll sub(ll A, ll B, int P) {
    return (A-B+P)%P;
}
 
ll* facs = new ll[3001];
 
 
void initFacs(int P) {
	facs[0] = 1;
	FOR(i, 1, MX) {
		facs[i] = (facs[i-1] * i) % P;
	}
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    
    
    int P; cin >> P;
    initFacs(P);
    int data[P]; F0R(i, P) cin >> data[i];
    vector<vi > partials;
    vi cur2;
    F0R(i, P) {
		 cur2.pb(data[i]);
	}
	partials.pb(cur2);
	F0R(i, P-1) {
		  vi cur;
		  F0R(j, sz(partials[i]) - 1) {
			  cur.pb(sub(partials[i][j+1], partials[i][j], P));
		  }
		  partials.pb(cur);
	  }
	  
	  
	  vi ans;
 
	  F0Rd(i, P) {
		  //X-1, X-2, ..., X-P-1
		  
		  //multiply by X-i+1
		  vi nxt(sz(ans)+1);
		  F0R(j, sz(nxt)) {
			  nxt[j] = 0;
			  if (j > 0) {
				  nxt[j] += mul(ans[j-1], P-i, P);
				  nxt[j] %= P;
			  }
			  if (j < sz(ans)) {
				  nxt[j] += ans[j];
				  nxt[j] %= P;
			  }
		  }
		  
		  ans = nxt;
		  
		  //add X
		  ans[sz(ans)-1] += mul(partials[i][0], modExp(facs[i], P-2, P), P);
		  ans[sz(ans)-1] %= P;
		  
		 
	  }
	  reverse(all(ans));
	  F0R(i, P) cout << ans[i] << " ";
	  cout << endl;
    
    return 0;
}

Measured memory_bytes: 18048
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 出力
      	if (a * b % 2 == 0) {
			System.out.println("Even");
        } else {
			System.out.println("Odd");
        }
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<"\n"
#define size(v) ((int)(v).size())
template<class T> using vec=vector<T>;
template<class T> using vvec=vec<vector<T>>;

constexpr int mod = 1e9 + 7;

void solve() {
  int N, K; cin >> N >> K;

  int s = (int)sqrt(N);
  vec<int> dp(2 * s), dq(2 * s), sz(2 * s);

  times(s, i) sz[i] = 1;
  sz[s] = N / s - s;
  times(s-1, i) sz[2 * s - 1 - i] = N / (i + 1) - N / (i + 2);

  dp = sz;

  times(K - 1, h) {
    swap(dp, dq);
    fill(begin(dp), end(dp), 0);
    times(2 * s - 1, i) (dq[i + 1] += dq[i]) %= mod;
    times(2 * s, i) dp[i] = dq[2 * s - 1 - i] * sz[i] % mod;
    // times(2 * s, i) cerr << dp[i] << "\t" << dq[i] ln;
    // cerr ln;
  }


  int ans = 0;
  times(2 * s, i) ans = (ans + dp[i]) % mod;

  cout << ans ln;
}

signed main() {
  // cin.tie(0);
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main{

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		if(Math.abs(a-c) <= d){
			System.out.println("Yes");
		}else{
			if(Math.abs(a-b) <= d && Math.abs(b-c) <= d ){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		}

	}





}






Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define MAXN 1109

using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	int x,y,Cnt = 0;
	while(n--)
	{
		scanf("%d%d",&x,&y);
		if(x==y) Cnt++;
		else Cnt = 0;
		if(Cnt==3) return printf("Yes"),0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 3748
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;
        int T = N * A;
        if(T<B) {
        	ans = T;
        }else {
        	ans = B;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<deque>
#include<cstring>
#define x first
#define y second

using namespace std;

typedef pair<int,int> PII;

const int N=1010;

char g[N][N];
int sx,sy,ex,ey;
int n,m;
int st[N][N];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int d[N][N];

int bfs(int x,int y)
{
	d[x][y]=0;
	deque<PII> q;
	q.push_front({x,y});
	st[x][y]=true;
	while(q.size())
	{
		PII t=q.front();
        q.pop_front();
        if(t.x==ex && t.y==ey) return d[t.x][t.y];
		for(int i=0;i<4;i++)
		{
			int a=t.x+dx[i],b=t.y+dy[i];
			if(a>=1 && a<=n && b>=1 && b<=m && g[a][b]=='.')
			{
				if(st[a][b]==2 || !st[a][b])
				{
					st[a][b]=1;
					q.push_front({a,b});
					d[a][b]=d[t.x][t.y]; 
				}
			}
		}
		//for(auto x:q) cout<< x.x << " " << x.y <<endl;  
		//printf("------\n");
	    for(int i=-2;i<=2;i++)
    		for(int j=-2;j<=2;j++)
    		{
    			if(i==0 && j==0) continue;
    			int a=t.x+i,b=t.y+j;
    			if(a>=1 && a<=n && b>=1 && b<=m && g[a][b]=='.')
    			{
    				if(!st[a][b])
    				{
    					st[a][b]=2;
    					q.push_back({a,b});
    					d[a][b]=d[t.x][t.y]+1;
    				}
    			}
    		}
    	//for(auto x:q) cout<< x.x << " " << x.y <<" "<<d[x.x][x.y]<<endl;
    	//printf("------\n");
	}
	return -1;
}

int main()
{
	cin>>n>>m>>sx>>sy>>ex>>ey;
	if(sx>ex) swap(sx,ex),swap(sy,ey);
	for(int i=1;i<=n;i++)  scanf("%s",g[i]+1);
	//for(int i=1;i<=n;i++) cout<< g[i] <<endl;
	cout<< bfs(sx,sy) <<endl;
	return 0; 
}

Measured memory_bytes: 12516
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int h, w;
    char a[100][100];

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        bool result = all_of(&a[i][0], &a[i][w], [](char c) {
                return c == '.';
            });
        if (result) {
            for (int j = 0; j < w; j++) {
                a[i][j] = ' ';
            }
        }
    }

    for (int j = 0; j < w; j++) {
        bool result = true;
        for (int i = 0; i < h; i++) {
            if (a[i][j] == '#') {
                result = false;
                break;
            }
        }
        if (result) {
            for (int i = 0; i < h; i++) {
                a[i][j] = ' ';
            }
        }
    }

    for (int i = 0; i < h; i++) {
        bool valid = false;
        for (int j = 0; j < w; j++) {
            if (a[i][j] != ' ') {
                cout << a[i][j];
                valid = true;
            }
        }
        if (valid) {
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;


int dp (){
}

long long n,m,a,b,c,k;
string s1,s2;

int main(){
    cin>>n;
    int l[n][3];
    cin>>l[0][0]>>l[0][1]>>l[0][2];
    for (int i=1; i<n; i++){
        cin>>l[i][0]>>l[i][1]>>l[i][2];
        l[i][0]+=max(l[i-1][1], l[i-1][2]);
        l[i][1]+=max(l[i-1][0], l[i-1][2]);
        l[i][2]+=max(l[i-1][1], l[i-1][0]);
    }
    cout<<max(l[n-1][0], max(l[n-1][1], l[n-1][2]))<<endl;
}


Measured memory_bytes: 4796
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        double N = sc.nextDouble();
                        System.out.printf("%.10f %.10f\n", N * N * Math.PI, 2. * N * Math.PI);
                }
        }
}


Measured memory_bytes: 28212
import sys
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int lcs[3001][3001];
char mov[3001][3001];
int main()
{
	fastio;
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0)
				lcs[i][j]=0;
			else
			{
				if(s[i-1]==t[j-1])
				{
					lcs[i][j]=lcs[i-1][j-1]+1;
					mov[i][j]='y';
				}
				else
				{
					if(lcs[i-1][j]>lcs[i][j-1])
					{
						lcs[i][j]=lcs[i-1][j];
						mov[i][j]='u';
					}
					else
					{
						lcs[i][j]=lcs[i][j-1];
						mov[i][j]='l';
					}
				}
			}
		}
	}
	vector<char>ans;
	while(n>0&&m>0)
	{
		if(mov[n][m]=='y')
		{
			ans.push_back(s[n-1]);
			n--;m--;
		}
		else if(mov[n][m]=='u')
		{
			n--;
		}
		else if(mov[n][m]=='l')
		{
			m--;
		}
	}
	reverse(ans.begin(),ans.end());
	for(auto u:ans)
		cout<<u;	
}

Measured memory_bytes: 44288
def tenka18_d():
    n = int(input())
    if n == 1:
        ans = ['Yes', '2', '1 1', '1 1']
        return print(*ans, sep='\n')
    if n == 2:
        return print('No')

    k = -1
    for i in range(2, int((2*n)**0.5)+2):
        if 2*n % i > 0: continue
        if 2*n // i == i - 1:
            k = i
            break
    if k == -1:
        return print('No')

    l = k-1
    res = [[l] for _ in range(k)]
    for i in range(l):
        s = l*(l+1)//2 - (l-i)*(l-i+1)//2 + 1
        arr = [x for x in range(s, s+l-i)]
        res[i] += arr
        for j in range(l-i):
            res[i+1+j].append(arr[j])

    print('Yes')
    print(k)
    for ln in res:
        print(*ln, sep=' ')

if __name__ == '__main__':
    tenka18_d()

Measured memory_bytes: 14360
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int b = k + 1; b <= n; b++) {
      ans += (b - k) * (n / b) + max(n % b - k + 1, 0);
  }
  if (k == 0) {
      ans -= n;
  }
  cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    // vector<int> A(N);
    unordered_map<int, int> A;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        A[t]++;
    }
    vector<int> b;
    for (auto const &x: A) {
        b.push_back(x.second);
    }

    sort(b.begin(), b.end());
    int drop = max(0, static_cast<int>(b.size()) - K);
    int sum = accumulate(b.begin(), b.begin() + drop, 0);

    cout << sum << endl;

    return 0;
}


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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};  // バケット
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i]) {  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;
}

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

using namespace std;

int main()
{
  string s;
  int alp[27];

  for(int i=0;i<27;i++)alp[i]=0;

  cin >> s;

  for(int i=0;i<s.size();i++)alp[s[i]-'a']++;

  for(int i=0;i<27;i++)
    if(alp[i]%2 != 0){
      cout << "No" << endl;
      return 0;
    }

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

Measured memory_bytes: 256
N,H,W = map(int,input().split())
A,B = [],[]
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)


ans = 0
for i in range(N):
    if A[i] >= H and B[i] >= W:
        ans += 1

print(ans)


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

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

    int Y;
    cin >> Y;

    int A, B, C;
    for (int i_A = N; i_A >= 0; i_A--) {
        A = i_A;
        int sum_A = i_A * 10000;
        if (sum_A > Y)
            continue;

        for (int i_B = N - i_A; i_B >= 0; i_B--) {
            B = i_B;
            C = N - i_A - i_B;

            int sum = A * 10000 + B * 5000 + C * 1000;
            if (sum == Y)
                goto MATCH;
            else
                continue;
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;

    MATCH:
        cout << A << " " << B << " " << C << endl;
    }

Measured memory_bytes: 256
import math
A,B = map(int,input().split())
"""自分の方針
素因数分解ができるならする
そうすると、両方に含まれる因数がわかる
素因数の数が答え。"""
def factriz(N):
    upper = int(math.sqrt(N))
    k = N
    ans = []
    for i in range(2,upper+2):
        if(k%i == 0):
            ans.append(i)
            while(k%i == 0):
                k = k//i
    if(k != 1):
        ans.append(k)
    return ans

A_list = set(factriz(A))
B_list = set(factriz(B))
print(len(A_list & B_list) + 1)



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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 998244353;

// code begins here

int main(){
    fast;
    
    ll n,k;
    cin>>n>>k;
    
    vector<ll> arr(n);
    for(auto &u: arr)
        cin>>u;
        
    sort(arr.begin(), arr.end());
    
    ll ans= 0;
    for(ll i=0;i<k;i++)
        ans += arr[i];
    
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << H * W - (h * W + w * H - h * w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	ll ans = 0, mi = INF;
	bool same = true;
	rep(i,n){
		cin >> a[i] >> b[i];
		if(a[i] > b[i]) chmin(mi, b[i]);
		ans += a[i];
		if(b[i] != a[i]) same = false;
	}
	if(mi < INF) ans -= mi;
	if(same) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624