akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		BigInteger a, b;
		int N = Integer.parseInt(input.nextLine());
		
		while(N > 0) {
			a = new BigInteger(input.nextLine());
			b = new BigInteger(input.nextLine());
			
			a = a.add(b);
			
			if(a.toString().length() > 80) {
				out.println("overflow");
			} else {
				out.println(a.toString());
			}			
			N--;
		}
		input.close();
		out.close();System.exit(0);
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>

int n,u,v,m;
int fie[2][501][501];
bool ok[2][501][501];
int card[100001];
int wx[2][1000001],wy[2][1000001];
int cnt[2];
int linex[2][501],liney[2][501],cross[2][2];

bool checkx(int v,int x){
	for(int i=0;i<n;i++){
		if(!ok[v][x][i])return false;
	}
	return true;
}

bool checky(int v,int y){
	for(int i=0;i<n;i++){
		if(!ok[v][i][y])return false;
	}
	return true;
}

bool checkc(int v,int dir){
	if(dir==0){
		for(int i=0;i<n;i++){
			if(!ok[v][i][i])return false;
		}
	}else{
		for(int i=0;i<n;i++){
			if(!ok[v][i][n-i-1])return false;
		}
	}
	return true;
}

int main(void){
	scanf("%d %d %d %d",&n,&u,&v,&m);
	if(n==1){
		u*=4;
		v*=4;
	}
	memset(wx,-1,sizeof(wx));
	memset(wy,-1,sizeof(wy));
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				scanf("%d",&fie[i][k][j]);
				wx[i][fie[i][k][j]]=k;
				wy[i][fie[i][k][j]]=j;
			}
		}
	}
	for(int i=0;i<m;i++){
		scanf("%d",&card[i]);
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<2;j++){
			if(wx[j][card[i]]!=-1){
				ok[j][wx[j][card[i]]][wy[j][card[i]]]=true;
				if(!linex[j][wx[j][card[i]]]){
					if(checkx(j,wx[j][card[i]])){
						linex[j][wx[j][card[i]]]=true;
						cnt[j]++;
					}
				}
				if(!liney[j][wy[j][card[i]]]){
					if(checky(j,wy[j][card[i]])){
						liney[j][wy[j][card[i]]]=true;
						cnt[j]++;
					}
				}
				if(wy[j][card[i]]==wx[j][card[i]]){
					if(!cross[j][0] && checkc(j,0)){
						cross[j][0]=true;
						cnt[j]++;
					}
				}
				if(wy[j][card[i]]==n-wx[j][card[i]]-1){
					if(!cross[j][1] && checkc(j,1)){
						cross[j][1]=true;
						cnt[j]++;
					}
				}
			}
		}
		//printf("%d %d\n",cnt[0],cnt[1]);
		if(cnt[0]>=u && cnt[1]>=v){
			printf("DRAW\n");
			return 0;
		}
		if(cnt[0]>=u){
			printf("USAGI\n");
			return 0;
		}
		if(cnt[1]>=v){
			printf("NEKO\n");
			return 0;
		}

	}
	printf("DRAW\n");
	return 0;
}

Measured memory_bytes: 19448
while 1:
	n=input()
	if n==0:break
	m=input()
	a=raw_input()
	P="I"+"OI"*n
	l=1+2*n
	c=0
	for i in range(m-l+1):
		if a[i:i+l]==P:c+=1
	print c
	

Measured memory_bytes: 36800
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int a[]=new int[3];
			for(int i=0;i<3;i++) {
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			int d[]=new int[2];
			for(int i=0;i<2;i++) {
				d[i]=a[2]-a[i];
			}
			int sumd=d[0]+d[1];
			if(sumd%2==0) {
				System.out.println(sumd/2);
				return;
			}
			else {
				System.out.println(sumd/2+2);
				return;
			}
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

int main(int argc, char **argv) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a ^ b ^ c) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    string s;
    cin>>s;
    int m=s.size();
    bool ok=1;
    if(m%2==1) ok=0;
    if(ok){
        rep(i,m-1){
            if(i%2==0){
                if(s[i]=='h'&&s[i+1]=='i') continue;
                ok=0;
            }
        }
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    int cnt = 1;
    vector<int> v;
    if(s[0] == '0')
        v.push_back(0);

    for(int i = 1; i < n; i++) {
        if(s[i] != s[i-1]) {
            v.push_back(cnt);
            cnt = 1;
        } else
            cnt ++;
    }

    v.push_back(cnt);


    int l = 0, r = 0, ans = -1, sum = 0, t = k;

    while(r != v.size()) {
        sum += v[r];

        if(r % 2 == 1) {
            if(t == 0) {
                sum -= v[l++];
                sum -= v[l++];
                t = 0;
            } else
                t --;
        }


        ans = max(ans, sum);

        r ++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int x = 0, y = 0;

	for (int i = 0; i < a.size(); i++)
	{
		if (i % 2 == 0)
		{
			x += a.at(i);
		}
		else
		{
			y += a.at(i);
		}
	}

	cout << x - y << endl;
}

Measured memory_bytes: 256
//q091.cpp
//Sun Sep 13 12:15:04 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	double a,b,x;
	cin >> a >> b >> x;

	double tmp = x/a;
	if (a*b/2>=tmp){
		double c = tmp*2/b;
		double d = sqrt(c*c+b*b);
		double e = d-b*(b/d);
		double ans = acos(e/c);
		ans = ans/3.1415926535*180;
		printf("%.8f\n",ans);
		return 0;
	}else {
		double c = b-(tmp*2/a-b);
		double d = sqrt(a*a+c*c);
		double e = d-c*(c/d);
		double ans = acos(e/a);
		ans = ans/3.1415926535*180;
		printf("%.8f\n",ans);
		return 0;
	}

//	printf("%.4f\n",ans);
}


Measured memory_bytes: 4064
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double t, x;
  cin >> t >> x;
  cout << (t / x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<fstream>
#include<cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define f first
#define s second

string str;

int memo[2][3][3][100010];

int solve(int next, int left, int right, int p){
  if(p == str.size() || !isdigit(str[p])) return 0;
  if(memo[next][left][right][p] != -1)
    return memo[next][left][right][p];

  int ret = 10000000;
  int nn = next;
  int tmp = 0;
  int st = (str[p]-'1') % 3;
  int l = (next == 0 ? st : left);
  int r = (next == 1 ? st : right);
  if(next == 0){
    if(st > right){
      tmp++;
      next ^= 1;
      r = st;
    }else
      l = st;
  }else{
    if(st < left){
      tmp++;
      next ^= 1;
      l = st;
    }else
      r = st;
  }

  return memo[nn][left][right][p] = tmp + solve(next^1, l, r, p+1);
}

int main(){
  while(getline(cin, str) && str[0] != '#'){
    int ans = 100000000;
    REP(i,2) REP(j,3) REP(k,3)
      memset(memo[i][j][k],-1,sizeof(int)*(str.size()+2));
    ans = min(ans, solve(0,0,2,0));
    ans = min(ans, solve(1,0,2,0));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12000
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
for i in range(N):
    cnt += min(A[i],B[i])
    a = A[i]
    A[i] = max(a-B[i],0)
    B[i] = max(B[i]-a,0)
    cnt += min(A[i+1],B[i])
    A[i+1] = max(A[i+1]-B[i],0)
print(cnt)

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

#dp[l][r] = [l, r)区間のスライムを合体するときのコストの最小値
dp = [[float("inf")]*(n+1) for i in range(n+1)]
for i in range(n):
    dp[i][i] = 0

#cost[r]-cost[l] = [l, r)区間を合計したときのスライムの総和
cost = [0]*(n+1)
for i in range(n):
    cost[i+1] = cost[i] + a[i]

#メモ化再帰でdp[0][n]求める
def dfs(l, r):
    if not isinf(dp[l][r]):
        return dp[l][r]
    elif (r - l) == 1:
        dp[l][r] = 0
        return dp[l][r]
    else:
        res = float("inf")
        for k in range(l + 1, r):
            #dp[l][k] + dp[k][r] + 合体に必要なコスト
            res = min(res, dfs(l, k) + dfs(k, r) + (cost[r] - cost[l]))
        dp[l][r] = res
    return dp[l][r]

dfs(0, n)
print(dp[0][n])


Measured memory_bytes: 49092
taro,hana = 0,0
count = gets.chomp.to_i
count.times do |i|
    wordarr = gets.chomp.split(" ").map do |s| s.to_s end
    if wordarr[0] > wordarr[1]
        taro += 3
    elsif wordarr[0] < wordarr[1]
        hana += 3
    else
        taro += 1
        hana += 1
    end
end
puts "#{taro} #{hana}"

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    if(n>=10)
        cout << r;
    else
        cout << (100*(10-n))+r;
    return 0;
}


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

int main(void){
    int N;
    int ans[7]={0,0,0,0};
    cin>>N;
    char S[N];
    for(int i=0;i<N;i++){
        cin>>S[i];
        switch(S[i]){
            case 'P':ans[0]+=1;break;
            case 'W':ans[1]+=1;break;
            case 'G':ans[2]+=1;break;
            case 'Y':ans[3]+=1;break;
        }
    }
    if(ans[0]>0&&ans[1]>0&&ans[2]>0&&ans[3]>0)
        cout<<"Four"<<endl;
    else if(ans[0]>0&&ans[1]>0&&ans[2]>0&&ans[3]==0)
        cout<<"Three"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
    
}



Measured memory_bytes: 3068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0,S[100];

void push(int);
int pop(void);
int isEmpty(void);
int isFULL(void);


int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);

    } else if ( s[0] == '-' ){
      a=pop();
      b=pop();
      push(b-a);

    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}





void push(int x)
{
  if(isFULL()==1)
    S[++top]=x;
}

int pop()
{
  if(isEmpty()==1)
  top--;
  return S[top+1];
}


int isEmpty()
{
  if(top==0)return 0;
  else return 1;
}

int isFULL()
{
  if(top>100-1)return 0;
  return 1;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 100005, M = 102, mod = 998244353, mxLog = 20;
int n, k;
int W[N];
int memo[N];
int solve(int i) {
    if (i == n - 1)
        return 0;
    int &ret = memo[i];
    if (~ret)
        return ret;
    ret = oo;
    for(int j = 1; j <= k && i + j < n; ++j) {
        ret = min(ret, solve(i + j) + abs(W[i + j] - W[i]));
    }
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(7), cout << fixed;

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> W[i];
    }
    memset(memo, -1, sizeof memo);
    cout << solve(0) << '\n';


    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] array = new int[26];

        for(int i = 0; i < array.length; i++) {
            array[i] = 0;
        }

        StringBuilder sb = new StringBuilder();

        while(sc.hasNext()) {
            sb.append(sc.nextLine().toLowerCase());
        }

        String line = sb.toString();

        for(int i = 0; i < line.length(); i++) {
            for(int j = 0; j < 26; j++) {
                if(line.charAt(i) == 'a' + j) {
                    array[j]++;
                }
            }
        }

        for(int i = 0; i < 26; i++) {
            System.out.println((char)('a' + i) + " : " + array[i]);
        }
    }
}



Measured memory_bytes: 26128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int max = Integer.MIN_VALUE;

		int gcd = 0;
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if (i == 0) {
				gcd = num;
			} else {
				gcd = gcd(gcd, num);
			}
			
			max = Math.max(max, num);
		}
		
		
		if (k % gcd == 0 && k <= max) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
		
	}
	private static int gcd(int m, int n) {
		if (n > m) { return gcd(n, m); }
		if (n == 0) { return m; }
		return gcd(n, m % n);
	}
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}

Measured memory_bytes: 37900
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,D;cin>>N>>D;
    int count=0;
    while(1){
        count++;
        N-=2*D+1;
        if(N<=0){
            break;
        }else{
            continue;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> S >> X >> Y;
	int tmp = 0, cnt = 0;
	vector<int>x, y;
	y.push_back(0);
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'T') {
			cnt++;
			if (tmp == 0) {
				if (x.size() == 0)x.push_back(0);
				continue;
			}
			if (cnt & 1)x.push_back(tmp);
			else y.push_back(tmp);
			tmp = 0;
		}
		else tmp++;
	}
	if (cnt & 1)y.push_back(tmp);
	else x.push_back(tmp);
	x.push_back(0);
	int tx = accumulate(x.begin(), x.end(), 0)-X;
	int ty = accumulate(y.begin(), y.end(), 0)-Y;
	if (tx < 0 || ty < 0) {
		cout << "No" << endl;
		return 0;
	}
	vector<vector<int>> dpx(x.size(), vector<int>(tx + 1, 0));
	vector<vector<int>> dpy(y.size(), vector<int>(ty + 1, 0));
	dpx[0][0] = 1; dpy[0][0] = 1;
	for (int i = 1; i < x.size(); i++) {
		for (int j = 0; j < tx + 1; j++) {
			dpx[i][j] |= dpx[i - 1][j];
			if (j >= 2 * x[i])
				dpx[i][j] |= dpx[i-1][j - 2 * x[i]];
		}
	}
	for (int i = 1; i < y.size(); i++) {
		for (int j = 0; j < ty + 1; j++) {
			dpy[i][j] |= dpy[i - 1][j];
			if (j >= 2 * y[i])
				dpy[i][j] |= dpy[i-1][j - 2 * y[i]];
		}
	}
	bool flag = (dpx[x.size()-1][tx] && dpy[y.size()-1][ty]);
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 60800
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (b/a > c){
      System.out.println(c);
    } else {
      System.out.println(b/a);
    }
  }
}

Measured memory_bytes: 21844
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
a_li = na()
for i in range(n):
    a_li[i] = a_li[i] - (i + 1)
m1 = statistics.median_low(a_li)
#m2 = statistics.median_high(a_li)
ans1 = 0
#ans2 = 0
for i in range(n):
    ans1 += abs(a_li[i] - m1)
    #ans2 += abs(a_li[i] - m2)
print(ans1)


Measured memory_bytes: 27260
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int gcd_3(int a, int b, int c){
    int ans = 0;
    int n = min(a, min(b, c));
    for(int i=n; i >= 1; i--){
        if(a % i == 0 and b % i == 0 and c % i == 0){
            ans = i;
            break;
        }
    }
    return ans;
}

int main() {
    int N; cin >> N;
    int res = 0;
    for(int i=1; i<N+1; ++i){
        for(int j=1; j<N+1; ++j){
            for(int k=1; k<N+1; ++k){
                res += gcd_3(i, j, k);
            }
        }
    }
    cout << res << endl;
  return 0;
}

Measured memory_bytes: 3576
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,M = mint()
if abs(N-M)>1:
    print(0)
else:
    ans = perm(N,MOD)*perm(M,MOD)*(2-abs(N-M))
    print(ans%MOD)

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

int main(){
int a=0,b=0,c=0,k=0,n=0,m=0;
cin >>a >>b >>c >>k;
if (a>=b && b>=c) {n=a;m=b+c;}
else if (a<=b && b>=c){ n=b;m=a+c;}
else {n=c;m=a+b;}
for(int i=0; i<k; i++){
n*=2;
}
cout << n+m <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum = 0; //各桁の和
  int x;
  int Nx = N; //N自体の値を変化させないため
  
  while (1) {
    x = Nx % 10;  //1桁目の数字を抽出
    sum += x;  //和に一桁目を足す
    Nx /= 10;  //繰り下げでループ
    if (Nx == 0)
      break;
  }
  
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    int ans=0;

    for(int i=0; i<n-1; i++){ //0~i番目とi+1~n-1番目に分割する
        int cnt=0;
        
        for(char c='a'; c<='z'; c++){
            bool left=false, right=false;
            for(int j=0; j<=i; j++){
                if(s[j]==c) left=true;
            }
            for(int j=i+1; j<=n-1; j++){
                if(s[j]==c) right=true;
            }

            if(left&&right) cnt++;
        }

        ans=max(ans,cnt);
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        ArrayList <Double> mou =new ArrayList <Double>();
        while (scan.hasNext()){
     mou.add(scan.nextDouble());		 
      }
        Collections.sort(mou);
        System.out.println(mou.get((mou.size()-1))-mou.get(0));
        }
      

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

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

  int ret = 0;
  rep(i,5){
    int x;
    cin >> x;
    if(x == 0) ret = i+1;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int a[300005];
int main()
{
	int k,n;
	scanf("%d%d",&k,&n);
	if(k%2==0)
	{
		printf("%d",k/2);
		for(int j=2;j<=n;j++)
			printf(" %d",k);
		printf("\n");
	}
	else
	{
		for(int i=1;i<=n;i++)
			a[i]=(k+1)/2;
		int len=n;
		for(int i=1;i<=n/2;i++)
		{
			if(a[len]==1)
				len--;
			else
			{
				for(int j=len+1;j<=n;j++)
					a[j]=k;
				a[len]--;
				len=n;
			}
		}
		for(int i=1;i<=len;i++)
		{
			if(i>=2)
				printf(" ");
			printf("%d",a[i]);
		}
		printf("\n");	
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------

string s;
int n, k;

int main(){
	cin >> n >> s >> k;
	FOR(i,0,n-1){
		if(s[i] == s[k-1]){
			cout << s[i];
		}else{
			cout << '*';
		}
	}
    return 0;
}


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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	for (int i = 0; i < 5 ; i++) {
		int x;
		cin >> x;
		if (!x) {
			cout << ++i;
			break;
		}
	}

	return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int foo = stoi(s.substr(0, 2));
  int bar = stoi(s.substr(2, 2));
  auto mm = [](int x) {
    return x >= 1 && x <= 12; 
  };
  auto yy = [](int x) {
    return x >= 0 && x <= 99;
  };
  bool ok0 = mm(foo) && yy(bar);
  bool ok1 = yy(foo) && mm(bar);
  if (ok0 && ok1) {
    cout << "AMBIGUOUS" << '\n';
  } else if (ok0 && !ok1) {
    cout << "MMYY" << '\n';
  } else if (!ok0 && ok1) {
    cout << "YYMM" << '\n';
  } else {
    cout << "NA" << '\n';
  }
  return 0;
}



Measured memory_bytes: 256
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
ans=0
for i in b:ans+=bisect.bisect_left(a,i)*(n-bisect.bisect_right(c,i))
print(ans)

Measured memory_bytes: 22580
n,k=map(int,input().split())
lr=[list(map(int,input().split())) for _ in range(k)]

mod = 998244353

dp = [0] * (n+1)
sdp = [0] * (n+1)
dp[1] = 1
sdp[1] = 1

for i in range(n+1):
  for j in range(k):
    left = max(0, i-lr[j][1])
    right = max(0, i-lr[j][0]+1)
    
    dp[i] += sdp[right] - sdp[left]
  if i+1 <= n:
    sdp[i+1] = sdp[i]%mod + dp[i]%mod

print(dp[n]%mod)

Measured memory_bytes: 26200
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

ll power(ll x, ll y) {
	if (y == 0)
		return 1;
	return x * power(x, y - 1);
}
int main() {
	run();
	int x;
	cin >> x;
	for (ll i = 0;; i++) {
		int st = -1e3, ed = 1e3;
		while (st <= ed) {
			int md = (st + ed >> 1);
			ll res = power(i, 5) - power(md, 5);
			if (res < x)
				ed = md - 1;
			else if (res > x)
				st = md + 1;
			else {
				cout << i << ' ' << md << endl;
				return 0;
			}
		}
		st = -1e3, ed = 1e3;
		while (st <= ed) {
			int md = (st + ed >> 1);
			ll res = -power(i, 5) - power(md, 5);
			if (res < x)
				ed = md - 1;
			else if (res > x)
				st = md + 1;
			else {
				cout << -i << ' ' << md << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3612
//Transit Tree Path

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<vector<P>>g(n);
    rep(i,0,n-1){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }
    int q,k;cin>>q>>k;k--;
    vector<int>d(n,-1);
    queue<tuple<int,int,int>>b;
    b.push({k,k,0});//現在、前、前からの距離
    d[k]=0;
    while(!b.empty()){
        int e=get<0>(b.front()),r=get<1>(b.front()),t=get<2>(b.front());
        b.pop();
        d[e]=d[r]+t;
        for(auto i:g[e]){
            if(d[i.first]==-1)b.push({i.first,e,i.second});
        }
    }
    rep(i,0,q){
        int z,x;cin>>z>>x;
        z--;x--;
        cout<<d[z]+d[x]<<endl;
    }
    return 0;
}

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

int main(){
  
  vector<ll> dp(31);
  dp[0] = 1;
  rep(i,31){
    if(!i) continue;
    dp[i] = dp[i-1];
    if(i>1) dp[i] += dp[i-2];
  	if(i>2) dp[i] += dp[i-3];
  }

  int year = 3650;
  rep(i,31) dp[i] = (dp[i]+year-1)/year; 
  //rep(i,31) cout << i << ":" << dp[i] << endl;
  
  int n; queue<int> q;
  while(cin >> n){
    if(!n) break;
    q.push(n);
  }
  while(!q.empty()){
    int a = q.front();
    cout << dp[a] << endl;
    q.pop();
  }
  return 0;
}



Measured memory_bytes: 3020
#include <stdio.h>
int main(void)
{
 int S,s,m,h,t;
 scanf("%d",&S);
 h=S/3600;
 t=S%3600;
 m=t/60;
 s=t%60;
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

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

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	int max = a + b;
	if(b < 0)max = a - b;
	if(a * b > max)max = a*b;
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define mp make_pair
#define pb push_back

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

mt19937 gen(34);

int n, ans;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		if (i < n - i)
			ans++;
	cout << ans;



	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))

L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        k = bisect_left(L, L[i]+L[j])
        ans += (k-j-1)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
def getSomeInputListIntn(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [str(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList
data = getSomeInputListIntn(n)

s = [int(i) for i in range(13)]
h = [int(i) for i in range(13)]
c = [int(i) for i in range(13)]
d = [int(i) for i in range(13)]

def checker(l, num):
    num = int(num)
    if l[num-1] == num-1:
        l[num-1] = -1

for suits, num in data:
    if suits == "S":
        checker(s, num)
    elif suits =="H":
        checker(h, num)
    elif suits =="C":
        checker(c, num)
    elif suits =="D":
        checker(d, num)

for i in range(13):
    if s[i] != -1:
        print("S", i+1)
for i in range(13):
    if h[i] != -1:
        print("H", i+1)
for i in range(13):
    if c[i] != -1:
        print("C", i+1)
for i in range(13):
    if d[i] != -1:
        print("D", i+1)


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

int main()
{
	int h,w;
	cin >> h >> w;
	int end=1;
	bool flag=true;
	for(int i=0;i<h;i++)
	{
		string s;
		cin >> s;
		int start=-1;
		int n_end=-1;
		for(int j=0;j<w;j++)
		{
			if(start==-1)
			{
				if(s[j]=='#')
					start=j;
			}
			else
			{
				if(s[j]=='.')
				{
					if(n_end==-1)
						n_end=j;
				}
				else
					if(n_end!=-1)
					{
						flag=false;
					}
			}
					
		}
		if(n_end==-1)n_end=w;
		if(start!=end-1)
		{
			flag=false;
		}
		end=n_end;
	}
	cout << (flag ? "Possible":"Impossible") << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
	int n;
	cin >> n;
    vector<int> vi(n);
    REP(i, n) {
        cin >> vi[i];
    }
    int ans = accumulate(ALL(vi), 0);
    ans -= *max_element(ALL(vi)) / 2;
    printf("%d", ans);
}

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

using namespace std;

#define MAX 334
typedef pair<int, int> pii;

int main()
{
    int s, d, m;
    while (cin >> s >> d >> m) {
        vector<pii> v[s];
        for (int i = 0; i < s; i++) {
            int k, w, p;
            cin >> k;
            for (int j = 0; j < k; j++) {
                cin >> w >> p;
                v[i].push_back(pii(w, p));
            }
        }

        int dp[MAX], f;
        memset(dp, -1, sizeof(dp));
        dp[m] = 0;
        for (int i = 0; i < d; i++) {
            cin >> f;
            for (int j = 0; j < (int)v[f].size(); j++) {
                for (int k = 0; k <= m; k++) {
                    if (dp[k] == -1) continue;
                    int nm = k - v[f][j].second;
                    if (nm >= 0) {
                        dp[nm] = max(dp[nm], dp[k] + v[f][j].first);
                    }
                }
            }   
        }
        
        int idx = m;
        for (int i = m-1; i >= 0; i--) {
            if (dp[i] > dp[idx]) {
                idx = i;
            }
        }
        cout << dp[idx] << " " << m - idx << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define rg register
using namespace std;
template<typename T>inline void in(T &a)
{
	T ch=getchar(),f=1;
	for(a=0;!isdigit(ch);ch=getchar())
	  ch=='-'?f=-1:f=f;
	for(;isdigit(ch);ch=getchar())
	  a=(a<<3)+(a<<1)+ch-'0';
	a*=f;
}
template<typename T>inline void print(T x)
{
	if(x<0)
	  putchar('-'),x=-x;
	if(x>9)
	  print(x/10);
	putchar(x%10+'0');
}
int a[10000];
signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<n;i++)
	  ans+=a[i];
	cout<<ans+(a[n]>>1);
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]


def bfs():
    q = [(0, 0)]
    nq = []
    m = []
    c = 1
    while len(q) > 0:
        while len(q) > 0:
            x, y = q.pop(0)
            for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
                if (H, W) == (yy + 1, xx + 1):
                    return c + 1
                if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                        (xx, yy) not in m:
                    m.append((xx, yy))
                    nq.append((xx, yy))
        q = nq
        nq = []
        c += 1
    return -1


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    c = bfs()
    if c == -1:
        print(-1)
    else:
        print(ans - c)


main()


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
 
using pear = pair<int,int>;
 
int main(){
    int n; cin >>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    deque<int> d;
    rep(i,n){
        int p = lower_bound(d.begin(),d.end(),a[i])-d.begin();
        if(p==0){
            d.push_front(a[i]);
        }else d[p-1] = a[i];
    }
    int ans = d.size();
    cout <<ans<<endl;
}

Measured memory_bytes: 1024
import collections
def hit(t):
    sort_t = sorted(t)
    return sort_t[1] == t[1]

n = int(input())
ps = [int(x) for x in input().split()]
window_ps=[]
for i in range(len(ps)-2):
    window_ps.append((ps[i],ps[i+1],ps[i+2]))

res = [hit(t) for t in window_ps]
print(collections.Counter(res)[True])

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

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

string S;

long long val[16][16];

long long num(string s) {
  long long ans = 0;
  for(int i = 0; i < s.length(); i++) {
    ans *= 10LL;
    ans += s[i]-'0';
  }
  return ans;
}

int main() {
  cin>>S;
  int len = S.length();
  REP(i,16) REP(j,16) val[i][j] = 0;
  for(int i = 0; i < S.length(); i++) {
    for(int j = i+1; j <= S.length(); j++) {
      string sub = S.substr(i,j-i);
      val[i][j]  = num(sub);
#ifdef DEBUG
      cout << i << j << " " << sub << " " << val[i][j] << endl;
#endif
    }
  }
  int bits[16];
  long long ans = 0;
  for(int mask = 0; mask < (1<<(len-1)) ; mask++) {
    vector<int> e(1,0);
    REP(m,len-1) {
      if((1<<m)&mask) {
	e.push_back(m+1);
      }
    }
    e.push_back(len);
    for(int i = 1; i < e.size(); i++) {
#ifdef DEBUG
      cout << e[i-1] << " " << e[i] << " " << val[e[i-1]][e[i]] << endl;
#endif
      ans += val[e[i-1]][e[i]];
    }
#ifdef DEBUG
    cout << "----" << endl;
#endif
  }
  cout << ans << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    vector<int> v(N + 1);
    for(int i = 1; i <= N; ++i) {
        cin >> v[i];
    }

    int t = v[1];
    for(int i = K + 1; i <= N; ++i) {
        if(v[i] > t) cout << "Yes";
        else cout << "No";
        cout << endl;
        t = v[i - K + 1];
    }
    return 0;
}


Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[] days = {-1,30,29,31,30,31,30,31,31,30,31,30,31};
		String[] week = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		while (true) {
			int m = sc.nextInt();
			int d = sc.nextInt();
			if (m == 0 && d == 0) break;
			int sum = 0;
			for (int i = 1; i <= m - 1; i++)
				sum += days[i];
			sum += m == 1 ? d - 1 : d;
			sum += 4;
			System.out.println(week[sum % 7]);
		}

	}

}

Measured memory_bytes: 17212
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>S;
    char c = *S.rbegin();
    S.append(c == 's' ? "es" : "s");
    cout<<S<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    //Minkowski
    double mp1 = 0.0;
    double mp2 = 0.0;
    double mp3 = 0.0;
    double mpi = 0.0;

    rep(i, n)
    {
        double z1 = abs(a[i] - b[i]);
        double z2 = z1 * z1;
        double z3 = z1 * z2;
        if (z1 > mpi)
            mpi = z1;
        mp1 += z1;
        mp2 += z2;
        mp3 += z3;
    }
    cout << fixed << setprecision(6) << mp1 << endl;
    cout << fixed << setprecision(6) << sqrt(mp2) << endl;
    cout << fixed << setprecision(6) << cbrt(mp3) << endl;
    cout << fixed << setprecision(6) << mpi << endl;
}


Measured memory_bytes: 3448
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] h = new int[n];
        int[] dp = new int[n];
        for(int i=0;i<n;i++)    h[i] = in.nextInt();
        dp[1] = Math.abs(h[1] - h[0]);
        solve(n, h, dp);
        System.out.println(dp[n-1]);
        in.close();
    }

    static void solve(int n, int[] h, int[] dp) {
        for(int i=2;i<n;i++)    {
            int s1 = Math.abs(h[i]-h[i-1]) + dp[i-1];
            int s2 = Math.abs(h[i]-h[i-2]) + dp[i-2];
            dp[i] = Math.min(s1, s2);
        }
    }
}

Measured memory_bytes: 57252
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();}
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);}
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}
 

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int w,b;
    cin>>w>>b;

    Vs ans(100);
    REP(i,0,100) REP(j,0,100) ans[i].pb('.');

    REP(i,0,100){
        REP(j,0,100){
            if(i%4==3 || j%4==3) ans[i][j]='#';
        }
    }
    
    bool check=false;
    if(b>w){
        swap(b,w);
        check=true;    
    }

    int count=0;
    REP(i,0,25){
        REP(j,0,25){
            count++;
            if(count<=w) continue;
            REP(k,0,3) REP(l,0,3) ans[4*i+k][4*j+l]='#';
        }
    }

    count=1;
    REP(i,0,25){
        REP(j,0,25){
            if(count>=b) break; 
            ans[4*i+1][4*j+1]='#';
            count++;
        }
        if(count>=b) break;
    }

    if(check){
        REP(i,0,100){
            REP(j,0,100){
                if(ans[i][j]=='.') ans[i][j]='#';
                else ans[i][j]='.';
            }
        }
    }

    cout<<100<<" "<<100<<endl;
    REP(i,0,100) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]) {
  bool all_visited = true;

  REP(i, n) {
    if(visited[i] == false) {
      all_visited = false;
    }
  }

  if(all_visited) {
    return 1;
  }

  int ret = 0;

  REP(i, n) {
    if(graph[v][i] == false) continue;
    if(visited[i]) continue;

    visited[i] = true;
    ret += dfs(i, n, visited);
    visited[i] = false;
  }

  return ret;
}

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

  int n,m;
  cin >> n >> m;
  REP(i, m) {
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }

  bool visited[nmax];
  REP(i, n) {
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0, n, visited) << endl;
  return 0;
}


Measured memory_bytes: 256