akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,ans;
int main()
{
    //IOS;
    cin>>n;
    ans+=1000*(n/500);
    n%=500;
    ans+=5*(n/5);
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())
    M1 = A*X + B*Y
    M2 = C*2*min(X, Y) + (Y >= X) * (Y - X) * B + (X > Y) * (X - Y) * A
    M3 = C*2*max(X, Y)
    ans = min(M1, M2, M3)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long times;
	cin>>times;
	long long cnt=1,dif=1;
	long long sum=0;
		if(s.size()==1){
		printf("%lld\n",times/2);
		return 0;
	}
	for(int i=1;i<s.size();i++){
		while(s[i]==s[i-1]){
			if(i>=s.size())
				break;
			i++;
			cnt++;	
		}
		sum+=cnt/2;
		cnt=1;
		if(i<s.size()) dif++;
	}
	//cout<<dif<<endl;

	if(dif==1){
		printf("%lld\n",(s.size()*times)/2);
	}
	else if(s[0]==s[s.size()-1]){
		int cnt1=1,cnt2=1;
		int i=1;
		while(s[i]==s[i-1]){
			i++;
			cnt1++;
		}
		i=s.size()-1;
		while(s[i]==s[i-1]){
			i--;
			cnt2++;
		}
		//cout<<cnt1<<" "<<cnt2<<" ";
		sum=(sum-cnt1/2-cnt2/2)*times+cnt1/2+cnt2/2+(cnt1+cnt2)/2*(times-1);
		printf("%lld\n",sum);	
	}
	else printf("%lld\n",sum*times);
	return 0;
}//123

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

typedef long long ll;

using namespace std;

int main() {
	int t = 0;
	int num;
	int ans;
	while (t < 5) {
		cin >> num;
		if (num == 0) ans = t + 1;
		t++;
	}
	cout << to_string(ans) << endl;
	return 0;
}


Measured memory_bytes: 3636
/*
      author : nishi5451
      created: 11.08.2020 22:43:35
*/

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


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

}


Measured memory_bytes: 3644
/* C Tree Walk */

#include<stdio.h>

int T[26][4];/*T[n][0]=P, T[n][1]=L(left child), T[n][2]=R(right child), T[n][3]=id*/
int n;

void Preoder(int u[]);
void Inorder(int u[]);
void Postorder(int u[]);

int main(){
  int i, j;
  int id, l, r;
  int rootid;


  scanf("%d",&n); 

  /* initialize T[n][3]*/
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      T[i][j]=-1;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id][3]=id;
    T[id][1]=l;
    T[id][2]=r;
    T[l][0]=id;
    T[r][0]=id;
  }
  
  for(i=0;i<n;i++){
    if(T[i][0]==-1){
      rootid=i;
      break;
    }
  }

  printf("Preorder\n");
  Preoder(&T[rootid][0]);
  printf("\n");
 
  printf("Inorder\n");
  Inorder(&T[rootid][0]);
  printf("\n");

  printf("Postorder\n");
  Postorder(&T[rootid][0]);
  printf("\n");
  return 0;
}

void Preoder(int u[4]){
  printf(" %d",u[3]);
  if(T[u[3]][1]!=-1)Preoder(T[u[1]]);
  if(T[u[3]][2]!=-1)Preoder(T[u[2]]);
}

void Inorder(int u[4]){
  if(T[u[3]][1]!=-1)Inorder(T[u[1]]);
  printf(" %d",u[3]);
  if(T[u[3]][2]!=-1)Inorder(T[u[2]]);
}

void Postorder(int u[4]){
  if(T[u[3]][1]!=-1)Postorder(T[u[1]]);
  if(T[u[3]][2]!=-1)Postorder(T[u[2]]);
  printf(" %d",u[3]);
}


  
  
  

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int r;
	cin >> r;
	cout << r*r*3 << endl;


	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[0 for i in range(100001)]
for i in range(1,41):
    a[6*(i**2)]+=1
for i in range(1,99):
    for j in range(1,i):
        if 3*(i**2)+j**2+2*i*j<=10000:
            a[3*(i**2)+j**2+2*i*j]+=3
        if 3*(j**2)+i**2+2*i*j <=10000:
            a[3*(j**2)+i**2+2*i*j]+=3
for i in range(1,100):
    for j in range(1,i):
        if i**2+j**2+i*j+i+j>9999:
            break
        for k in range(1,j):
            if i**2+j**2+k**2+i*j+i*k+j*k>10000:
                break
            else:
                a[i**2+j**2+k**2+i*j+i*k+j*k]+=6
for i in range(1,n+1):
    print(a[i])

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par;

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    par[root(a)]=root(b);
}



    
int main()
{    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    char c;

    cin>>c;

    cout<<(char)(c+1);

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int l[n];
    int r[n];
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        ans += r[i]-l[i] + 1;
    }   
    cout << ans << endl;
    return 0;

}

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

using namespace std;

const int N = 2e5 + 6;

int n;
char s[N], t[N];

bool solve(int h, int c, char lef, char rig) {
  int l = -1, r = h;
  for (int i = n-1; i >= 0; --i) {
    if (t[i] == lef) {
      r = min(r+1, h);
    }
    if (t[i] == rig) {
      l = max(l-1, -1);
    }
    if (s[i] == rig) {
      --r;
    }
    if (s[i] == lef) {
      ++l;
    }
    // cerr << i << " : " << l << " " << r << endl;
    if (l+1 >= r) {
      // cerr << i << " " << l << " " << r << " " << endl;
      return 0;
    }
  }
  // cerr << h << endl;
  // cerr << l << " " << c << " " << r << endl;
  if (c <= l || c >= r) {
    return 0;
  }
  return 1;
}

int main() {
  int h, w;
  scanf("%d %d %d", &h, &w, &n);
  int r, c;
  scanf("%d %d", &r, &c);
  scanf("%s", s);
  scanf("%s", t);
  int res = solve(w, c-1, 'L', 'R') && solve(h, r-1, 'U', 'D');
  puts(res ? "YES" : "NO"); 
  return 0;
}


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

using ll = long long;
ll N;
string S;
int P;

ll solve() {
    if (P == 2 || P == 5) {
        ll res = 0;
        for (int i = 0; i < N; i++) if ((S[N - i - 1] - '0') % P == 0) res += N-i;
        return res;
    }

    vector<ll> val(P, 0);
    ll tenfactor = 1;
    ll cur = 0;
    val[cur]++;

    for (int i = 0; i < N; i++) {
        cur = (cur + (S[N-i-1] - '0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }

    ll res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;

    return res;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define mod 998244353ll
//using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
//#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//#endif
}
//-1 -1 1 3 -1
typedef long long ll;
typedef double ld;
typedef pair<ll, ll> pi;
typedef pair<ld, ld> pd;
typedef map<int, int> mii;
typedef __V <ll> vi;
typedef __V <pi> vpi;
typedef __V <pi> vvi;
typedef __V< __V <pi>> vvpi;
int n;
vpi ans;
bool can(int i, int j) {
	if((i+j)==(n+1-(n&1)))
		return false;
	return true;
}
int main() {
	doin();
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = i+1; j <= n; j++)
			if(can(i, j)) ans.pb({i, j});
	cout << ans.size() << "\n";
	for(auto& i : ans) cout << i.first << " " << i.second << "\n";
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = new string[3];
        for(int i = 0; i < 3; i++)
        {
            n[i] = ReadLine();
        }
        int index = 0;
        while(n[index] != "")
        {
            int next = n[index][0] - 'a';
            n[index] = n[index].Substring(1, n[index].Length - 1);
            index = next;
        }
        WriteLine($"{(char)(index + 'A')}");
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> h(n);
    rep(i, n)cin >> h[i];

    vector<vector<ll>> tnb(n);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        tnb[a].push_back(b);
        tnb[b].push_back(a);
    }

    bool looked[n] = {};

    ll ans = 0;
    rep(i, n)if(!looked[i]){
        bool ok = true;
        rep(j, tnb[i].size()){
            if(h[tnb[i][j]] >= h[i]){
                ok = false;
                break;
            }
            looked[tnb[i][j]] = true;
        }

        if(ok)ans++;
        looked[i] = true;
    }

    cout << ans << endl;
}

Measured memory_bytes: 10124
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = Integer.MIN_VALUE;
		max = Math.max(max, a + b);
		max = Math.max(max, a - b);
		max = Math.max(max, a * b);

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	string s;
	cin >> s;
	bool even, same;
	if (s.size() % 2) {
		even = false;
	}
	else {
		even = true;
	}
	if (s[0] == s[s.size() - 1]) {
		same = true;
	}
	else {
		same = false;
	}
	if (even ^ same) {
		cout << "Second" << endl;
	}
	else{
		cout << "First" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<queue>
#include<map>
#include<algorithm>
#include<iostream>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,P1> P2;

int main(){
  bool t[20][20][4][101];
  int s[20][20],c[20][20][20][20];
  int k,m,n,ns,nc,nj,sw,sh,gw,gh;
  char a,b,z;

  while(cin>>m>>n && (m || n)){
    cin >> k >> ns;
    fill(&c[0][0][0][0],&c[m-1][n-1][m-1][n-1]+1,k);

    fill(&s[0][0],&s[m-1][n-1]+1,0);
    while(ns--){
      cin>>a>>z>>sw>>k;
      s[a-'a'][sw-1] = k;
    }

    cin>>nc;
    while(nc--){
      cin>>a>>z>>sw>>b>>z>>gw;
      c[a-'a'][sw-1][b-'a'][gw-1] = c[b-'a'][gw-1][a-'a'][sw-1] = -1;
    }

    cin>>nj;
    while(nj--){
      cin>>a>>z>>sw>>b>>z>>gw>>k;
      c[a-'a'][sw-1][b-'a'][gw-1] += k;
      c[b-'a'][gw-1][a-'a'][sw-1] += k;
    }

    cin>>a>>z>>sw>>b>>z>>gw;
    sw--;gw--;
    sh = a-'a';gh = b-'a';

    fill(&t[0][0][0][0],&t[m-1][n-1][4][101]+1,false);
    t[sh][sw][0][0] = true;
    queue<P2> q;
    q.push(P2(P1(0,0),P1(sh,sw)));
    int ans = 1<<30;

    while(q.size()){
      P2 p=q.front();q.pop();
      int y = p.sc.fs,x = p.sc.sc;

      for(int dd=0;dd<4;dd++){
	if(dd==(p.fs.sc+2)%4)continue;
	int dy=y,dx=x,dt=p.fs.fs;
	if(dd==0)dx++;
	if(dd==1)dy++;
	if(dd==2)dx--;
	if(dd==3)dy--;
	if(dy<0 || dx<0 || m<=dy || n<=dx)continue;
	if(c[y][x][dy][dx]<0)continue;
	dt += c[y][x][dy][dx];
	if(dt>100)continue;
	k = s[dy][dx];
	if(k && ( ((dt/k)&1) == (dd&1) ) )continue;
	if(!t[dy][dx][dd][dt]){
	  if(dy==gh && dx==gw)ans = min(ans,dt);
	  t[dy][dx][dd][dt] = true;;
	  q.push(P2(P1(dt,dd),P1(dy,dx)));
	}
      }
    }
    cout<<ans<<endl;;
  }
}

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

int main(){
    int x;
    cin >> x;
    if(x >= 400 && x <= 599) cout << 8 << endl;
    else if(x >= 600 && x <= 799) cout << 7 << endl;
    else if(x >= 800 && x <= 999) cout << 6 << endl;
    else if(x >= 1000 && x <= 1199) cout << 5 << endl;
    else if(x >= 1200 && x <= 1399) cout << 4 << endl;
    else if(x >= 1400 && x <= 1599) cout << 3 << endl;
    else if(x >= 1600 && x <= 1799) cout << 2 << endl;
    else if(x >= 1800 && x <= 1999) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <random>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define MP(x, y) make_pair((x),(y))
#define FI first
#define SE second
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define HEIGHT(n) (sizeof(int) * 8 - __builtin_clz(n)) //height of range n segment tree
#define INF 1e9
#define INF_LL 4e18
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/
#define N 101
int n;
vi a;

void do_case() {
  a.clear();
  for (int i=0; i<2*n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i=2*n-1; i>0; i-=2) {
    cnt += a[i-1];
  }
  cout << cnt << endl;
}

int main() {
  while (cin >> n) do_case();
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    if (b-a==c-b){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<string>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LL long long
#define INF 0x3f3f3f3f
#define MAXN 800010
#define MOD 1000000007
#define EPS 1e-3
using namespace std;
char ch[2][100];
bool vis[2][100];

struct Node {
    int x,y;
};

int main() {
    int n;
    W(~scanf("%d",&n)) {
        MEM(vis,false);
        scanf("%s%s",ch[0],ch[1]);
        LL ans=0;
        UP(i,0,n) {
            if(vis[0][i])
                continue;
            int num;
            if(ch[0][i+1]==ch[0][i]) {
                if(i==0){
                    num=6;
                }else{
                    if(ch[0][i-1]==ch[1][i-1]) {
                        num=2;
                    } else {
                        num=3;
                    }
                }
                vis[0][i+1]=true;
            } else if(ch[1][i]==ch[0][i]) {
                num=3;
                if(i>0) {
                    if(ch[0][i-1]==ch[1][i-1]) {
                        num=2;
                    } else {
                        num=1;
                    }
                }
            }
            if(ans==0) {
                ans=num;
            } else {
//                cout<<num<<endl;
                ans=(ans*num)%MOD;
            }
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s[5]>'0' || s[6]>'4')
    cout << "TBD";
    else
    cout << "Heisei";
    
}

Measured memory_bytes: 256
#pragma comment(linker, ¡°/STACK:1024000000,1024000000¡±)
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

int main(){
    string S;
    cin >> S;
    int N = S.size(), MOD = 1000000007;

    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 3584
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


ll H, W;
ll dp[3001][3001];
pi parent[3001][3001];

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		string s1, s2;
		cin >> s1 >> s2;

		// dp[i][j] = LCS considering s1[1...i] and s2[1..j]

		// LCS(i, j) = 1 + LCS(i - 1, j - 1) if s1[i] == s2[j]
		// LCS(i, j) = MAX(LCS(i - 1, j), LCS(i, j - 1)) if s1[i] != s2[j]

		for (int i = 1; i <= (int) s1.size(); i++) {
				for (int j = 1; j <= (int) s2.size(); j++) {
						if (s1[i - 1] == s2[j - 1]) {
								dp[i][j] = 1 + dp[i - 1][j - 1];
								parent[i][j] = mp(i - 1, j - 1);
						} else {
								if (dp[i - 1][j] < dp[i][j - 1]) {
										dp[i][j] = dp[i][j - 1];
										parent[i][j] = mp(i, j - 1);
								} else {
										dp[i][j] = dp[i - 1][j];
										parent[i][j] = mp(i - 1, j);
								}
						}
				}
		}
		int N = s1.size();
		int M = s2.size();

		string ans = "";

		pi pos = mp(N, M);

		while (pos.f != 0 && pos.s != 0) {
				if (parent[pos.f][pos.s].f == pos.f - 1 && parent[pos.f][pos.s].s == pos.s - 1) {
						ans += s1[pos.f - 1];
				}
				pos = parent[pos.f][pos.s];
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
}

Measured memory_bytes: 140928
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,t,ans=1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> t;
    ans=ans/__gcd(ans,t)*t;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int dat[105]={};
int main(void){
	int n;
	scanf("%d",&n);
	int s=0;
	rep(i,n){
		int a;
		scanf("%d",&a);
		s+=a;
		dat[i]=a;
	}
	int ans=0;
	rep(i,n+1){
		ans=max(ans,((s-dat[i])%10==0)?0:(s-dat[i]));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())

s = [input().split() for i in range(n)]
# 整数に戻す
for i in range(n):
    s[i][1] = int(s[i][1])

c = s.copy()
s.sort()
s.append("fin")

cnt = 0
for i in range(n):
    if (s[i][0] != s[i + 1][0]):
        for j in reversed(range(i - cnt, i + 1)):
            for k in range(n):
                if s[j][1] == c[k][1]:
                    print(k + 1)
                    break
        cnt = 0
    else:
        cnt += 1


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> Pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

  string s;
  cin >> s;
  
  if( s.length() == 1) cout <<0 <<endl;
  else{
	  
	  int i = 0;
	  int j = s.length()-1;
	  
	   int ans = 0;
	   
	   while( i<j){
		   
		   if( s[i++] != s[j--]) ans++;
	   }
	  cout << ans << endl;
  } 


}




Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    private static final boolean IS_TAKAHASHI_TURN = true;

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int takahashiHP = sc.nextInt();
        int takahashiAP = sc.nextInt();

        int aokiHP = sc.nextInt();
        int aokiAP = sc.nextInt();

        boolean turn = IS_TAKAHASHI_TURN;
        while (takahashiHP > 0 && aokiHP > 0) {
            if (turn == IS_TAKAHASHI_TURN) {
                aokiHP = aokiHP - takahashiAP;
            } else {
                takahashiHP = takahashiHP - aokiAP;
            }
            turn = !turn;
        }
        System.out.println(takahashiHP > 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 35708
<?php
list($n) = ints();
$i = 1;
$ans = 0;
while (true) {
    $m = intdiv($n - $i,  $i);
    if ($m <= $i) break;
    if (($n - $i) % $i === 0) $ans += $m;
    $i++;
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16200
while True:
    A = list(input().split("\""))
    if A[0] == ".":
        break
    
    B = list(input().split("\""))

    wrong = 0
    ans = ""

    for i in range(min(len(A),len(B))):
        if i%2 == 1:
            if A[i] != B[i]:
                wrong += 1
        else:
            if A[i] != B[i]:
                wrong = 2
    if wrong == 0:
        ans = "IDENTICAL"
    elif wrong == 1:
        ans = "CLOSE"
    else:
        ans = "DIFFERENT"   
    if len(A) != len(B):
        ans = "DIFFERENT"
    print(ans)


Measured memory_bytes: 5584
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))

remain = 3
s = [0,0,0]
ans = 1
for i in a:
    k = s.count(i)
    ans *= s.count(i)
    ans %= mod
    if k == 0:
        break
    s[s.index(i)] += 1

print(ans)



Measured memory_bytes: 52908
n,x,m = map(int,input().split())
loop = []
loop.append(x)
looplist = [0]*m
looplist[x]=1
for i in range(1,m+1):
    x = x**2%m
    #print(x)
    if looplist[x]==0:
        looplist[x]=1
        loop.append(x)
    else:
        break

ss = loop.index(x)
amari = loop[:ss]
neoloop = loop[ss:]

lon = len(neoloop)

if n<=ss:
    print(sum(amari[:n]))
else:
    print(sum(amari)+(n-ss)//lon*sum(neoloop)+sum(neoloop[:(n-ss)%lon]))

Measured memory_bytes: 12244
#define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

const int MAX_N=50100;
int p[(MAX_N+1)/2];
bool isp[MAX_N+1];
 
int gen_ps(){
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=false;
    int idx=0;
    loop(i,2,MAX_N+1){
        if(!isp[i]) continue;
        p[idx++]=i;
        for(int j=i+i; j<=MAX_N; j+=i){
            isp[j]=false;
        }
    }
    return idx;
}

int main(){
    int len = gen_ps();
    int n;
    while(cin>>n && n){
        int ans = -1;
        for(int i=n;i>=0;i--){
            if(isp[i] && isp[i-2]){
                ans = i;
                break;
            }
        }
        if(ans==-1) throw;
        cout << ans-2 << " " << ans << endl;
    }
}

Measured memory_bytes: 1244
cutsub x "" = [x]
cutsub x (a : as) = 
  if a == '/' then
    x : (cutsub "" as)
  else
    cutsub (x ++ [a]) as


cut l = cutsub "" l

main = do
    input <- getLine
    let 
      [a, b, c] = map read $ cut input
    putStrLn (if (b <= 4) then "Heisei" else "TBD")


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

int N,C;

// char X[100][100];
// int dp[1000000001];
int s[114514];
int t[114514];
int c[114514];

int a[200020];
int b[200020];

int main(void){
    cin >> N >> C;
    REP(i,0,N) {
        cin >> s[i] >> t[i] >> c[i];
        // s[i] -= 0.5;
    }
    
    REP(i,1,31) {
        REP(j,0,200020) {
            a[j] = 0; // rest
        }
        REP(j,0,N) {
            if (c[j] == i) a[s[j]*2-1]++, a[t[j]*2]--; // imos
        }
        REP(j,1,200020) a[j] += a[j-1]; // acc
        REP(j,0,200020) {
            if (a[j] > 0) b[j] += 1; // acc
        }
        
    }
    
    int mx = 0;
    REP(i,0,200020) {
        if (b[i] >= mx) mx = b[i];
    }
    
    cout << mx << endl;
    

}

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

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

		if(N==0)
			break;

		int n[10]={0};
		int m=0;

		for(int i=0;i<100;i++){
			char c;
			cin>>c;

			n[i%N]++;

			if(c=='S'){
				m+=n[i%N];
				n[i%N]=0;
			}else if(c=='L'){
				n[i%N]+=m;
				m=0;
			}
		}

		sort(n,n+N);

		for(int i=0;i<N;i++){
			cout<<n[i]<<' ';
		}
		cout<<m<<endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;

#define F first
#define S second

ll n;
vector<ll> c,v;

ll find(vector<ll> tmp)
{
	if(tmp.size()==n)
	{
		ll ct=0,val=0;
		for(int i=0;i<n;i++)
		{
			if(tmp[i]==1)
			{
				ct+=c[i];
				val+=v[i];
			}
		}
		ll z=val-ct;
		return z;
	}
	else
	{
		tmp.push_back(0);
		ll x=find(tmp);
		tmp.pop_back();
		tmp.push_back(1);
		ll y=find(tmp);
		tmp.pop_back();
		return max(x,y);
		//return max(find(tmp.push_back(0)),find(tmp.push_back(1)));
	}

}
void solve()
{
	//ll n;
	cin>>n;
	c.assign(n,0);
	v.assign(n,0);
	//vector<ll> c(n),v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
	}
	vector<ll> tmp;
	ll ans=find(tmp);
	cout<<ans<<endl;
	return;
}

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


Measured memory_bytes: 256
import sys
import numpy as np

def main():
	dp =input()
	mae = int(dp[0])*10 + int(dp[1])
	ushiro = int(dp[2])*10 + int(dp[3])
	if 1 <= mae <= 12 and  1<=ushiro <= 12:
		print("AMBIGUOUS")
	elif 1 <= mae <= 12 and  (ushiro > 12 or ushiro==0):
		print("MMYY")
	elif (mae > 12 or mae ==0) and  1 <= ushiro <= 12:
		print("YYMM")
	else:
		print("NA")   
main()

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll INF = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const int inf = (int)1e9;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 300500;

int n, a[N];
multiset <int> s;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		s.insert(x);
	}

	int mn = *s.begin(), mx = *s.rbegin();

	s.erase(s.begin());
	s.erase(s.find(mx));

	a[0] = mn, a[1] = mx;
	for(int i = 2; i < n; ++i){
		int x = (a[i - 1] ^ a[i - 2]);
		if(s.find(x) != s.end())
			s.erase(s.find(x));
		else{
			cout << "No";
			return 0;
		}
		a[i] = x;
	}

	for(int i = 0; i < n; ++i){		
		if((a[(i - 1 + n) % n] ^ a[(i + 1) % n]) != a[i]){
			cout << "No";
			return 0;
		}

	}

	cout << "Yes";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

Measured memory_bytes: 5376
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
mod = 10 ** 9 + 7
res = 0
l = K * (K - 1) // 2
r = 0
for i in range(K):
  r += (N - i)
for i in range(K, N + 2):
  res += r - l + 1
  res %= mod
  l += i
  r += N - i
print(res)

Measured memory_bytes: 64008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    private int A,B,C,D,E,F;
    private void Scan()
    {
        var l=Console.ReadLine().Split(' ');
        A=int.Parse(l[0])*100;
        B=int.Parse(l[1])*100;
        C=int.Parse(l[2]);
        D=int.Parse(l[3]);
        E=int.Parse(l[4]);
        F=int.Parse(l[5]);
    }
    
    
    
    public void Solve()
    {
        Scan();
        var water=new bool[F+1];
        water[0]=true;
        var sugar=new bool[F+1];
        sugar[0]=true;
        for(int i=0;i<=F;i++)
        {
            if(water[i])
            {
                if(i+A<=F)
                {
                    water[i+A]=true;
                }
                if(i+B<=F)
                {
                    water[i+B]=true;
                }
            }
            if(sugar[i])
            {
                if(i+C<=F)
                {
                    sugar[i+C]=true;
                }
                if(i+D<=F)
                {
                    sugar[i+D]=true;
                }
            }
        }
        double max=-1;
        int ansA=-1,ansB=-1;
        double maxN=(double)E/(100+E);
        for(int i=A;i<=F;i++)
        {
            if(!water[i])continue;
            for(int j=F-i;j>=0;j--)
            {
                if(sugar[j])
                {
                    double n=(double)j/(j+i);
                    if(n>maxN)continue;
                    if(max<n)
                    {
                        ansA=j+i;
                        ansB=j;
                        max=n;
                    }
                }
            }
        }
        Console.WriteLine($"{ansA} {ansB}");
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
struct node{
	int a,b;
}q[100005];
vector <int> cur;
bool cmp(const node &x,const node &y){
	if(x.a == y.a) return x.b > y.b;
	return x.a < y.a;
}
int n,m;
bool del[100005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&q[i].a,&q[i].b);
	}
	sort(q+1,q+m+1,cmp);
	int minr = q[m].b;
	for(int i=m-1;i>=1;i--){
		if(minr <= q[i].b) del[i] = true;
		else minr = q[i].b;
	}
	for(int i=1;i<=m;i++){
		if(!del[i]) cur.push_back(i);
	}
	int ans = 0,lst = 0;
	for(int i=0;i<cur.size();i++){
		if(q[cur[i]].a > lst){
			ans++;
			lst = q[cur[i]].b-1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1660
n = int(input())
x0 = 0
y0 = 0
t0 = 0
for i in range(n):
  
  t, x, y = map(int, input().split())
  d = abs(x - x0) + abs (y - y0)
  if d > t - t0:
    print('No')
    exit()
  elif (t - t0 - d) % 2 == 1:
    print('No')
    exit()
  else:
    x0 = x
    y0 = y
    t0 = t

print('Yes')

Measured memory_bytes: 9172
HEISEI = 'Heisei'
TBD = 'TBD'

def main():
    s = input()
    s = s.split('/')
    year = int(s[0])
    month = int(s[1])
    day = int(s[2])
    if year > 2019:
        print(TBD)
    elif year < 2019:
        print(HEISEI)
    else:
        if month > 4:
            print(TBD)
        else:
            if day > 30:
                print(TBD)
            else:
                print(HEISEI)
main()


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

int main(){
    int n,k;
    cin >>n>>k;
    
    v h(n);
    rep(i,n)cin >> h[i];
    
    sort(h.begin(), h.end());
    
    ll ans = 0;
    
    rep(i,n-k)ans+=h[i];
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Color{
	int r,g,b;
	String name;

	Color(int r,int g,int b,String name){
		this.r=r; this.g=g; this.b=b;
		this.name = name;
	}

	double dist(Color c){
		return Math.sqrt( Math.pow(this.r - c.r, 2) +
											Math.pow(this.g - c.g, 2) +
											Math.pow(this.b - c.b, 2));
	}
}

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		Color color[] = {new Color(0,0,0,"black"),
											new Color(0,0,255,"blue"),
											new Color(0,255,0,"lime"),
											new Color(0,255,255,"aqua"),
											new Color(255,0,0,"red"),
											new Color(255,0,255,"fuchsia"),
											new Color(255,255,0,"yellow"),
											new Color(255,255,255,"white")};

		while(true){
			int minIndex = 0;
			double minDist = Double.MAX_VALUE;
			String s = scan.next();

			if(s.equals("0")) break;

			Color input = new Color(Integer.parseInt(s.substring(1,3),16),
															Integer.parseInt(s.substring(3,5),16),
															Integer.parseInt(s.substring(5,7),16),
															"");

			for(int i=0;i<8;i++){
				double dist = color[i].dist(input);
				if(minDist > dist){
					minIndex = i;
					minDist = dist;
				}
			}

			System.out.println(color[minIndex].name);
		}
	}
}

Measured memory_bytes: 12000
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};
const main=()=>{
  let [m,d]=tnn(2),ans=0
  for(let k=1;k<=m;k++){
    for(let i=22;i<=d;i++){
      if(k==Number(String(i)[0])*Number(String(i)[1])&&Number(String(i)[1])>=2)ans++
    }
  }
  to(ans)
}
main()


Measured memory_bytes: 7628
input()
li=list(map(int,input().split()))

a=[]

for i in range(len(li)-1):
  if li[i]>li[i+1]:
    if len(a)==0:
      a.append(i)
    else:
      a.append(i+1)
if len(a)>2:
  print('NO')
  exit()
else:
  a.append(len(li)-1)
  a.append(len(li)-1)
  temp=li[a[0]]
  li[a[0]]=li[a[1]]
  li[a[1]]=temp
for i in range(len(li)-1):
  if li[i]>li[i+1]:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto N = readln.chomp.to!int;
    int[][] RS;
    RS.length = N;
    foreach (i; 0..N) RS[i] = readln.split.to!(int[]);

    auto DP = new long[][](N, 2^^N);
    foreach (ref dp; DP) foreach (ref e; dp) e = -1;
    long solve(int i, uint s) {
        if (i == N) return 1;
        if (DP[i][s] == -1) {
            long x;
            foreach (j; 0..N) {
                if ((s & (1<<j)) == 0 && RS[i][j]) x = (x + solve(i+1, s | (1<<j))) % P;
            }
            DP[i][s] = x;
        }
        return DP[i][s];
    }
    writeln(solve(0, 0));
}

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

typedef struct{
	int q, c;	
}Problem;

typedef long long	ll;
const int N = 11;
Problem problems[N];
const int S = 1e7;
int dp[N][S];
bool used[N][S];
int d, g;
const int inf = 1e9;

int solve(int i, int s){
	if(s >= g){
		return 0LL;
	}
	
	if(i >= d){
		return inf;
	}
	
	int &ans = dp[i][s];
	
	if(used[i][s]){
		return ans;
	}
	
	used[i][s] = true;
	
	ans = inf;
	
	for(int k = 0 ; k <= problems[i].q ; k++){
		int add = 0;
		
		if(k == problems[i].q){
			add = problems[i].c;
		}
		
		ans = min(ans, k + solve(i + 1, (i + 1) * k + add + s));
	}
	
	return ans;
}

int main() {
	
	cin >> d >> g;
	
	g /= 100;
	
	for(int i = 0 ; i < d ; i++){
		cin >> problems[i].q >> problems[i].c;
		problems[i].c /= 100;
	}
	
	cout << solve(0, 0) << endl;
	
	return 0;
}

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

int main() {;
    vector<int> num{};
    int ret = 0, tmp;
    for (int i = 0; i < 3; i++) {cin >>tmp; num.push_back(tmp);}
    while (num[0] != num[1] || num[1] != num[2]) {
        sort(num.begin(), num.end());
        if (num[2]-num[0] > 1) {ret++; num[0]+=2;}
        else if (num[0]==num[1]) {ret += 1; break;}
        else if (num[0]!=num[1]) {ret += 2; break;}
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a={0,0,0};
        int i,t,j;
        for(i=0;i<3;i++){
            a[i] = sc.nextInt();
        }
        for(i=0;i<3;i++){
            for(j=i+1;j<3;j++){
                if(a[i]>a[j]){
                    t=a[i];
                    a[i]=a[j];
                    a[j]=t;
                }
            }
        }

        System.out.println(a[0]+" "+a[1]+" "+a[2]);
    }
}


Measured memory_bytes: 26216
#include <iostream>

using namespace std;

int counts[100000];

int main()
{
	int N, K, Q;
	int par;
	int ans;

	cin >> N >> K >> Q;
	ans = N;
	for (int i = 0; i < Q; i++) {
		cin >> par;
		counts[par - 1]++;
	}

	for (int i = 0; i < N; i++) {
		if (counts[i] <= Q - K) cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}

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

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = sc.nextInt();
        }

        Arrays.sort(l);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += l[n - 1 - i];
        }
        System.out.println(ans);
    }
}

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

const ll MOD = 1000000007LL;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> P(N);
  REP(i, 0, N) cin >> P[i];

  const ll PMAX = 1000001;
  vector<bool> prime(PMAX, true);
  prime[1] = false;
  REP(i, 2, PMAX) if(prime[i]) for(ll j = i + i; j < PMAX; j += i) prime[j] = false;

  vector<ll> dp1(N, 0), dp2(N, 0);
  REP(i, 0, N) {
    if(i == 0) {
      if(prime[P[i]]) (dp1[i] += 1) %= MOD;
    } else if(i == 1) {
      if(prime[P[i]] && P[i - 1] < P[i]) (dp1[i] += dp1[i - 1]) %= MOD;
      if(prime[P[i - 1]]) (dp2[i] += 1) %= MOD;
    } else if(i == 2) {
      if(prime[P[i]] && P[i - 1] < P[i]) (dp1[i] += dp1[i - 1]) %= MOD;
      if(prime[P[i]] && P[i - 2] < P[i]) (dp1[i] += dp2[i - 1]) %= MOD;
      if(prime[P[i - 1]] && P[i - 2] < P[i - 1]) (dp2[i] += dp1[i - 2]) %= MOD;
    } else {
      if(prime[P[i]] && P[i - 1] < P[i]) (dp1[i] += dp1[i - 1]) %= MOD;
      if(prime[P[i]] && P[i - 2] < P[i]) (dp1[i] += dp2[i - 1]) %= MOD;
      if(prime[P[i - 1]] && P[i - 2] < P[i - 1]) (dp2[i] += dp1[i - 2]) %= MOD;
      if(prime[P[i - 1]] && P[i - 3] < P[i - 1]) (dp2[i] += dp2[i - 2]) %= MOD;
    }
  }
  cout << (dp1[N - 1] + dp2[N - 1]) % MOD << endl;
}



Measured memory_bytes: 5204
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

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

int A,B,C,D;

int main(){
	cin>>A>>B>>C>>D;
	
	cout<<abs(A-C)+abs(B-D)-gcd(abs(A-C),abs(B-D));
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <time.h>
#include <algorithm>
#include <string>
#include <map>

using namespace std;
typedef long long int lint;

int main()
{
	lint n, mod = 1000000007;
	string s[2];
	cin >> n;
	cin >> s[0] >> s[1];
	lint N = s[0].size();

	lint state = 0, pos = 0, pattern = 1;

	while (pos < N) {
		//縦
		if (s[0][pos] == s[1][pos]) {
			if (state == 0) {
				pattern *= 3;
				pattern %= mod;
			}
			else if (state == 1) {
				pattern *= 2;
				pattern %= mod;
			}

			state = 1;
			pos++;
		}
		//横
		else {
			if (state == 0) {
				pattern *= 6;
				pattern %= mod;
			}
			else if (state == 1) {
				pattern *= 2;
				pattern %= mod;
			}
			else {
				pattern *= 3;
				pattern %= mod;
			}

			state = 2;
			pos += 2;
		}
	}

	cout << pattern << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int h,w;
   cin>>h>>w;
   string art[h];
   for(int i=0;i<h;i++){
     cin>>art[i];
   }
  for(int i=0;i<h;i++){
   cout<<art[i]<<endl<<art[i]<<endl;
  }
}


Measured memory_bytes: 256