akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N, X, L;
    cin >> N;
    vector<vector<int>> v(N, vector<int>(2));
    rep(i, N) {
        cin >> X >> L;
        v[i] = {X + L - 1, X - L};
    }
    sort(v.begin(), v.end());
    int ans = 0, l = - 1e9 - 1;
    rep(i, N) {
        if (v[i][1] > l) {
            ans++;
            l = v[i][0];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N,K,*H = map(int,read().split())
N -= K
if N <= 0:
    print(0)
    exit()
    
H.sort()
    
print(sum(H[: N]))

Measured memory_bytes: 70664
#include <stdio.h>

#define N 100

int main(){
  int a[N],n,i,j,temp,count=0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
	count++;
      }
    }
  }
  for(i=0; i<n-1; i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2128
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		sc.close();
		
		int A = X;
		int B = Y;
		int C = Z;
		
		//System.out.printf("%d %d %d\n", A, B, C);

		Pair<Integer, Integer> model1 = new Pair<Integer, Integer>(A, B);
		A = model1.second;
		B = model1.first;

		Pair<Integer, Integer> model2 = new Pair<Integer,Integer>(A, C);
		A = model2.second;
		C = model2.first;
		
		System.out.printf("%d %d %d\n", A, B, C);
	}

	static class Pair<F, S> {
		public final F first;
		public final S second;

		Pair (F first, S second) {
			this.first = first;
			this.second = second;
		}
	}
}

Measured memory_bytes: 22868
def main():
    N=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    dp=[N]*(N+1)
    #dp[i];=i個目まで選んで交換したときの最大
    C=[B[i]-A[i] for i in range(3)]
    for i in range(N):
        dp[i+1]=max(dp[i+1],dp[i])
        for j in range(3):
            if i+1-A[j]>=0:
                dp[i+1]=max(dp[i+1],dp[i+1-A[j]]+C[j])
    M=dp[N]
    dp=[0]*(M+1)
    C=[A[i]-B[i] for i in range(3) if A[i]-B[i]>=0]
    C=[]
    b=[]
    a=[]
    for i in range(3):
        if A[i]-B[i]>=0:
            C.append(A[i]-B[i])
            b.append(B[i])
            a.append(A[i])
    B=b
    A=a
    for i in range(M):
        dp[i+1]=max(dp[i+1],dp[i])
        for j in range(len(C)):
            if i+1-B[j]>=0:
                dp[i+1]=max(dp[i+1],dp[i+1-B[j]]+C[j])
    print(M+dp[M])
if __name__=='__main__':#おまじない
  main()


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

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

ll mpow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = r * a;
    a = a * a;
    b >>= 1;
  }
  return r;
}

ll f(ll a) { return pow(a, 1 / 5); }

int main() {
  ll x, t;
  cin >> x;
  set<ll> st;
  unordered_map<ll, ll> mp;
  rep(i, 1000) {
    t = mpow(i, 5);
    st.insert(t);
    st.insert(t * -1);
    mp[t] = i;
    mp[t * -1] = i * -1;
  }
  for (ll aa : st) {
    for (ll bb : st) {
      if (aa == x + bb && aa != bb) {
        cout << mp[aa] << " " << mp[bb] << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3780
function main(input) {
  const args = input.split(' ');
  const num1 = parseInt(args[0], 10);;
  const num2 = parseInt(args[1], 10);;

  const plus = num1 + num2;
  const minus = num1 - num2;
  const multiple = num1 * num2;

  const max = plus >= minus ? (plus >= multiple ? plus : multiple) : (minus >= multiple ? minus : multiple);

  console.log(max);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

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

    //printf("%lld\n", sum);
    if(sum == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;

}

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

using namespace std ; 


int main() {
  
  int N , A , B ; 
  
  cin >> N >> A >> B ;
  
  if(A*N >= B){
    cout << B << endl ; 
  }
  else {
    cout << A*N << endl ; 
  }
  
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <cctype>
#include <utility>
#include <climits>


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


const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);


#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define pb push_back
#define fir first
#define scn second
#define ednl endl


#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
int dp[10][2];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
  reverse(s.begin(),s.end());
  for(int i = 0; s.size() > i; i++){
    if(s[i] >= '7'){
      s[i] = '3';
    }else if(s[i] >= '5'){
      s[i] = '2';
    }else if(s[i] >= '3'){
      s[i] = '1';
    }else{
      if(i+1!=s.size()){
        s[i+1]--;
        s[i] = '3';
      }else{
        s.pop_back();
      }
    }
  }
  reverse(s.begin(),s.end());
  string z = "122";
  int a = 0;
  while(z.size() <= s.size() && z!=s){
    int nw = z.size()-1;
    while(nw>=0 && z[nw]=='3')nw--;
    if(nw<0){
      z = "1"+z;
      for(int i = 0; z.size() > i; i++){
        z[i]='1';
      }
    }else{
      z[nw++]++;
      while(nw!=z.size()){
        z[nw++] = '1';
      }
    }
    bool g[3] = {0,0,0};
    for(int i = 0; z.size() > i; i++){
      g[z[i]-'1']=true;
    }
    if(g[0]&&g[1]&&g[2])a++;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

//データ数 < 2^(log2n)
constexpr ll log2n = 20;
constexpr ll sizeofn = 1 << log2n+1;
ll SegmentTree[sizeofn];
ll STconvert(ll i,ll j){
  return (1<<log2n)/(j-i+1) + i/(j-i+1);
}

ll STmerge(ll i,ll j){
  return max(i,j);
}

ll STquery(ll i,ll j){
  if(i > j)swap(i,j);
  REP(rep,0,log2n+1){
    ll p = 1 << rep;
    if(i%p == 0 && i+p-1 < j){
      return STmerge(STquery(i+p,j),SegmentTree[STconvert(i,i+p-1)]);
    }
    else if(i%p == 0 && i+p-1 <= j){
      return SegmentTree[STconvert(i,j)];
    }
  }
}

void STchange(ll i,ll j){
  SegmentTree[STconvert(i,i)] = j;
  FOR(rep,1,log2n+1){
    ll p = 1 << rep;
    SegmentTree[STconvert(i/p*p,i/p*p+p-1)] = STmerge(SegmentTree[STconvert(i/p*p,i/p*p+p/2-1)],SegmentTree[STconvert(i/p*p+p/2,i/p*p+p-1)]);
  }
}

signed main(){
    ll N;
    cin >> N;
    ll h[N],a[N];
    FOR(i,0,N)cin >> h[i];
    FOR(i,0,N)cin >> a[i];
    FOR(i,0,N){
        ll n = STquery(h[i],h[i]);
        ll dp = STquery(0,h[i]-1)+a[i];
        if(n < dp)STchange(h[i],dp);
    }
    cout << STquery(0,N) << endl;
}

Measured memory_bytes: 9984
n=int(input())
list1 = list(map(int,input().split()))

if(n>1):
    
    list1.sort()
    #print('ソート後(昇順)：{}'.format(list1))

    #list1.reverse()
    #print('ソート後(降順)：{}'.format(list1))

    tmp = (list1[0]+list1[1])/2
    for i in range(2,n):
        tmp=(tmp+list1[i])/2

    print(tmp)

else:
    print(list1[0])


Measured memory_bytes: 2940
n=int(input())
M=10**6+1
l=[]
p=[1]*M
for i in range(2,M):
  if p[i]:
    l+=[i]
    for j in range(2*i,M,i):
      p[j]=0
d={}
for k in l:
  c=0
  while n%k==0: n//=k; c+=1
  if c>0: d[k]=c
s=[1]
for i in range(2,9):
  s.append(s[-1]+i)
a=0
for i in d.values():
  for j in s:
    if j>i: break
    a+=1
print(a+(n>1))

Measured memory_bytes: 20120
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b_int = b * 100 + 0.5;

  cout << (a * b_int) / 100 << endl;
  
  return 0;
}


Measured memory_bytes: 3684
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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

int DP[1002][1002];


int grundy(int x, int y){
    if(x > y)   swap(x, y);
    int &ans = DP[x][y];
    if(ans != -1)   return ans;
    if(DP[y][x] != -1)  return ans = DP[y][x];
    ans = 0;
    if(x <= 1 && y <= 1)    return ans;
    set<int> mex;
    for(int i=2;i<=x;i+=2)
        mex.insert(grundy(x-i, y+i/2));
    for(int i=2;i<=y;i+=2)
        mex.insert(grundy(x+i/2, y-i));
    ans = 0;
    for(auto it : mex){
        if(it != ans)   break;
        ans++;
    }
    return ans;
}


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    memset(DP, -1, sizeof(DP));

    // for(int i=0;i<=100;i++){
    //     for(int j=0;j<=100;j++)
    //         if(grundy(i, j) == 0)
    //             cout<<i<<" "<<j<<" = "<<grundy(i, j)<<endl;
    //     cout<<endl;
    // }

    ll a, b;
    cin>>a>>b;
    if(abs(a-b) <= 1)   cout<<"Brown";
    else    cout<<"Alice";
    return 0;
}











Measured memory_bytes: 4224
// パスカルの三角形
package main

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

const (
	p = 1000000007
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	n := max(K, N-K+1)
	c := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		c[i] = make([]int, n+1)
	}
	c[0][0] = 1
	for i := 0; i < n+1; i++ {
		c[i][0] = 1
		for j := 1; j < i+1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % p
		}
	}

	for i := 1; i <= K; i++ {
		println(c[K-1][i-1] * c[N-K+1][i] % p)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

int main() {
	int n,k;
	cin>>n>>k;
	int a[10];
	for(int i=0;i<k;i++){
		cin>>a[i];
	}
	while(1){
		int N=n;
		bool ans=false,check=true;
		while(N){
			for(int i=0;i<k;i++){
				if(N%10==a[i]){
					check=false;
					break;
				}
			}
			if(check==false){
				break;
			}
			N=N/10;
			if(N==0){
				ans=true;
			}
		}
		if(ans){
			cout <<n;
			return 0;
		}
		n=n+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k])
					continue;
				vector<int> v;
				v.pb(arr[i]);
				v.pb(arr[k]);
				v.pb(arr[j]);
				sort(v.begin(), v.end());
				if (v[2] < v[1] + v[0])
					ans++;
			}
		}
	}
	cout << ans;

	return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int a[100001]={};
    int c;
    
    cin>>N;
    int mx=0;
    for(int i=0;i<N;i++){
        cin>>c;
        if(c!=0) a[c-1]++;
        if(c!=100000) a[c+1]++;
        a[c]++;
    }
    
    for(int i=0;i<100001;i++){
        mx=max(a[i],mx);
    }
    cout<<mx<<endl;
    
    return 0;
    
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

bool used[N];
vi g[N];
int kol = 0;

void dfs (int v, int p) {
    used[v] = 1;
    for (auto to : g[v]) {
        if (to == p) continue;
        kol++;
        if (!used[to]) dfs(to, v);
    }
}


signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
    #endif
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    int k;
    cin >> s >> k;
    if (s[0] == s.back() && k > 1) {
       string s1 = s;
       reverse(s1.begin(), s1.end());
       int pref = 0, suf = 0, i = 0, ans1 = 0;
       char c = s[0];
       while (i < s.size() && c == s[i]) i++, pref++;
       if (pref == s.size()) {
            cout << k * pref / 2;
            return 0;
       }
       c = s1[0], i = 0;
       while (i < s.size() && c == s1[i]) i++, suf++;
       int ans = pref / 2 + suf / 2;
       ans+= (k - 1) * ((pref + suf) / 2);
       for (int i = pref; i < (int )s.size() - suf; i++) {
            if (s[i] == s[i - 1]) s[i] = '1', ans1++;
       }
       cout << ans + ans1 * k;
    }
    else {
        int kol = 0;
        for (int i = 1;  i < s.size(); i++) {
            if (s[i] == s[i - 1]) s[i] = '1', kol++;
        }
        cout << kol * k;
        return 0;
    }
}


Measured memory_bytes: 23680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
const int INF = 1000000009;

int n, a, b;

int main(){
	scanf("%d%d%d", &n, &a, &b);
	if((a-b)%2 == 0){
		printf("Alice\n");
	}else{
		printf("Borys\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#define MOD 998244353
using namespace std;

int a, b, c, d;
long long dp[3001][3001];

int main()
{
	/*
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	*/

	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	dp[a][b] = 1;
	for (int i = a + 1; i <= c; i++)
		dp[i][b] = (dp[i - 1][b] * b) % MOD;
	for (int i = b + 1; i <= d; i++)
		dp[a][i] = (dp[a][i - 1] * a) % MOD;
	
	for (int i = b + 1; i <= d; i++)
		for (int j = a + 1; j <= c; j++)
		{
			dp[j][i] = (dp[j - 1][i] * i + dp[j][i - 1] * j - dp[j - 1][i - 1] * (i - 1) * (j - 1)) % MOD;
			if (dp[j][i] < 0)
				dp[j][i] += MOD;
		}

	printf("%I64d", dp[c][d]);

	return 0;
}

Measured memory_bytes: 74048
#include<stdio.h>

#define saigo 7368792

bool ok[saigo];

int all_ok(int k){
    int m=k;
    while(m<saigo){
        ok[m]=true;
        m=m+k;
    }
}

int main(){
    int m,n;
    int i;
    scanf("%d %d",&m,&n);
    while(m != 0){
        for(i=0;i<saigo;i++){
            ok[i]=false;
        }
        int nokori=n;
        for(i=m;i<saigo;i++){
            if(ok[i]==false){
                if(nokori>0){
                    ok[i]=true;
                    nokori--;
                    all_ok(i);
                } else{
                    printf("%d\n",i);
                    break;
                }
            }
        }

        scanf("%d %d",&m,&n);

    }

    return 0;
}

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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> a;

	string A = "";

	for (int j = 0; j < H; j++) {
		A = "";
		cin >> A;
		a.push_back(A);
	}

	for (int m = 0; m < W + 2; m++) cout << "#";

	cout << endl;

	for (int n = 0; n < H; n++) {
		cout << "#" << a[n*(int)a.size() / H] << "#" << endl;
	}

	for (int m = 0; m < W + 2; m++) cout << "#";

	int f;
	cin >> f;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A,B,C;

int main(){
    cin>>A>>B>>C;
    out(A+B+C-max(A,max(B,C)));
}

Measured memory_bytes: 256
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]
for i, l in enumerate(C):
    l = [x-1 for x in l]
    C[i] = l

X = [[0]*c for _ in range(3)]
for i in range(n):
    for j in range(n):
        r = (i+j)%3
        for k in range(c):
            X[r][k] += D[C[i][j]][k]
import itertools
ans = 10**18
for p in itertools.permutations(range(c), 3):
    temp = 0
    for i in range(3):
        temp += X[i][p[i]]
    ans = min(temp, ans)
print(ans)


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n; --n;
	vector<int>c(n),s(n),f(n);
	for(int i=0;i<n;++i)cin>>c.at(i)>>s.at(i)>>f.at(i);
	for(int i=0;i<n;++i){
		int ans=0;
		for(int j=i;j<n;++j){
			if(s.at(j)>ans)ans=s.at(j)+c.at(j);
			else ans+=(s.at(j)-ans%f.at(j))%f.at(j)+c.at(j);
		}
		cout<<ans<<"\n"s;
	}
	cout<<"0\n"s;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  //
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x;
    cin >> x;
    ans += ((x & 1) && (i & 1));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
int main() {
    long n, c, p[222222], dp[222222],i;
    scanf("%ld", &n);
    dp[1] = 1;
    for (i = 1; i <= n; i++)
        p[i] = -1;
    scanf("%ld", &c);
    p[c] = 1;
    for (i = 2; i <= n; i++) {
        scanf("%ld", &c);
        dp[i] = dp[i - 1];
        if (p[c] != -1 && p[c] != i - 1)
            dp[i] += dp[p[c]];
        dp[i] = dp[i] % 1000000007;
        p[c] = i;
    }
    printf("%ld", dp[n]);
    return 0;
}

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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int x; cin >> x;
	int st = 1, en = x, mid, ret = 0;
	while (st <= en) {
		mid = st + en >> 1;
		if ((long long)mid * (mid + 1) / 2 >= x) ret = mid, en = mid - 1;
		else st = mid + 1;
	}
	cout << ret << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        a[i] += a[i - 1];
    }
    int ret = 10000000;
    for (int i = 1; i < n; i++) {
        ret = std::min(ret, abs(a[n] - 2 * a[i]));
    }
    std::cout << ret << std::endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int64_t> N(n+2);
  N.at(0)=2;
  N.at(1)=1;
  for(int i=0;i<n;i++){
    N.at(i+2)=N.at(i)+N.at(i+1);
  }
  cout << N.at(n) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	cin >>n;
	set<int>a;
	int bef;
	for(int i=0;i<n;i++){
		cin >>bef;
		a.insert(bef);
	}
	
	cout<<(a.size())<<endl;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
LL s,l;
int n,a[N];
int main(){

	ios::sync_with_stdio(false);
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		a[i]=l+i-1;
		s+=a[i];
	}
	int pos=1;
	LL M =s-a[1];
	LL ma=abs(a[1]);
	for(int i=2;i<=n;i++){
		if(abs(a[i])<ma){
			ma=abs(a[i]);
			pos=i;
			M=s-a[i]
;		}
	}	
	cout<<M<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

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

Node* root, * NIL;

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

	z = (Node*)malloc(sizeof(Node));
	z->key = a;
	z->right = NIL;
	z->left = 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;
		}
	}
}

Node* find(Node* u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

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

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


int main() {
	int n, x;
	string str;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (str == "print") {
			In(root);
			printf("\n");
			Pre(root);
			printf("\n");

		}
		else if (str == "find") {
			scanf("%d", &x);
			Node* node = find(root, x);
			if (node != NIL) printf("yes\n");
			else printf("no\n");
		}
	}

	return 0;
}



Measured memory_bytes: 21940
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <queue>
#include <vector>
using namespace std;

#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

using PII = pair<int, int>;
using QII = queue<PII>;

char grid[50][50];
int dist[50][50];

int main(void) {
  int h, w, nw = 0;
  cin >> h >> w;

  rep(i, h) rep(j, w) {
    cin >> grid[i][j];
    nw += grid[i][j] == '.';
    dist[i][j] = INF;
  }

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

  QII q;
  q.push(PII(0, 0));
  dist[0][0] = 0;

  while (q.size()) {
    int x, y;

    tie(x, y) = q.front();
    q.pop();

    if (x == w - 1 && y == h - 1)
      break;

    rep(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h)
        continue;
      if (dist[ny][nx] != INF)
        continue;
      if (grid[ny][nx] == '#')
        continue;
      q.push(PII(nx, ny));
      dist[ny][nx] = dist[y][x] + 1;
    }
  }

  if (dist[h-1][w-1] == INF) cout << "-1" << endl;
  else cout << nw - dist[h-1][w-1] - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

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

signed main()
{
    int k;
    cin >> k;
    int g[201][201];

    for (int i = 1; i <= k; i++)
    {
        for (int j = i; j <= k; j++)
        {
            g[i][j] = g[j][i] = gcd(j, i);
        }
    }
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int l = 1; l <= k; l++)
            {
                ans += g[g[i][j]][l];
            }
        }
    }
    cout << ans << endl;
}

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

		// 半径 x2 * 3.14
		double b = 2 * a * Math.PI;
		// 出力
		System.out.println(b);
	}
}

Measured memory_bytes: 35948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> number(n);
  bool flag = true;
  for(int i = 0; i < n; ++i) cin >> number[i];
  for(int num: number){
    if(num % 2 != 0) continue;
    if(num % 3 == 0 || num % 5 == 0) continue;
    flag = false;
    break;
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


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

typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  LL a, b, c, k;
  cin >> a >> b >> c >> k;
  LL ans = 0;
  ans += min(k, a);
  k -= min(k, a);
  k -= min(k, b);
  ans -= min(k, c);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3640
import itertools

H,W,K = map(int,input().split())
C = [0]*H
for i in range(H):
    C[i] = input()

ans = 0
for HH in itertools.product((0,1),repeat=H):
    for WW in itertools.product((0,1),repeat=W):
        a = 0
        for h in range(H):
            for w in range(W):
                if HH[h] and WW[w] and C[h][w] == "#":
                    a += 1
        if a == K:
            ans += 1

print(ans)

Measured memory_bytes: 68412
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll K;
  cin >> K;
  cout << lcm(K, 360) / K << endl;
}

Measured memory_bytes: 3632
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func ReadLineStdin() string {
	scanner.Scan()
	str := scanner.Text()
	return strings.TrimSpace(str)
}

func StringToInt(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	N := StringToInt(ReadLineStdin())

	res := 0
	counter := map[string]int{}
	for i := 0; i < N; i++ {
		tmp := strings.Split(ReadLineStdin(), "")
		sort.Strings(tmp)
		s := strings.Join(tmp, "")

		if _, ok := counter[s]; ok {
			res += counter[s]
			counter[s]++
		} else {
			counter[s] = 1
		}
	}
	fmt.Println(res)
}



Measured memory_bytes: 11776
#include <bits/stdc++.h>
//繝?せ繝?using namespace std;

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

Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int w, h;
string s[100];
string dp[100][100];

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

bool c(int y, int x) {
	return s[y][x] >= '0'&&s[y][x] <= '9';
}

//void solve(int y, int x, string num) {
//	if (c(y, x)) {
//		if (num.size() == 0) {
//			if(s[y][x] != '0')num += s[y][x];
//		}
//		else num += s[y][x];
//	}
//	else return;
//	if (dp[y][x].size() > num.size())return;
//	else {
//		if (dp[y][x] >= num)return;
//	}
//	dp[y][x] = num;
//	REP(i, 2) {
//		int ny = y + dy[i], nx = x + dx[i];
//		if (ny >= 0 && ny < h&&nx >= 0 && nx < w) {
//			solve(ny, nx, num);
//		}
//	}
//}
//

int main() {
	while (cin >> w >> h&&w + h) {
		REP(i, h)cin >> s[i];
		REP(i, 100)REP(j, 100)dp[i][j] = "";
		REP(i, h)REP(j, w) {
			if (c(i, j))dp[i][j] = s[i][j];
			else dp[i][j] = "";
		}
		REP(i, h) {
			REP(j, w) {
				REP(k, 2) {
					int ny = i + dy[k], nx = j + dx[k];
					if (ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
					if (dp[i][j] != "0"&&c(ny, nx)) {
						string t = dp[i][j] + s[ny][nx];
						if (dp[ny][nx].size() < t.size())dp[ny][nx] = t;
						else if (dp[ny][nx].size() == t.size()) {
							if (dp[ny][nx] < t)dp[ny][nx] = t;
						}
					}
				}
			}
		}
		string ans[1000];
		REP(i, 1000)ans[i] = "";
		REP(i, 100) {
			REP(j, 100) {
				//if (!dp[i][j].empty())cout << dp[i][j] << " ";
				ans[dp[i][j].size()] = max(ans[dp[i][j].size()], dp[i][j]);
			}
			//cout << endl;
		}
		for (int i = 1000 - 1; i >= 0; i--) {
			if (!ans[i].empty()) {
				cout << ans[i] << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3364
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();
        System.out.println(a%2+b%2+c%2==3?Math.min(Math.min(a*b,b*c),c*a):0);
    }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll h,w,k;
void Main(){
    cin>>h>>w>>k;
    string s[h];
    bool flag[h],kousin=true;
    For(i,0,h) flag[i]=false;//いちごが乗っているか
    For(i,0,h){
        cin>>s[i];
        For(j,0,w){
            if(s[i][j]=='#') flag[i]=true;
        }
        kousin=kousin&&flag[i];
    }
    int ans[h][w];
    For(i,0,h){
        For(j,0,w){
            ans[i][j]=0;
        }
    }  
    int now=1;
    For(i,0,h){
        if(flag[i]==false) continue;
        int strawberry=0;
        For(j,0,w){
            ans[i][j]=now;
            if(s[i][j]=='#'){
                strawberry=j;
                now++;
            }
       }
        if(strawberry<w-1){
            For(j,strawberry,w){
                ans[i][j]=now-1;
            }
        }
   }
   while(kousin==false){
       kousin=true;
       For(i,0,h){
           if(ans[i][0]==0){
               if(ans[i-1][0]!=0&&i>0){
                   For(j,0,w) ans[i][j]=ans[i-1][j];
               }
               else if(ans[i+1][0]!=0&&i<h-1){
                   For(j,0,w) ans[i][j]=ans[i+1][j];
               }
               kousin=false;
           }
       }
   }
    For(i,0,h){
        For(j,0,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }    
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 1280
a=input()
b=input()
c=input()

x=a[0]
a=a[1:]
while True:
  if x=="a":
    if a=="":
      print("A")
      break
    else:
      x=a[0]
      a=a[1:]
  elif x=="b":
    if b=="":
      print("B")
      break
    else:
      x=b[0]
      b=b[1:]
  elif x=="c":
    if c=="":
      print("C")
      break
    else:
      x=c[0]
      c=c[1:]

Measured memory_bytes: 9076
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    ll b = abs(A - B);
    bool ok = false;
    rep(i, 0, N-1){
        ll p = i; ll m = N-1 - i;
        ll mn = C*p - D*m, mx = D*p - C*m;
        if(mn <= b&&b <= mx){
            ok = true;
        }
    }
    if(ok){
        prtl("YES");
    }else{
        prtl("NO");
    }
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N;
    cin >> N;
    ll now;
    rep1(i, N) if(i * (i + 1) / 2 >= N){
        now = i;
        break;
    }

    rep1(i, now){
        if(i != now * (now + 1) / 2 - N){
            print(i);
        }
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int a,b;cin>>a>>b;
	cout<<(a*b)/(__gcd(a,b));
	
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
int main(){ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
int q,t,f,k=0;
char ch;
cin>>s;
cin>>q;
while(q--){
    cin>>t;
    if(t==1){k=k^1;
    }else{
        cin>>f;
        cin>>ch;
        if(f==1){
            if(k){s+=ch;}
            else{s.insert(s.begin()+0,ch);}
        }
        else{if(k){s.insert(s.begin()+0,ch);}
            else{s+=ch;}
        }
    }
}
if(k){reverse(s.begin(),s.end());}
cout<<s;
    return 0;}


Measured memory_bytes: 912
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	static ArrayList<ArrayList<Integer>> list1=new ArrayList<>();
	static ArrayList<ArrayList<Integer>> list2=new ArrayList<>();
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int r=s.nextInt();
		int c=s.nextInt();
		int k=s.nextInt();
		
		char[][] arr=new char[r][c];
		
		for(int i=0;i<r;i++)
		{
			String str=s.next();
			
			for(int j=0;j<c;j++)
			{
				arr[i][j]=str.charAt(j);
			}
		}
		
		int black=0;
		
		for(int i=0;i<r;i++)
		{
			for(int j=0;j<c;j++)
			{
				if(arr[i][j]=='#')
				{
					black++;
				}
			}
		}
		
		int ans=0;
		
		ArrayList<Integer> temp=new ArrayList<>();
		
		find(0,r,temp,0);
		find(0,c,temp,1);
		
		for(int i=0;i<list1.size();i++)
		{
			for(int j=0;j<list2.size();j++)
			{
				int[][] visited=new int[r][c];
				
				ArrayList<Integer> row=list1.get(i);
				ArrayList<Integer> col=list2.get(j);
				
				int count=0;
				
				for(int l=0;l<row.size();l++)
				{
					int q=row.get(l);
					
					for(int m=0;m<c;m++)
					{
						if(visited[q][m]==0&&arr[q][m]=='#')
						{
							count++;
						}
						
						visited[q][m]=1;
					}
				}
				
				for(int l=0;l<col.size();l++)
				{
					int q=col.get(l);
					
					for(int m=0;m<r;m++)
					{
						if(visited[m][q]==0&&arr[m][q]=='#')
						{
							count++;
						}
						
						visited[m][q]=1;
					}
				}
				
				if(black-count==k)
					ans++;
				
			}
		}
		
		System.out.println(ans);
		
	}
	
	public static void find(int curr,int r,ArrayList<Integer> temp,int which)
	{
		if(curr==r)
		{
			ArrayList<Integer> add=new ArrayList<>();
			
			for(int i=0;i<temp.size();i++)
			{
				add.add(temp.get(i));
			}
			
			if(which==0)
				list1.add(add);
			else
				list2.add(add);
			
			return;
		}
		
		temp.add(curr);
		find(curr+1,r,temp,which);
		
		if(temp.size()>0)
		temp.remove(temp.size()-1);
		
		find(curr+1,r,temp,which);
		
	}
	
}

Measured memory_bytes: 39280
#include<iostream>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int matrix[n+1][m+1];
  for(int i=0;i<n;i++)
    {
      for(int k=0;k<m;k++)
	{
	  cin>>matrix[i][k];
	}
    }
      int row[200]={0};
      for(int i=0;i<m;i++)
    {
      cin>>row[i];
    }
  int col[200]={0};
  for(int i=0;i<n  ;i++)
    {
      for(int k=0;k<m;k++)
	{
	  col[i]=col[i]+matrix[i][k]*row[k];
	}
      cout<<col[i]<<endl;
    }
  return 0;
}



Measured memory_bytes: 3140
#include <iostream>

int main() {
  unsigned long d, n;

  std::cin >> d;
  std::cin >> n;

  if (n != 100) {
    unsigned long ans = n;

    for (size_t i=0; i<d; i++)
      ans *= 100;

    std::cout << ans << std::endl;
  } else {
    switch (d) {
    case 0:
      std::cout << 101 << std::endl;
      break;
    case 1:
      std::cout << 10100 << std::endl;
      break;
    case 2:
      std::cout << 1010000 << std::endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;
    int maxv = max(P,Q);
    maxv = max(maxv,R);
    cout << P+Q+R-maxv << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,tot;
long long now[25007],b[25007];
long long calc(long long x)
{
	long long res=0;
	while (x>0)
	{
		res+=(x%10);
		x/=10;
	}
	return res;
}
int main()
{
	long long noww=0,del=1;
	for (int i=0;i<=15;i++)
	{
		for (int j=0;j<1000;j++)
			if (1LL*j*del+noww<=1000000000000000LL) now[++tot]=1LL*j*del+noww;
		noww+=9LL*del;
		del=10LL*del;
	}
	sort(now+1,now+tot+1);
	int cnt=1;
	for (int i=2;i<=tot;i++)
		if (now[i]!=now[cnt]) now[++cnt]=now[i];
	tot=cnt;
	scanf("%d",&n);
	for (int i=1;i<=tot;i++)
		b[i]=calc(now[i]);
	for (int i=1;i<=tot;i++)
	{
		bool check=true;
		for (int j=i+1;j<=tot;j++)
			if (1LL*now[j]*b[i]<1LL*now[i]*b[j]) 
			{
				check=false;
				break;
			}
		if (check&&now[i]!=0)
		{
			--n;
			printf("%lld\n",now[i]);
			if (n==0) return 0;
		}
	}
	return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL dp[2005][2005];

bool check(PLL x,PLL y)
{
    if(x.SE == y.SE)return x.FI < y.FI;
    return x.SE > y.SE;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,j,n,x,ans=0;
    V<PLL>v;
    v.emplace_back(0,0);
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> x;
        v.emplace_back(i,x);
    }
    sort(v.B+1,v.E,check);
    for(i=1;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]+v[i].SE*abs(v[i].FI-(n-i+1));
        for(j=1;j<i;j++)dp[i][j]=max(dp[i-1][j-1]+v[i].SE*abs(v[i].FI-j),dp[i-1][j]+v[i].SE*abs(v[i].FI-(n-i+j+1)));
        dp[i][i]=dp[i-1][i-1]+v[i].SE*abs(v[i].FI-i);
    }
    for(i=1;i<=n;i++)ans=max(ans,dp[n][i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    string T;
    cin >> T;
    for(int i = 0; i < T.size(); i++){
        if (T[i] == '?') T[i] = 'D';
    }
    cout << T;
    return 0;
}


Measured memory_bytes: 3768
S = input()[::-1]
s1 = "dream"[::-1]
s2 = "dreamer"[::-1]
s3 = "erase"[::-1]
s4 = "eraser"[::-1]
index = 0
ret = False
while True:
    if S[index : index + len(s2) :] == s2:
        index += len(s2)
    elif S[index : index + len(s4) :] == s4:
        index += len(s4)
    elif S[index : index + len(s1) :] == s1 or S[index : index + len(s3) :] == s3:
        index += len(s1)
    else:
        break
    if index == len(S):
        ret = True
        break
print("YES" if ret else "NO")


Measured memory_bytes: 3188
#include <iostream>
#include <array>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;


int main()
{
	int W, H, N, x_zero = 0, y_zero = 0;
	cin >> W >> H >> N;
	for (size_t i = 0; i < N; i++)
	{
		int xi, yi, ai;
		cin >> xi >> yi >> ai;
		if (ai == 1 && x_zero < xi) { x_zero = xi; }
		if (ai == 2 && W > xi) { W = xi; }
		if (ai == 3 && y_zero < yi) { y_zero = yi; }
		if (ai == 4 && H > yi) { H = yi; }
	}
	int h = H - y_zero, w = W - x_zero;
	if (h <= 0 || w <= 0){ cout << "0" << endl; return 0;}
	cout << (h*w) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
#define N 12000
int pre[N];
int n,m;
struct Edge{
	int u,v;
	double len;
}edge[N*N/2];
struct Node
{
	double x,y;
 } node[N];
int cmp(Edge a,Edge b)
{
	return a.len>b.len;
}
double dis(Node a,Node b)//两点的距离 
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void init(int n)
{
	for(int i=1;i<=n;i++)
	{
		pre[i]=i;
	}
}
int find(int x)
{
	if(pre[x]==x)
	return x;
	else return pre[x]=find(pre[x]);
}
void mix(int x,int y)
{
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy)
	{
		pre[fx]=fy;
	}
}
double kruskal()
{
	init(n);
	sort(edge,edge+m,cmp);
	double s=0.0;//记录不用抹去的边,求最大生成树 ，树没有环，树权值最大 说明去掉的就最少
	for(int i=0;i<m;i++)
	{
		Edge e=edge[i];
		if(find(e.u)!=find(e.v))
		{
			mix(e.u,e.v);
			s+=e.len;
		}
	 } 
	 return s;
}
int main()
{
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		int a,b;
		for(int i=1;i<=n;i++)
		{
			scanf("%lf%lf",&node[i].x,&node[i].y);
		}
		double sum=0.0;//巫婆围得的总边和
		for(int i=0;i<m;i++)
		{
			scanf("%d%d",&a,&b);
			edge[i].u=a;
			edge[i].v=b;
			edge[i].len=dis(node[a],node[b]);
			sum+=edge[i].len;
		 }
		 double s=kruskal();
		 double ans=0.0;
		 ans=sum-s;
		 printf("%.3lf\n",ans); 
	}return 0;
}


Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007

signed main()
{
    int T,n,i,j;
    cin>>n>>T;
    int dp1[n+1][T];
    int a[n],b[n];
    for(i=0;i<n;i++) cin>>a[i]>>b[i];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<T;j++)
        {
            if(i==0 || j==0) dp1[i][j]=0;
            else if(a[i-1]<=j)
                dp1[i][j] = max(b[i-1]+dp1[i-1][j-a[i-1]],dp1[i-1][j]);
            else dp1[i][j]=dp1[i-1][j];
            //cout<<dp1[i][j]<<" ";
        }
       // cout<<endl;
    }
    for(i=0;i<(n/2)+(n%2);i++) {swap(a[i],a[n-1-i]);swap(b[i],b[n-1-i]);}
    int dp2[n+1][T];
   // cout<<"dp2"<<endl;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<T;j++)
        {
            if(i==0 || j==0) dp2[i][j]=0;
            else if(a[i-1]<=j)
                dp2[i][j] = max(b[i-1]+dp2[i-1][j-a[i-1]],dp2[i-1][j]);
            else dp2[i][j]=dp2[i-1][j];
            //cout<<dp2[i][j]<<" ";
        }
        ////cout<<endl;
    }
    int ans = dp1[n][T-1];
    for(i=0;i<n;i++)
    {
        for(j=0;j<T;j++) {//cout<<"index "<<i<<","<<j<<endl;cout<<dp1[i][j]<<","<<dp2[n-1-i][T-1-j]<<endl;
                ans=max(ans,b[n-1-i]+dp1[i][j]+dp2[n-1-i][T-1-j]);}
    }
    cout<<ans;
}


Measured memory_bytes: 140928
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string s1, s2, s3;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s1 >> s2 >> s3;

  cout << "A" << s2[0] << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll k,ans=0;
cin>>k;
for(ll i=1;i<=k;i++)
{
    for(ll j=1;j<=k;j++)
    {
        for(ll m=1;m<=k;m++)
        {
          ans=ans+__gcd(__gcd(i,j),m);  
        }
    }
}
cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>

int main(void)
{

		int a, b,c,d;

		scanf("%d %d %d %d", &a, &b,&c,&d);
		while (1)
		{
			c -= b;
			if (c<=0) {
				printf("Yes");
				return 0;
			}
			a -= d;
			if (a <= 0) {
				printf("No");
				return 0;
			}
		}
	
}

Measured memory_bytes: 1732