akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()

cnts = [0]*(N+1)
cnts[-1] = 3

ans = 1
for a in AA:
    ans *= (cnts[a-1] - cnts[a])
    ans %= mod
    cnts[a] += 1


print(ans)


Measured memory_bytes: 15412
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  int num = -1;
  int num2 = -1;
  int num3 = 0;
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  for(int i = 0;i < N;++i){
    num = max(num,A[i]);
  }
  
  for(int i = 0;i < N;++i){
    if(A[i] == num && num3 == 0){
      num3++;
      continue;
    }
    else{
      num2 = max(num2,A[i]);
    }
  }
  
  for(int i = 0;i < N;++i){
    if(A[i] == num){
      cout << num2 << endl;
    }
    else{
      cout << num << endl;
    }
  }
}





Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            
           if (n <= 999)
                Console.WriteLine("ABC");
           else
                Console.WriteLine("ABD");
        }
    }
}



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

using namespace std;


int main()
{
  int A, B;
  cin >> A >> B;
  (A += 11) %= 13;
  (B += 11) %= 13;
  if(A == B) cout << "Draw" << endl;
  else if(A > B) cout << "Alice" << endl;
  else cout << "Bob" << endl;

}

Measured memory_bytes: 256
#define c(a,b,c,d,e,f)(c-a)*(f-b)-(e-a)*(d-b)
main(){float d,e,f,g,h,i,m,n,o,p,q;for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);puts(o*p>0&&p*q>0?"YES":"NO"))o=c(d,e,f,g,m,n),p=c(f,g,h,i,m,n),q=c(h,i,d,e,m,n);return 0;}

Measured memory_bytes: 0
// B - Bitter Alchemy
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,X; cin>>N>>X;
	vi M(N);
	int all_m = 0;
	rpz(i, N){
		cin>>M[i];
		all_m += M[i];
	}
	X -= all_m;
	sort(all(M));
	int ans = N + X/M[0];
	cout<< ans <<endl;
}

Measured memory_bytes: 256
using System.Linq;
using System;
class A{
static void Main()
{bool flag=false;
int c=0;string a=Console.ReadLine();
int N=0;int S=0;int W=0;System.Int32 E=0; 
for(int i=0;i<a.Length;i++){
string y=a.Substring(i,1);
if(y=="N"){N++;}
if(y=="S"){S++;}
if(y=="E"){E++;}
if(y=="W"){W++;}
}
if((N>0&&S>0)||(N==0&&S==0)){c++;}
if((E>0&&W>0)||(W==0&&E==0)){c++;}
if(c==2){flag=true;}
Console.WriteLine(flag?"Yes":"No");
}
}

Measured memory_bytes: 13140
import sys
# input = sys.stdin.readline
inf = 10 ** 18

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

x = [xi for xi, yi in xy]
y = [yi for xi, yi in xy]

ans = inf
for i in range(N - 1):
    xi, yi = xy[i]
    for j in range(i + 1, N):
        xj, yj = xy[j]
        #
        p = xj - xi
        q = yj - yi
        #
        ans_tmp = 0
        for n, (xn, yn) in enumerate(xy):
            xm = xn - p
            ym = yn - q
            # print("##", (xm, ym))
            if [xm, ym] not in xy: ans_tmp += 1
        #
        # print("#", xy, ans_tmp)
        if ans > ans_tmp: ans = ans_tmp

if N == 1:
    print(1)
else:
    print(ans)

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

int main()
{
    string s;
    cin>>s;
    int x=0;
    for(char c:s)   
        x+=(c-'0');
    x%=9;
    if(x==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

int main(){
  int D;
  cin >> D;
  if(D==25){
    cout << "Christmas" << endl;
  }else if (D==24){
    cout << "Christmas Eve" << endl;
  }else if (D==23){
    cout << "Christmas Eve Eve" << endl;
  }else if (D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
    ll n; cin >> n;
	vector<int>a(n), b(n), c(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	a.push_back(INF);
	c.push_back(INF);
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		auto iter1 = lower_bound(a.begin(), a.end(), b[i]);
		auto iter2 = upper_bound(c.begin(), c.end(), b[i]);
		ll key1 = iter1 - a.begin();
		ll key2 = n - (iter2 - c.begin());
		res += (key1 * key2);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let sum = Array.fold_left ( + ) 0 as_ in
  print_endline @@ try
    if 0 < sum * 2 mod (n * (n + 1)) then raise Not_found;
    let ops = sum * 2 / (n * (n + 1)) in
    let xs = Array.init n @@ fun i ->
      let d = as_.(i) - as_.((i + 1) mod n) + ops in
      if d < 0 || 0 < d mod n then raise Not_found; d / n in
    if Array.fold_left ( + ) 0 xs <> ops then raise Not_found;
    "YES"
  with Not_found -> "NO"


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
#define rep(i, n) for(i = 0; i < (n); i++)
#define rrep(i, n) for(i = (n - 1); i >= 0; i--)
using namespace std;
int allprime[10000005]={0};

void sieve_of_divisors_upto_10e6()
{
    int n=10000000;
    for(int i=1;i<=n;i++)
    {
        allprime[i]=2;
    }
    allprime[1]=1;
    int p;
    for(p=2;p<=n;p++)
    {
        for(int i=2*p;i<=n;i+=p)
        {
            allprime[i]++;
        }
    }
}

void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
    return 0;
}
void solve1()
{
    int n;
    cin>>n;int ans=0;
    sieve_of_divisors_upto_10e6();
    for(int i=1;i<=n;i++)
    {
        ans+=i*allprime[i];
    }cout<<ans<<endl;
    //cout<<allprime[100]<<endl;
}


Measured memory_bytes: 81732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n;
int a[N],b[N],c[N];
int dp1[N],dp2[N],dp3[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();

	for(int i=1;i<=n;++i){
		a[i]=read();
		b[i]=read();
		c[i]=read();
	}

	for(int i=1;i<=n;++i){
		dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=c[i]+max(dp1[i-1],dp2[i-1]);
	}

	printf("%d\n",max({dp1[n],dp2[n],dp3[n]}));

    return 0;
}

Measured memory_bytes: 6076
#include <iostream>
#include <cmath>
#include <set>
#include <vector>

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

using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  auto board = vector<vector<int>>(h, vector<int>(w, 1));
  REP(p, h) {
    REP(q, w) {
      char c;
      cin >> c;
      board[p][q] = c == '#' ? 1 : 0;
    }
  }
  auto yoko = vector<vector<int>>(h, vector<int>(w, 0));
  auto tate = vector<vector<int>>(h, vector<int>(w, 0));
  REP(i, h) {
    int succ = 0;
    REP(j, w + 1) {
      if (j == w || board[i][j]) {
        REP(k, succ) {
          yoko[i][j-k-1] = succ;
        }
        succ = 0;
      } else {
        succ += 1;
      }
    }
  }
  REP(j, w) {
    int succ = 0;
    REP(i, h + 1) {
      if (i == h || board[i][j]) {
        REP(k, succ) {
          tate[i-k-1][j] = succ;
        }
        succ = 0;
      } else {
        succ += 1;

      }
    }
  }
  int max_score = 0;
  REP(i, h) {
    REP(j, w) {
      int score = yoko[i][j] + tate[i][j];
      max_score = max(max_score, score);
    }
  }
  // REP(i, h) {
  //   REP(j, w) {
  //     printf("%d", yoko[i][j]);
  //   }
  //   printf("\n");
  // }
  // printf("\n");
  // REP(i, h) {
  //   REP(j, w) {
  //     printf("%d", tate[i][j]);
  //   }
  //   printf("\n");
  // }
  // printf("\n");
  // REP(i, h) {
  //   REP(j, w) {
  //     printf("%d", board[i][j]);
  //   }
  //   printf("\n");
  // }

  cout << max_score - 1;
}


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

int n;
string str;
int t[26];
map<int,int> mp;
int ans=-1;

int main(){
  cin>>n>>str;
  for(int i=0;i<n;i++){
    if(str[i]=='+')continue;
    t[ (int)(str[i]-'a') ]++;
  }
  
  for(int i=0;i<26;i++){
    if(t[i]==0)continue;
    if(t[i]==1){
      ans+=2;
    }else{
      mp[t[i]]++;
    }
  }
  map<int,int> :: iterator it;
  for(it=mp.begin();it!=mp.end();it++){
    if(it->second>=2)ans+=(2+it->second*2-1+2+1);
    else ans+=4;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
// #define int ll

typedef long long ll;

using namespace std;

const int N=100010;
const int M=400010;

struct edge{
	int v,nxt;
};

int n,m,x,tot,hd[N],ans[N];
bool vst[N];
edge es[M];

void add_edge(int u,int v){
	es[++tot]=(edge){v,hd[u]};
	hd[u]=tot;
}

inline int read() {
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}

void bfs(){
	queue<int> q;q.push(1);vst[1]=true;x=1;
	while(!q.empty()){
		int now=q.front();q.pop();
		for(int i=hd[now];i;i=es[i].nxt){
			int v=es[i].v;
			if(!vst[v]){
				ans[v]=now;
				vst[v]=true;
				q.push(v);
				x++;
			}
		}
	}
}

signed main() {
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read();
		add_edge(u,v);add_edge(v,u);
	}
	bfs();
	if(x==n){
	puts("Yes");
	for(int i=2;i<=n;i++)printf("%d\n",ans[i]);
	}else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {
	public static int[][] field;
	public static int w;
	public static int h;
	public static final int MAX = 11;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		doIt();
	}
	public static void test(){
		boolean b = false;
		int i = 0;
		//System.out.println(sizeof(b));
	}
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		w = sc.nextInt();
		h = sc.nextInt();
		while(w + h != 0){
			//1つめがy,2つめがx
			field = new int[h][w];
			int x = 0,y = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					int tmp = sc.nextInt();
					field[i][j] = tmp;
					if(tmp == 2){
						x = j;
						y = i;
					}
				}
			}
			int result = dp(y,x,0);
			if(result >= MAX){
				result = -1;
			}
			System.out.println(result);
			w = sc.nextInt();
			h = sc.nextInt();
		}
	}
	
	public static int dp(int y, int x, int depth){
//		for(int i = 0; i < depth; i++){
//			System.out.print("　");
//		}
//		System.out.println("x = " + x + ", y = " + y + ", depth = " + depth);
		boolean bBreak = false;
		int tmp;
		int min = MAX;
		
		if(depth == MAX){
			return min;
		}
		
		tmp = x + 1;
		if(tmp < w){
			if(field[y][tmp] != 1){
				//右にいってみる
				for(; tmp < w; tmp++){
					if(field[y][tmp] == 3){
						return 1;
					}
					else if(field[y][tmp] == 1){
						bBreak = true;
						field[y][tmp] = 0;
						//System.out.println("right");
						int t = dp(y,tmp - 1, depth + 1);
						if(min > t){
							min = t;
						}
						break;
					}
				}
				if(bBreak){
					//fieldを直す
					field[y][tmp] = 1;
					bBreak = false;
				}
			}
		}
		
		tmp = x - 1;
		if(tmp >= 0){
			if(field[y][tmp] != 1){
				//左に行ってみる
				for(; tmp >= 0; tmp--){
					if(field[y][tmp] == 3){
						return 1;
					}
					else if(field[y][tmp] == 1){
						bBreak = true;
						field[y][tmp] = 0;
						//System.out.println("left");
						int t = dp(y,tmp + 1, depth + 1);
						if(min > t){
							min = t;
						}
						break;
					}
				}
				if(bBreak){
					//fieldを直す
					field[y][tmp] = 1;
					bBreak = false;
				}
			}
		}
		
		tmp = y - 1;
		if(tmp >= 0){
			if(field[tmp][x] != 1){
				//上に行ってみる
				for(; tmp >= 0; tmp--){
					if(field[tmp][x] == 3){
						return 1;
					}
					else if(field[tmp][x] == 1){
						bBreak = true;
						field[tmp][x] = 0;
						//System.out.println("above");
						int t = dp(tmp + 1, x, depth + 1);
						if(min > t){
							min = t;
						}
						break;
					}
				}
				if(bBreak){
					//fieldを直す
					field[tmp][x] = 1;
					bBreak = false;
				}
			}
		}

		tmp = y + 1;
		if(tmp < h){
			if(field[tmp][x] != 1){
				//下に行ってみる
				for(; tmp < h; tmp++){
					if(field[tmp][x] == 3){
						return 1;
					}
					else if(field[tmp][x] == 1){
						bBreak = true;
						field[tmp][x] = 0;
						//System.out.println("below");
						int t = dp(tmp - 1, x, depth + 1);
						if(min > t){
							min = t;
						}
						break;
					}
				}
				if(bBreak){
					//fieldを直す
					field[tmp][x] = 1;
					bBreak = false;
				}
			}
		}
		
		return min + 1;
	}

}

Measured memory_bytes: 13000
import os, sys, re, math

from functools import reduce
from fractions import gcd
def lcm(vals):
    return reduce((lambda x, y: (x * y) // gcd(x, y)), vals, 1)

lines = sys.stdin.readlines()

n = int(lines[0])
a = [int(k) for k in lines[1].split()]

m = lcm(a) - 1
print (sum([m % k for k in a]))


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

int main() {
    int N;
    string P, W, G, Y;
    cin >> N;
    for (int i = 0; i < N; i++){
        string S;
        cin >> S;
        if (S == "Y"){
            cout << "Four" << endl;
            break;
        }
        else{
            if(i == N - 1){
                if (S == "Y"){
                    cout << "Four" << endl;
                }
                else{
                    cout << "Three" << endl;
                }
            }
            else{
                continue;
        }
    }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = LLONG_MAX;

int r[10];
int used[210];
int d[210][210];
int N,M,R;
int res;
void warshall_floyd(){
  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

void dfs(int c,int las,int dist){
  if(c==R){
    res=min(res,dist);
    return;
  }

  for(int i=0;i<R;i++){
    if(!used[i]){
      used[i]=true;
      if(las==-1){
        dfs(c+1,i,0);
      }
      dfs(c+1,i,dist+d[r[las]][r[i]]);
      used[i]=false;
    }
  }
}
int main(){
  cin>>N>>M>>R;
  rep(i,R){
    int t;cin>>t;t--;
    r[i]=t;
  }

  for(int i=0;i<N;i++)for(int j=0;j<N;j++){
    if(i!=j)d[i][j]=INF;
  }
  rep(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    if(d[a][b]>c)d[a][b]=c;d[b][a]=c;
  }

  warshall_floyd();
  res=INF;
  dfs(0,-1,0);

  cout<<res<<endl;

}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, set<int>> mp;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    mp[a].insert(b);
    mp[b].insert(a);
  }
  if(mp[1].count(n)){
    cout << "POSSIBLE" << endl;
    return 0;
  }
  for(auto x : mp[1]){
    if(mp[x].count(n)){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 37760
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := make([]bool, 26)
    ok := true
    for i:=0;i<len(s);i++{
        if a[s[i]-'a']{
            ok = false
        }
        a[s[i]-'a']=true
    }
    ans := "no"
    if ok{
        ans = "yes"
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    rep(i, m) {
        cin >> c[i] >> d[i];
    }
    rep(i, n) {
        int min_d = 1e9;
        int p;
        rep(j, m) {
            if (chmin(min_d, abs(a[i] - c[j]) + abs(b[i] - d[j]))) {
                p = j + 1;
            }
        }
        cout << p << endl;
    }
}

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

int main(void){
    int N, M, K, conv;
    cin >> N >> M >> K;
    
    vector<long> A(N + 1), B(M + 1);
    A.at(0) = 0;
    B.at(0) = 0;
    for (int i = 1; i < N + 1; i++) {
        cin >> conv;
        A.at(i) = conv + A.at(i - 1);
    }
    for (int i = 1; i < M + 1; i++) {
        cin >> conv;
        B.at(i) = conv + B.at(i - 1);
    }
    
    
    
    int ans = 0, m = M;
    for (int i = 0; i < N + 1; i++) {
        if (A.at(i) > K) {
            break;
        }
        while (K < A.at(i) + B.at(m)) {
            m--;
        }

        ans = max(ans, i + m);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 6356
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

 int x;
 cin >> x;
 if(1200> x) cout << "ABC" << endl;
 else cout << "ARC" << endl;





//   if(b-a == c-b) cout << "YES" << endl;
//  else cout << "NO" << endl;



   return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	p = readline() |> split |> parseMap
	r = zeros(Int,n)
	for i in 1:n
		r[p[i]] = i
	end
	for i in 1:n-1
		print(30000*i," ")
	end
	println(30000*n)
	for i in 1:n-1
		print(30000*(n-i)+r[i]," ")
	end
	println(r[n])
end

main()

Measured memory_bytes: 165112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;
const int mod = 1e9+7;

void self_max(int &a, int b){
    a+=b;
    
}

int main(){
    int n; cin>>n;
    vector<vector<double>> dp(n+1, vector<double>(n+1,0));
    dp[0][0]=1; //probability that there are zero heads.

    for(int i=1; i<=n; ++i){
        double ph; cin>>ph;
        for(int j=0; j<=i; ++j){
            if(j) dp[i][j]=dp[i-1][j-1]*ph+dp[i-1][j]*(1-ph);
            else dp[i][j]=dp[i-1][j]*(1-ph);
        }
    }

    double ans=0;
    for(int j=n/2+1; j<=n; j++){
        ans+=dp[n][j];
    }

    printf("%.10lf", ans);
}

Measured memory_bytes: 73696
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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

const int INF = 1e8;

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

	cout << n * n * n << endl;
}

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

int N, M;
vector<pair<int, string> > st;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s_in;
        cin >> s_in;
        bool f = true;
        for (int j = 0; j < st.size(); j++) {
            if (st[j].second == s_in) {
                st[j].first++;
                f = false;
            }
        }
        if (f) {
            st.push_back(make_pair(1, s_in));
        }
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        string t_in;
        cin >> t_in;
        bool f = true;
        for (int j = 0; j < st.size(); j++) {
            if (st[j].second == t_in) {
                st[j].first--;
                f = false;
            }
        }
        if (f) {
            st.push_back(make_pair(-1, t_in));
        }
    }
    
    sort(begin(st), end(st), greater<>());

    if (st[0].first > 0) {
        cout << st[0].first << endl;
    } 
    else {
        cout << 0 << endl;
    }

    return 0;
}


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

int nCr(int n, int r);

int main(){
    int N,M;
    cin >> N >> M;
    cout << nCr(N,2) + nCr(M,2) << endl;
    return 0;
}

int nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
struct edge { int u, v; ll w; };

void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
	fill(d, d + n, LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
}

vector<edge> G[100];
ll d[100];

int main() {
	for (;;) {
		int n, m, c, s, g;
		cin >> n >> m >> c >> s >> g;
		if (n == 0) break;
		vector< vector< vector<int> > > a(c, vector< vector<int> >(n, vector<int>(n)));
		for (int j = 0; j < c; j++)
			for (int u = 0; u < n; u++)
				for (int v = 0; v < n; v++)
					a[j][u][v] = (u == v ? 0 : INT_MAX / 2);
		for (; m > 0; m--) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			a[c][x][y] = min(a[c][x][y], d);
			a[c][y][x] = min(a[c][y][x], d);
		}
		for (int j = 0; j < c; j++)
			for (int k = 0; k < n; k++)
				for (int u = 0; u < n; u++)
					for (int v = 0; v < n; v++)
						a[j][u][v] = min(a[j][u][v], a[j][u][k] + a[j][k][v]);
		vector<int> p(c);
		for (int j = 0; j < c; j++) cin >> p[j];
		for (int u = 0; u < n; u++) G[u].clear();
		for (int j = 0; j < c; j++) {
			vector<int> q(p[j]), r(p[j]);
			for (int k = 1; k < p[j]; k++) cin >> q[k];
			for (int k = 0; k < p[j]; k++) cin >> r[k];
			vector<int> f(p[j]);
			for (int k = 1; k < p[j]; k++)
				f[k] = f[k - 1] + r[k - 1] * (q[k] - q[k - 1]);
			for (int u = 0; u < n; u++)
				for (int v = 0; v < n; v++) {
					int d = a[j][u][v];
					if (d == INT_MAX / 2) continue;
					int k = upper_bound(q.begin(), q.end(), d) - q.begin() - 1;
					int w = f[k] + r[k] * (d - q[k]);
					edge e = {u, v, w}; G[u].push_back(e);
				}
		}
		dijkstra(n, G, s - 1, d);
		cout << (d[g - 1] < LLONG_MAX ? d[g - 1] : -1) << endl;
	}
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,freq[N],x;
int main(){
    //freopen("input.txt","r",stdin);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        freq[x]++;
    }
    int mx=0;
    for(int i=0;i<N-2;i++){
        mx=max(mx,freq[i]+freq[i+1]+freq[i+2]);
    }
    cout<<mx;
    
}
    

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,x=0,ans=0;cin>>n;
  string s;cin>>s;
  for (int i = 0; i < s.size(); ++i){
  	s[i]=='I' ? x++ : x--;
  	ans=max(ans,x);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);    
    if(op=='?') break;
    if(op=='+'){
      printf("%d\n",a+b);
    } else if(op=='-'){
      printf("%d\n",a-b);
    } else if(op=='*'){
      printf("%d\n",a*b);
    } else if(op=='/'){
      printf("%d\n",a/b);
    }
  }
  return 0;
}

Measured memory_bytes: 600
CMAX = 1000000000
N, M, R = gets.chomp.split(" ").map(&:to_i)
r = gets.chomp.split(" ").map(&:to_i)
d = Array.new(N).map{Array.new(N, CMAX)}
M.times do
    a, b, c = gets.chomp.split(" ").map(&:to_i)
    d[a-1][b-1] = c
    d[b-1][a-1] = c
end
#(N+1).times {|i| d[i][i] = 0}

for k in 0..N-1 do
    for i in 0..N-1 do
        for j in 0..N-1 do
            d[i][j] = d[i][k]+d[k][j] if d[i][k]+d[k][j] <  d[i][j]
        end
    end
end

ans = CMAX
r.permutation(R) do |roots|
    sum = 0
    roots.each_cons(2) do |x, y|
        sum += d[x-1][y-1]
    end
    ans = sum if sum < ans
end
puts ans


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
int main(){

  int H,W; cin >> H >> W;

  string S[50];
  for(int i = 0;i < H;i++)cin >> S[i];

  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(S[i][j] != '#'){
        int cnt = 0;

        int dx[8] = {1,1,0,-1,-1,-1,0,1};
        int dy[8] = {0,1,1,1,0,-1,-1,-1};
        for(int k = 0;k < 8;k++){
          int nx = j + dx[k];
          int ny = i + dy[k];
          if(0 <= nx && nx < W && 0 <= ny && ny < H && S[ny][nx] == '#')cnt++;
        }
        S[i][j] = (char)('0' + cnt);
      }
    }
  }

  for(int i = 0;i < H;i++)cout << S[i] << endl;
  return 0;
}


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

int main(){
	int sa = 0, sb = 0;
	for(int i = 0; i < 4; i++){
		int a;
		cin >> a;
		sa += a;
	}
	for(int i = 0; i < 4; i++){
		int a;
		cin >> a;
		sb += a;
	}
	cout << max(sa, sb) << endl;
	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;




int32_t main()
{
    int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

int x;
cin>>x;
cout<<arr[x-1]<<endl;


 return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
	int N;
	double total;
	std::cin>>N;

	for(int i=0;i<N;i++){
		double money;
		std::string kind;
		std::cin>>money>>kind;
		if(kind == "BTC"){
			total += money*380000;
		}else{
			total += money;
		}
	}
	std::cout<<total;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int A, B;
    cin >> A >> B;

    cout << (6-A-B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x) << endl;
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define eb(e) emplace_back(e)
#define EPS 0.00000001

int main() {
    FAST;
  
    string s, t;
    cin >> s >> t;

    int ans = 0;

    int len = size(s);
    rep(i, len){
        if(s[i] != t[i]){
            ans++;
        }
    }

    print(ans);
}


Measured memory_bytes: 3808
import numpy as np
H, W, K = map(int, input().split())
zu = np.zeros((H, W), dtype=int)

for h in range(H):
    zu[h, :] = (np.array(list(input())) == '#')

MAXX = 2**(H+W)
ans = 0
if np.sum(zu) == K:
    ans += 1

for c in range(1, MAXX):
    zu1 = np.copy(zu)
    for h in range(H):
        if (c & (1<<h)) > 0:
            zu1[h] = 0
    for w in range(W):
        if (c & (1<<(H+w))) > 0:
            zu1[:, w] = 0
    if np.sum(zu1) == K:
        ans += 1

print(ans)

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

ll d[(1<<18)];
ll n;

void init(ll _n){
  n = 1;
  while( n < _n ) n*=2;
  memset(d,0,sizeof(d));
}

ll query(ll a,ll b,ll k,ll l,ll r){
  if( r <= a || b <= l ) return 0;
  else if( a <= l && r <= b ) return d[k];
  return max( query( a, b, 2*k+1, l, (l+r)/2 ),  query( a, b, 2*k+2, (l+r)/2, r ) );
}

ll query(ll a,ll b){
  return query( a, b, 0, 0, n );
}

void sets(ll k,ll x) {
  k += n-1;
  d[k] = x;
  while( k > 0 ){
    k = (k-1)/2;
    d[k] = max( d[2*k+1], d[2*k+2] );
  }
}

typedef pair<ll,ll> P;

ll N;
vector<P> p;
int main(){
  cin >> N;
  init( N );
  for(ll i=0;i<N;i++){
    ll x; cin >> x;
    p.push_back( P(x,i) );
  }

  sort( p.begin(), p.end() );
  
  ll res = 0;
  for(ll i=N-1;i>-1;i--){    
    ll k = p[i].second;
    ll num = query( k, N );
    res = max( res, num + p[i].first );
    sets( k, num+p[i].first );
  }
  cout << N*(N+1)/2 - res << endl;
  
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);(i)++)
#define Rep(i,n) For(i,0,n)
#define sp " "

typedef long long ll;
const int MAX_N = 1000000;
ll par[MAX_N];
ll siz[MAX_N];

/*
一通り枝の情報を入力し終わったら、もう一回親を更新しないとだめです
*/

void init(ll n){
    Rep(i,n){
        par[i] = i;
        siz[i] = 1;
    }
}

ll find(ll x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]); //renew par[x]
    }
}

bool same(ll x,ll y){
    return find(x) == find(y);
}

void unite(ll x,ll y){
    x = find(x);
    y = find(y);
    if(x == y) return; // if same parent: nothing
    if(siz[x] < siz[y])swap(x,y);
    siz[x] += siz[y];
    par[y] = x; // else unite them
}

ll size(ll x){
    return siz[find(x)];
}

ll N,M;

int main(){
    cin >> N >> M;
    init(N);
    vector<pair<int,int>> edge(M,pair<int,int>());
    vector<ll> ans(M+1);
    ans[0] = (N*(N-1))/2;
    Rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        edge[i] = make_pair(a,b);
    }
    Rep(i,M){
        int a = edge[M-1-i].first;
        int b = edge[M-1-i].second;
        if(!(same(a,b))){
            ans[i+1] = ans[i] - (size(b)*size(a));
            //cout << find(a) << sp << cnt[find(a)] << sp << find(b) << sp << cnt[find(b)] << endl;
            unite(a,b);
        }else{
            ans[i+1] = ans[i];
        }
    }
    Rep(i,M) cout << ans[M-1-i] << endl;
    //cin >> N;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int k;
    cin >> k;
    int ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            int g = __gcd(a, b);
            for (int c = 1; c <= k; c++) {
                ans += __gcd(g, c);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  10 9 8 7 5 6 3 4 2 1 10 9 8 7 5 6 3 4 2 1
  }*/

signed main(){
  int n, k;
  cin >> n >> k;

  vi a(n), cnt(2002);
  rep(i, 0, n){
    cin >> a[i];
    cnt[a[i]]++;
  }

  int ans = 0;
  rep(i, 0, n) rep(j, i+1, n){
    if(a[i] > a[j]) ans++;
  }
//  cout << ans << endl;
  (ans *= k) %= mod;
//  cout << ans << endl;

  vi s(2002);
  for(int i = 2000; i >= 0; i--) s[i] = (s[i+1] + cnt[i+1])%mod;

  int m = k*(k-1)/2%mod;
  int tmp = 0;
  rep(i, 0, n){
    (tmp += s[a[i]]) %= mod;
  }

//  cout << tmp << endl;
  (tmp *= m) %= mod;
//  cout << tmp << endl;

  (ans += tmp) %= mod;
  cout << ans << endl;

//  rep(i, 0, 10) cout << s[i] << " ";
//  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#define MAXN (500 + 5)
#define pii pair<int, int>
using namespace std;
struct node
{
	pii poi;
	bool isB;
	bool operator < (const node x) const
	{ return poi < x.poi; }
}a[MAXN];
int n, ans;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i].poi.first, &a[i].poi.second), a[i].isB = false;
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[n + i].poi.first, &a[n + i].poi.second), a[n + i].isB = true;
	sort(a + 1, a + (n << 1) + 1);
	set<int> qwq;
	for (int i = 1; i <= (n << 1); i++)
	{
		if (!a[i].isB)
			qwq.insert(a[i].poi.second);
		else if (!qwq.empty())
		{
			set<int>::iterator x = qwq.upper_bound(a[i].poi.second);
			if (x == qwq.begin())
				continue;
			--x;
			++ans;
			qwq.erase(x);
		}
	}
	printf("%d", ans);
	return 0;
}

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

int main() {
  int N, A, R;
  cin >> N >> A;

  R = (N / 500);

  if ((N - (500 * R)) > A) {
    cout << "No" << endl;
  }

  else {
    cout << "Yes" << endl;
  }
}

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

int main() {
  // ここにプログラムを追記
  int A,B,N;
  cin >> N >> A >> B;
  if (A*N > B) cout << B <<endl;
  else if (A*N < B) cout << A*N <<endl;
  else cout << B <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(void){
    int i;
    i=0;
    char a[1200];
    char mo;
    while(1){
        scanf("%c",&mo);
        a[i]=mo;
        if(islower(a[i])){
            printf("%c",toupper(a[i]));
        }else if(isupper(a[i])){
        printf("%c",tolower(a[i]));
        }else{
        printf("%c",a[i]);
        }
        if(a[i]=='\n'||i==1200)break;
        i=i+1;
    }
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int c=0;
  for(int i=A;i<=B;i++){
    int d1,d2,d3,d4,d5;

    d1 = i%10;
    int tmp = i/10;
    d2 = tmp%10;
    tmp /= 10;
    d3 =tmp%10;
    tmp /= 10;
    d4 =tmp%10;
    tmp /= 10;
    d5 =tmp%10;
    if(d1==d5 && d2==d4){
      c++;

    }
  }

  cout << c << endl;


}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;
const string YES = "Yes";
const string NO = "No";

string S;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> S;
    solve();
}

// S は A または B から成る
// |S| = 3

// string S
// バスが運行することになる駅の組み合わせが存在する場合は Yes を、存在しない場合は No を出力せよ。
void solve(){
    cout<<(S[0]==S[1]&&S[1]==S[2]?NO:YES)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
struct card{
	char E;
	int N;
};
void bs(struct card  c[],int n){
	int j,i;
	struct card tmp[n];

	for(i = 0;i < n;i++){
		for(j = n-1;j >= i+1;j--){
			if(c[j].N<c[j-1].N){
				tmp[j] = c[j];
				c[j] = c[j-1];
				c[j-1] = tmp[j];
			}
		}
	}
	
	
}
void sl(struct card  c[],int n){
	int i,j,minj;
	struct card tmp[n];
	for(i = 0;i < n;i++){
		minj = i;
		for(j = i;j < n;j++){
			if(c[j].N < c[minj].N){
				minj = j;
			}
		}
		tmp[j] = c[i];
		c[i] = c[minj];
		c[minj] = tmp[j];
	}
}
int isStable(struct card c[],struct card b[],int n){
	int i;
	for(i = 0;i < n;i++){
		if(c[i].E != b[i].E){return 1;}
		
	}
	return 0;
}

int main(void){
	int n,i,p = 0;
	
	scanf("%d",&n);
	struct card c[n];
	struct card b[n];
	for(i = 0;i < n;i++){
		scanf(" %c %d",&c[i].E,&c[i].N);
	}
	for(i = 0;i < n;i++){
		b[i] = c[i];
	}
	
	bs(b,n);
	
	for(i = 0;i < n; i++){
		if(i <n-1){
			printf("%c%d ",b[i].E,b[i].N);
		}
		else{
			printf("%c%d",b[i].E,b[i].N);
		}
		
	}
	printf("\n");
	if(p == 1){printf("Not stable\n");}
	
	else {printf("Stable\n");}
	
	 sl(c,n);

	for(i = 0;i < n; i++){
		if(i <n-1){
			printf("%c%d ",c[i].E,c[i].N);
		}
		else{
			printf("%c%d",c[i].E,c[i].N);
		}
		
	}
	printf("\n");
	p = isStable(c,b,n);
	if(p == 1){printf("Not stable\n");}
	else {printf("Stable\n");}
	
	

}


Measured memory_bytes: 2036
S = int(input())
x1 = min(10**9, int(S**0.5) + 1)
y2 = min(10**9, int(S**0.5) + 1)
r = x1 * y2 - S
x2 = r
y1 = 1
print(0, 0, x1, y1, x2, y2)


Measured memory_bytes: 3060
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
boolean i=true;
while(i){
String str=br.readLine();
String[] arr=str.split(" ");
int h=Integer.parseInt(arr[0]);
int w=Integer.parseInt(arr[1]);
if(h==0 && w==0)  i=false;
else{
for(int k=0; k<h; k++){
for(int j=0; j<w; j++){
if(k==0||j==0||k==h-1||j==w-1)  System.out.print("#");
else System.out.print(".");
}
System.out.println();
}
System.out.println();
}
}
br.close();
}
}

Measured memory_bytes: 30588
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  map<char, bool> mp;
  for(char alp = 'a'; alp <='z'; alp++){
    mp[alp] = false;
  }

  REP(i,s.size()){
    mp[s[i]] = true;
  }
  for(char alp = 'a'; alp <='z'; alp++){
    if(mp[alp] == false) {
      cout << alp << endl;
      return 0;
    }
  }

  cout << "None" << endl;


  return 0;
}

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


void solve()
{
    string t,s;
    cin >> s >> t;
    int res=0;
    for (int i = 0; i < (int) s.size(); ++i) {
        if (s[i]!=t[i]) {
            res++; 
        }
    }
    cout << res << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3808
/*||>>>> Praveen Ojha <<<<>>>> 22 June 2019 <<<<>>>> 17:28:10 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	string s;
	cin>>s;
	for(int i=1;i<4;i++){
		if(s[i]==s[i-1]){
			return cout<<"Bad\n",0;
		}
	}
	cout<<"Good\n";
return 0;
}

Measured memory_bytes: 256