akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	cout << ((a < b && b < c) ? "Yes" : "No") << endl;






	return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5;
map < int , int> mp ;
map < int , int >::iterator it ;
int a[maxn] , ans ;
int main()
{
	int n ;
	cin >> n ;
	for ( int i = 0 ; i<n ; i++)
		cin >> a[i] , mp[a[i]]++ ;
	for ( it = mp.begin() ; it!=mp.end() ; it++ )
	{
		if ( it->first > it->second ) 
			ans += it->second ;
		else
			ans += it->second - it->first ;
	}
	cout << ans << endl;
	


}

Measured memory_bytes: 5120
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    cnt = len(set(a))

    if (n - cnt)%2:
        cnt -= 1

    print(cnt)

solve()


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	char c;
	cin>>c;
	c++;
	cout<<c;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n ;
  scanf("%d", &n) ;

  int r0, r1 ;
  scanf("%d %d",&r0,&r1) ;

  int maxv = r1-r0 ;
  int minv ;
  if( r1 <= r0 ){
    minv = r1 ;
  }else{
    minv = r0 ;
  }

  int r, i ;
  for( i = 0 ; i < n - 2 ; i++ ){
    scanf("%d", &r) ;
    if( maxv <= r - minv ){
      maxv = r - minv ;
    }
    if( minv >= r ){
      minv = r ;
    }
  }
  printf("%d\n", maxv) ;
  
  return 0 ;
}


Measured memory_bytes: 2140
#include<iostream>

using namespace std;

typedef long long ll;
ll dp[22][(1 << 21)];
int a[21][21];
const ll MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  dp[0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int s = 0; s < (1 << n); s++) {
      if(__builtin_popcount(s) != i) continue;
      for(int j = 0; j < n; j++) {
	if(a[i][j] == 1 && !((s >> j) & 1)) {
	  //	  cout << "i = "<<i<<"  j = "<<j<<endl;
	  dp[i+1][s | (1 << j)] = (dp[i+1][s | (1 << j)] + dp[i][s]) % MOD;
	 
	}
      }
    }
  }
  /*  for(int i = 0; i < n; i++) {
    for(int j = 0; j < (1 << n); j++) {
      cout << dp[i][j] << endl;
    }
    }*/

  cout << dp[n][(1 << n) - 1] << endl;
}
  


Measured memory_bytes: 309504
import java.util.Scanner;

public class Main 
{
	static int w, h;
	static int[][][] dp;
	static boolean[][] g;
	static int BIGNUM = 999999999;
	
	static int get(int x, int y, int s)
	{
		if(x >= w || y >= h)return BIGNUM;
		else return dp[x][y][s];
	}
	
	int cuk(int x, int y)
	{
		int min = BIGNUM;
		if(g[x][y])
		{
			min = cukblack(x, y);
		}
		else //if this is floor, just walk
			min = Math.min(cuk(x, y+1), cuk(x+1,y));
		return min;
	}
	
	int cukblack(int x, int y)
	{ //draw squares and min
		int min = BIGNUM;
		
		int y2 = y;
		int maxwidth = BIGNUM;
		int x2 = x;
		while(y2 < h)
		{
			while(x2 < w-1 && x2 < maxwidth && g[x2+1][y2]) //black extend to the right
			{
				x2++; //x2: last x that's still black
				min = Math.min(min, cuk(x2+1,y2)+1);
				min = Math.min(min, cuk(x2,y2+1)+1);
			}
			maxwidth = x2;
		}
		return min;
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		
		g = new boolean[w][h];
		
		dp = new int[w][h][2];
		for(int y = 0; y < h; y++)
		{
			String s = sc.next();
			for(int x = 0; x < w; x++)
			{
				g[x][y] = s.charAt(x) == '#';
			}
		}

		for(int y = 0; y < h; y++)
			for(int x = 0; x < w; x++)
				for(int s = 0; s < 2; s++)
				{
					dp[x][y][s] = BIGNUM;
				}
		
		dp[w-1][h-1][g[w-1][h-1]?1:0] = 0;
		dp[w-1][h-1][g[w-1][h-1]?0:1] = 0;
		boolean debug = false;
		
		//s=1 means flipped
		for(int y = h-1; y >= 0; y--)
			for(int x = w-1; x >= 0; x--)
				for(int s = 0; s < 2; s++)
				{
					//right
					if(x < w-1)
					{
						int reqstate = g[x+1][y]?1:0;
						int tax = reqstate==1&&s==0?1:0;
						dp[x][y][s] = Math.min(dp[x][y][s], get(x+1,y,reqstate)+tax);
					}
					
					//down
					if(y < h-1)
					{
						int reqstate = g[x][y+1]?1:0;
						int tax = reqstate==1&&s==0?1:0;
						dp[x][y][s] = Math.min(dp[x][y][s], get(x,y+1,reqstate)+tax);
					}
					
					if(debug)System.out.println(x + " " + y + " " + s + ": " + dp[x][y][s]);
				}
		
		
		if(debug)
			for(int s = 0; s < 2; s++)
			{
				System.out.print("\n\n");
				for(int y = 0; y < h; y++)
				{
					for(int x = 0; x < w; x++)
						System.out.print(dp[x][y][s] + " ");
					System.out.print("\n");
				}
			}
		
		if(g[0][0])
			System.out.println(get(0,0,1)+1);
		else
			System.out.println(get(0,0,0));
			
	}

}


Measured memory_bytes: 24792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 105
char s[N];
int a[N];
long long k;
int main(){
	int i,len;
	scanf("%s",s+1);
	len=strlen(s+1);
	for(i=1;i<=len;i++) a[i]=s[i]-'0';
	readl(k);
	i=0;
	while(k>0){
		i++;
		if(a[i]==1) k--;
		else k-=pow(a[i],5*1e15-1);
	}
	printf("%d",a[i]);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll a=1,b=1;
    rep(i,n)
    {
        ll A,B;
        cin>>A>>B;
        ll n = max((a+A-1)/A,(b+B-1)/B);
        a = A*n;
        b = B*n;
    }

    cout<<a+b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[300000];
long long sum[300000];
int main()
{
	int n;
	cin >> n;
	int cnt=0;
	for(int i=1;i<=n;i++) 
	{
		cin >> a[i];
		sum[a[i]]++;
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=sum[i]*(sum[i]-1)/2;
	for(int i=1;i<=n;i++) cout << ans-(sum[a[i]]-1) << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    bool is_approbed = true;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if(A%2 == 0) {
            if(A%3 != 0 && A%5 != 0) {
                is_approbed = false;
            }
        }
    }
    if(is_approbed) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

void print(void)
{
        printf(":(\n");
        return ;
}
int main(void)
{
        int a,b,c,d,e,k;
        scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);

        if(b-a>k)print();
        else if(c-a>k)print();
        else if(d-a>k)print();
        else if(e-a>k)print();
        else if(c-b>k)print();
        else if(d-b>k)print();
        else if(e-b>k)print();
        else if(d-c>k)print();
        else if(e-c>k)print();
        else if(e-d>k)print();
        else printf("Yay!\n");
        return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2
int calc_dist(int j, int i, int n, int x, int y){
    int ans;
    if((j<=x && i<=x) || (j>=y && i>=y)){
        ans = i - j;
    }else if(j<=x && i<=y){
        ans = min(i-j, x - j + 1 + (y - i));
    }else if(j<=x && i>y){
        ans = i-j - (y-x) + 1;
    }else if(j>=x && i<=y){
        ans = min(i-j, j-x+1+y-i);
    }
    else{
        ans =  min(i-j, j-x + 1 + i-y);
    }
    return ans;
}

void ssolve(std::istream& in, std::ostream& out){
    int n, x, y;
    s3(n,x,y);
    map<int,int> dists;
    f(i,1,n+1){
        f(j,1,i){
            dists[calc_dist(j,i, n, x, y)]++;
        }
    }
    f(k,1,n){
        if(dists.count(k)){
            out<<dists[k]<<endl;
        }else{
            out<<0<<endl;
        }
    }
}

class DLine {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	DLine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


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

int main() {
  string s, ans;
  {
    string s1, s2;
    cin >> s1 >> s >> s2;
  }

  // empty
  // ans = "A" + s.at(0);
  ans = "A";
  ans += s.at(0);
  ans += "C";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int size(int a){
  if(a == 0) return 0;
  return 1 + size(a/10);
}

void out(int a){
  if(size(a) == 1) cout << "00000" << a;
  if(size(a) == 2) cout << "0000" << a;
  if(size(a) == 3) cout << "000" << a;
  if(size(a) == 4) cout << "00" << a;
  if(size(a) == 5) cout << "0" << a;
  if(size(a) == 6) cout << a;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<pair<int,int>,int>> d;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    auto tmp = make_pair(a,b);
    auto tmp2 = make_pair(tmp,i);
    d.push_back(tmp2);
  }
  sort(d);
  int cnt = 1;
  rep(i,m){
    if(i == 0) d[i].first.second = cnt;
    else{
      if(d[i].first.first == d[i-1].first.first) cnt ++;
      else cnt = 1;
      d[i].first.second = cnt;
    }
  }
  vector<pair<int,pair<int,int>>> r;
  for(auto p : d){
    auto tmp = make_pair(p.second,p.first);
    r.push_back(tmp);
  }
  sort(r);
  for(auto p : r){
    out(p.second.first);
    out(p.second.second);
    cout << endl;
  }
}

Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;


int main() {
    long long N, K;
    cin >> N >> K;

    long long amari = N % K;
    long long a = K - amari;

    if (a>amari) {
        cout << amari << endl;

    }
    else {
        cout << a << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int is_prime(int x) {
  for (int i = 2; i * i < x; ++i) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main(int argc, char* argv[]) {
  int X;
  cin >> X;

  while (true) {
    if (is_prime(X))
      break;
    ++X;
  }

  cout << X << endl;

  return 0;
}

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

static const int N=100;
static const int INF = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s)
{
    queue<int> q;
    q.push(s);
    for(int i=0;i<n;i++) d[i]=INF;
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front(); q.pop();
        for(int v=0;v<n;v++){
            if(M[u][v]==0) continue;
            if(d[v]!=INF) continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i=0;i<n;i++){
        cout<< i+1 << " " <<((d[i]==INF)?(-1):d[i])<<endl;
    }
}


int main()
{
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) M[i][j]=0;
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    bfs(0);
    return 0;
}



Measured memory_bytes: 3148
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
    }
    let mut dp = vec![0; n+200];
    dp[0] = 1;
    for i in 0..n {
        if dp[i] == 0 { continue; }
        for j in 100..106 {
            dp[i+j] = 1;
        }
    }

    println!("{}", dp[n]);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
//---------------------------------------------------------------------------//

int main(){
        string a,b,c;
        cin>>a>>b>>c;
        int i=0,j=0,k=0;
        char next='a';
        while(1) {
                if(next=='a') {
                        if(i>=a.length()) {
                                cout<<"A"<<endl;
                                break;
                        }
                        next=a[i];
                        ++i;
                }else if(next=='b') {
                        if(j>=b.length()) {
                                cout<<"B"<<endl;
                                break;
                        }
                        next=b[j];
                        ++j;
                }else{
                        if(k>=c.length()) {
                                cout<<"C"<<endl;
                                break;
                        }
                        next=c[k];
                        k++;
                }
        }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int A,B; cin >> A >> B;
    cout << max(A+B,max(A-B,A*B)) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

a = []
for i in range(5):
    a.append(int(input()))

# print(a)
sum_time = 0
b = {}

for i in range(5):
    t = a[i] % 10
    if t == 0:
        b[i] = 10
    else:
        b[i] = a[i] % 10

# print(b)

sort_dict = sorted(b.items(), key=lambda x:x[1], reverse=True)
# print(sort_dict)

for i in range(4):
    d = sort_dict[i]
    index = d[0]
    sub = 10 - d[1]
    sum_time += a[d[0]] + sub

d = sort_dict[4]
index = d[0]
sum_time += a[d[0]]

print(sum_time)


Measured memory_bytes: 3064
n = int(input())
strn = str(n)
keta = len(strn)
n_head = int(strn[0])
n_tail = int(strn[-1])
naka = strn[1:-1]
if len(naka)  == 0:
    nakan = 0
else:
    nakan = int(naka)

ans = 0

if keta <= 2:
    for i in range(1,n+1):
        for j in range(1,n+1):
            head1 = int(str(i)[0])
            tail1 = int(str(i)[-1])
            head2 = int(str(j)[0])
            tail2 = int(str(j)[-1])
            if head1 == tail2 and head2 == tail1:
                ans += 1
                #print(i,j)
    print(ans)

else:
    hoj = []
    tmp = 1
    mog = 1
    for i in range(keta):
        hoj.append(mog)
        tmp = tmp*10
        mog = mog + tmp
    #print(hoj)
    
    for i in range(1,n+1):
        head = int(str(i)[0])
        tail = int(str(i)[-1])
        if tail == 0:
            continue

        if tail < n_head:
            ans += hoj[keta-2]
        elif tail > n_head:
            ans += hoj[keta-3]
        else:
            ans += hoj[keta-3]
            if head <= n_tail:
                ans += nakan + 1
            else:
                ans += max(nakan ,0)

        if head == tail:
            ans += 1

        #print(i,ans)
    print(ans)

Measured memory_bytes: 41580
# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,z=some[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0;i < 3;i++){
        if(s[i]=='R') cnt++;
    }
    if(cnt == 2 && s[1] == 'S') cnt = 1;
    cout << cnt << endl;
}

Measured memory_bytes: 3640
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ');
                var H = int.Parse(inputs[0]);
                var W = int.Parse(inputs[1]);
                if (H==0 && W==0) return;

                const char blockA = '#';
                const char blockB = '.';
                var lineA = MakeCheck(W, blockA, blockB);
                var lineB = MakeCheck(W, blockB, blockA);

                for (int i = 0; i < H; i++)
                {
                    if ((i & 1) == 0) Console.WriteLine(lineA);
                    else Console.WriteLine(lineB);
                }
                Console.WriteLine();
            }
        }

        public static string MakeCheck(int length, char first, char second)
        {
            var str = new char[length];

            for (int i = 0; i < length; i++)
            {
                if ((i & 1) == 0) str[i] = first;
                else str[i] = second;
            }

            return new string(str);
        }
    }
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int mx = 0;
	int* score = (int *)malloc( s.length()*sizeof(int) );
	for( int i = 1; i < s.length()-1; i++ ) {
		memset( score, 0, s.length()*sizeof(int) );
		
		int nc = 0;
		int j = 0;
		for( ; j < i; j++ ) {
			*(score+(s[j]-'a')) = 1;
		}
		for( ; j < s.length(); j++ ) {
			if( *(score+(s[j]-'a')) == 1 ) {
				*(score+(s[j]-'a')) = 2;
				nc++;
			}
		}
		if( mx < nc ) mx = nc;
	}
	cout << mx << endl;
}


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

const int INF = 1 << 28;

int N;
vector<string> A, B;
string y, s;

string replace(string str, string pattern, string object) {
    string ret;
    while (str.find(pattern) != string::npos) {
        ret += string(str.begin(), str.begin() + str.find(pattern));
        ret += object;
        str = string(str.begin() + str.find(pattern) + pattern.size(), str.end());
    }

    return ret + str;
}

int dfs(string str, int d) {
    if (str.size() >= s.size()) {
        if (str == s) return d;
        else return INF;
    }

    int ret = INF;
    for (int i = 0; i < N; i++) {
        string tmp = replace(str, A[i], B[i]);
        if (tmp == str) continue;
        ret = min(ret, dfs(tmp, d + 1));
    }

    return ret;
}

void solve() {
    A.resize(N);
    B.resize(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    cin >> y >> s;

    int ret = dfs(y, 0);
    if (ret == INF) cout << -1 << endl;
    else cout << ret << endl;
}

int main() {
    while (cin >> N, N) solve();

    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

int main(){
    int a,b;
    cin>>a>>b;
    if(b<a){
        cout<<a-1<<endl;
    }else{
        cout<<a<<endl;
    }
}

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

import math

def max_min(a,b):
    f = math.gcd(a,b)
    
    return f

ans = 0

for a in range(1, k + 1):
    for b in range(1, k + 1):
        
        n = max_min(a, b)
        
        if n == 1:
            ans += k
            
        else:
            for c in range(1, k + 1):
                
                ans += max_min(n, c)

print(ans)


Measured memory_bytes: 9180
#include <iostream>
using namespace std;
int main(void)
{
    string x,y;
    int gusu_num,kisu_num;
    
    cin >> x >> y;
    
    kisu_num = x.size();
    gusu_num = y.size();
    
    if(kisu_num > gusu_num)
    {
        for(int i = 0;i <= gusu_num - 1;++i)
        {
            cout << x[i] << y[i];
        }
        cout << x[kisu_num - 1];
    }
    else
    {
        for(int i = 0;i <= gusu_num - 1;++i)
        {
            cout << x[i] << y[i];
        }
    }    
}

Measured memory_bytes: 256
#include <stdio.h>

int n, s[500000];
int a = 0;

void Merge(int left, int mid, int right)
{
   int n1 = mid - left;
   int n2 = right - mid;
   int L[n1+1], R[n2+1];
   int i, j, k;

   for ( i = 0; i < n1; i++ )
      L[i] = s[left + i];

   for ( i = 0; i < n2; i++ )
      R[i] = s[mid + i];
      L[n1] = 1000000000;
      R[n2] = 1000000000;

   i = 0;
   j = 0;

   for ( k = left; k < right; k++ ) {
      a++;

      if( L[i] <= R[j] )
         s[k] = L[i++];
      else
         s[k] = R[j++];

   }

}


void MergeSort(int left, int right)
{
   int mid;

   if( right -left <= 1 )
      return;

   mid = (left+right) / 2;
   MergeSort(left, mid);
   MergeSort(mid, right);
   Merge(left, mid, right);

}


int main()
{
   int i, left, right;

   scanf("%d", &n);

   for ( i = 0; i < n; i++ )
      scanf("%d", &s[i]);

   left = 0;
   right = n;
   MergeSort(left, right);

   for ( i = 0; i < n; i++ ){
      if( i > 0 )
         printf(" ");
         printf("%d", s[i]);
   }

   printf("\n");
   printf("%d\n", a);

   return 0;

}

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

struct DOLL{
	int h;
	int r;
};

int memo[1001][1001];

int f(vector<DOLL> &d1, vector<DOLL> &d2, int h, int r,int i1,int i2)
{
	if( memo[r][h] >= 0 ){
		return memo[r][h];
	}


	int ans = 0;

	for(int i=i1;i<d1.size();i++){
		DOLL &d=d1[i];
		if( d.r>r && d.h>h ){
			int a = f(d1,d2,d.h,d.r,i+1,i2)+1;
			ans = max(a,ans);
			break;
		}
	}

	for(int i=i2;i<d2.size();i++){
		DOLL &d=d2[i];
		if( d.r>r && d.h>h ){
			int a = f(d1,d2,d.h,d.r,i1,i2+1)+1;
			ans = max(a,ans);
			break;
		}
	}

	memo[r][h] = ans;	

	return ans;
}

int main() {

	while (true){

		for(int i=0;i<1001;i++){
			fill(memo[i],memo[i]+1001,-1);
		}

		vector<DOLL> d1;
		vector<DOLL> d2;
		int n,m;

		cin >> n;
		if (n == 0) break;

		for (int i = 0; i<n; i++){
			DOLL d;
			cin >> d.h >> d.r;
			d1.push_back(d);
		}

		cin >> m;

		for (int i = 0; i<m; i++){
			DOLL d;
			cin >> d.h >> d.r;
			d2.push_back(d);
		}

		int ans = f(d1, d2, 0, 0,0,0);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5140
# Dice IV
# 2018/11/17, 2019/1/16
from collections import Counter
import sys

class Dice:
    def __init__(self, *num):
        if len(num) != 6:
            raise ValueError("6!")
        self.numbers = num

    def east(self):
        index = (3, 1, 0, 5, 4, 2)
        self.numbers = tuple((self.numbers[i] for i in index))

    def west(self):
        index = (2, 1, 5, 0, 4, 3)
        self.numbers = tuple((self.numbers[i] for i in index))

    def south(self):
        index = (4, 0, 2, 3, 5, 1)
        self.numbers = tuple((self.numbers[i] for i in index))

    def north(self):
        index = (1, 5, 2, 3, 0, 4)
        self.numbers = tuple((self.numbers[i] for i in index))

    def rot_top(self):
        """topを変えないように時計周りにくるくる回す"""
        index = (0, 2, 4, 1, 3, 5)
        self.numbers = tuple((self.numbers[i] for i in index))

    @property
    def top(self):
        return self.numbers[0]

    @property
    def front(self):
        return self.numbers[1]

    @property
    def right(self):
        return self.numbers[2]

    def __repr__(self):
        return "Dice(" + ", ".join([str(i) for i in self.numbers]) + ")"


    def align_top_and_front(self, tmp_dice):
        # topを一番レアいやつにする
        rarest = Counter(self.numbers).most_common()[-1][0]
        for i in range(4):
            if self.top == rarest:
                break
            self.east()
        for i in range(4):
            if self.top == rarest:
                break
            self.north()

        # topが合うまで回す
        for i in range(4):
            if self.top == tmp_dice.top:
                break
            tmp_dice.east()

        for i in range(4):
            if self.top == tmp_dice.top:
                break
            tmp_dice.north()

        # frontを合わせる
        for i in range(4):
            if self.front == tmp_dice.front:
                break
            tmp_dice.rot_top()
        return tmp_dice

    def equals(self, other_dice):
        tmp = Dice(*other_dice.numbers)
        tmp = self.align_top_and_front(tmp)
        #print(self.numbers)
        #print(tmp.numbers)
        if self.numbers == tmp.numbers:
            return True
        else:
            return False


def main():
    all_different = True
    n = int(input())
    dice = [Dice(*[int(i) for i in input().split()]) for _ in range(n)]

    for i in range(n-1):
        for j in range(i+1, n):
            if dice[i].equals(dice[j]):
                all_different = False

    if all_different:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()


Measured memory_bytes: 6080
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c;
    if(a<=b)
    {
    cout<<1<<endl;
    return 0;
    }
    if(b<=c)
    {
    cout<<-1;
    return 0;
	}
	if((a-b)%(b-c)>=1)
	{
    d=1;
    }
    else
    d=0;
    ans=((a-b)/(b-c)+d)*2+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//テンプレ
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//
signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int T,X;
   cin >> T >> X ;
   cout << static_cast<double>(T)/X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define f first
#define s second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    lli n, k;
    cin >> n >> k;
    cout << min((n % k), (k - (n % k))) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
int main() {
	  ll a,b,c,k;
	  cin>>a>>b>>c>>k;
	  ll ans=1,co=0;
	  while(b<=a)
	  {
	      co++;
	      b*=2;
	      if(co>k)
	      {ans=0;break;}
	  }
	  if(ans==1){
	  while(c<=b)
	  {
	      co++;
	      c*=2;
	      if(co>k)
	      {ans=0;break;}
	  }}
	  if(ans==0)cout<<"No";
	  else
	  cout<<"Yes";
	  
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=s.size();
    for (int i=0;i<a;i++)
    {
        if (i%2==0)
        cout<<s[i];
    }
    cout<<endl;
    system ("pause");
    return 0;
}

Measured memory_bytes: 756
def main():
  import sys
  sys.setrecursionlimit(10**5+10)
  N, M, K = map(int,input().split())
  class UnionFind:
      def __init__(self, N):
          self.par = [-1 for i in range(N+1)]
          self.rank = [1]*(N+1)

      def find(self, x):
          if self.par[x] < 0:
              return x
          else:
              self.par[x] = self.find(self.par[x])
              return self.par[x]

      def same_check(self, x, y):
          return self.find(x) == self.find(y)

      def union(self, x, y):
          x = self.find(x)
          y = self.find(y)

          if self.rank[x] > self.rank[y]:
              self.par[x] += self.par[y]
              self.par[y] = x
          else:
              self.par[y] += self.par[x]
              self.par[x] = y
              if self.rank[x] == self.rank[y]:
                  self.rank[x] += 1

  UF = UnionFind(N)
  friendlist = [[] for _ in range(N+1)]
  for n in range(M):
      A, B = map(int,input().split())
      friendlist[A].append(B)
      friendlist[B].append(A)
      if not UF.same_check(A,B):
          UF.union(A, B)
  blocklist = [[] for _ in range(N+1)]
  for n in range(K):
      C, D = map(int, input().split())
      blocklist[C].append(D)
      blocklist[D].append(C)

  for person in range(1,N+1):
      root = UF.find(person)
      ans = -UF.par[root]-1
      ans -= len(friendlist[person])
      for l in blocklist[person]:
          if UF.same_check(person,l):
              ans -= 1
      print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 62528
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N,M,L,R;

int main(){
    cin >> N >> M;
    ll ans = 0;
    ll l = 0, r = INF;
    REP(i,M){
        cin >> L >> R;
        l = max(l,L);
        r = min(r,R);
    }
    cout << max(0LL, r - l + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define int long long
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vector<int>a(100001);
signed main() {
int n,ans=0;
  cin >>n;
REP(i,100001){
    a[i]=0;
} 
REP(i,n){
int b;
cin>>b;
a[b]+=1;
}
REP(i,100001){
    ans+=a[i]*i;
}
int q;
cin >> q;
REP(i,q){
    int bi,ci;
cin >> bi >> ci;
a[ci]+=a[bi];
ans-=a[bi]*bi;
ans+=a[bi]*ci;
  a[bi]=0;
 cout << ans <<endl;
}

}

Measured memory_bytes: 3848
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=3e5+10;
const int mod=1e9+7;
char mp[2020][2020];
int dis[2020][2020];
int vis[2020][2020];
int h,w,x11,y11,x2,y2;
int sum=inf;
int dx[4]= {0,0,1,-1};
int dy[4]= {1,-1,0,0};
struct A
{
    int x,y,v;
    A(int x=0,int y=0,int v=0):x(x),y(y),v(v) {}
    bool operator<(const A&o)const//优先队列的大小比较
    {
        return v>o.v;
    }
};
int main()
{
    cin>>h>>w;
    cin>>x11>>y11;
    cin>>x2>>y2;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin>>mp[i][j];
        }
    }
    memset(dis,inf,sizeof(dis));
    priority_queue<A>q;
    q.push(A(x11,y11,dis[x11][y11]));
    dis[x11][y11]=0;
    while(!q.empty())
    {

        int x=q.top().x;
        int y=q.top().y;
        q.pop();
        if(vis[x][y])
        {
            continue;
        }
        vis[x][y]=1;
        for(int i=0; i<4; i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')//没有越界，不是#
            {
                if(dis[xx][yy]>dis[x][y])
                {
                    dis[xx][yy]=dis[x][y];
                    q.push(A(xx,yy,dis[xx][yy]));
                }
            }
        }
        for(int i=-2; i<=2; i++)
        {
            for(int j=-2; j<=2; j++)
            {
                int xx=x+i;
                int yy=y+j;
                if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&mp[xx][yy]!='#')
                {
                    if(dis[xx][yy]>dis[x][y]+1)
                    {
                        dis[xx][yy]=dis[x][y]+1;
                        q.push(A(xx,yy,dis[xx][yy]));
                    }
                }
            }
        }
    }
    if(dis[x2][y2]==inf)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dis[x2][y2]<<endl;
    }
    system("pause");
    return 0;
}


Measured memory_bytes: 29508
#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class PrimeTest{
private:
	std::vector<bool> is_prime_;					//nが素数かどうかをis_prime[n]で判定
	std::vector<unsigned int> prime_numbers_;		//素数の集合

public:
	PrimeTest();

	~PrimeTest();

	const std::vector<unsigned int>& get_prime_numbers() const;

	bool is_prime(unsigned int n);

};

PrimeTest::PrimeTest(){
	is_prime_.push_back(false);	//0
	is_prime_.push_back(false);	//1
	is_prime_.push_back(true);	//2
	is_prime_.push_back(true);	//3

	prime_numbers_.push_back(2);
	prime_numbers_.push_back(3);
}
PrimeTest::~PrimeTest(){}

const std::vector<unsigned int>& PrimeTest::get_prime_numbers() const{
	return prime_numbers_;
}

bool PrimeTest::is_prime(unsigned int n){
	if(n >= is_prime_.size()){
		unsigned int i_s = is_prime_.size();
		is_prime_.resize(n + 1, false);

		//i_sからnまでの各数が素数かどうか判定
		for(unsigned int i = i_s; i <= n; i++){
			unsigned int max_val = int(sqrt((double)i));
			bool b = true;
			for(unsigned int j = 0; j < prime_numbers_.size(); j++){
				if(prime_numbers_[j] > max_val){ break;}
				if(i % prime_numbers_[j] == 0){
					b = false;
					break;
				}
			}
			if(b){
				prime_numbers_.push_back(i);
				is_prime_[i] = true;
			}
		}

	}
	return is_prime_[n];
}

int main(){
	PrimeTest prime_test;
	int n;
	int result;
	std::vector<unsigned int> prime_numbers;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

	prime_test.is_prime(50000);
	prime_numbers = prime_test.get_prime_numbers();

#if INPUT_FROM_FILE
	while(fscanf(fp, "%d", &n) != EOF){
#else
	while(scanf("%d", &n) != EOF){
#endif
		if(n == 0){ break; }
		result = 0;
		for(int i = 0; i < prime_numbers.size(); i++){
			if(prime_numbers[i] > n){ break; }
			int m = n - prime_numbers[i];

			if(std::binary_search(prime_numbers.begin() + i, prime_numbers.end(), m)){
				result++;
			}
		}
		printf("%d\n", result);
	}

#if INPUT_FROM_FILE
	fclose(fp);
#endif
	return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a >= d)
    {
        cout << d << endl;
        return 0;
    }
    else
    {
        ll ans = 0;
        ans += a;
        d -= a;
        if(d <= b)
        {
            cout << ans << endl;
            return 0;
        }
        else
        {
            d -= b;
            ans -= d;
            cout << ans << endl;
            return 0;
        }
        
    }
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){

  int N,i,j,k,v;
  int A[100] ;

  for(i=0 ; i<100 ;i++){
    A[i] = 0;
  }
  scanf("%d",&N);
  for(i=0 ; i<N ;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N ;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  for(i=1 ; i <= N-1 ; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(k=0 ; k<N ;k++){
      if(k>0)printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  return 0 ;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll D, N;
        cin >> D >> N;
        ll tmp = round(pow(100, D));
        if (N != 100)
                cout << tmp * N << endl;
        else
                cout << tmp * 101 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

void set_data(int data[], int n){
    for(int i = 0; i < n; i++){
        scanf("%d", &data[i]);
    }
}

int calc_dis(int data[], int n, int mean){
    int dis = 0;
    for(int i = 0; i < n; i++){
        dis += (mean - data[i]) * (mean - data[i]);
    }
    return dis;
}
int main(void){
    int n, sum = 0;
    scanf("%d", &n);
    int data[n];
    set_data(data, n);
    for(int i = 0; i < n; i++){
        sum += data[i];
    }
    printf("%d\n", calc_dis(data, n, (double)sum / n + 0.5));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int num,t=0,x=0,y=0,flag=0;
	cin>>num;
	while(num--){
		int tmpt,tmpx,tmpy;
		cin>>tmpt>>tmpx>>tmpy;
		if(abs(tmpx-x)+abs(tmpy-y)>abs(tmpt-t)||(abs(tmpt-t)-abs(tmpx-x)-abs(tmpy-y))%2)
			flag = 1;
		t =tmpt;x = tmpx;y = tmpy;
	}
	flag==1?cout<<"No"<<endl:cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	string str;cin >> str;
	str += "#";
	char pre = str[0];
	ll ans = 0;

	REP(i, str.size()){
		if(str[i] != pre)ans++;
		pre = str[i];
	}

	cout << ans << endl;

	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
vector<int> graph[10];
int v, e;
int dfs(int start, int depth, bool* seen)
{
    int ret = 0;
    int counter = 0;
    bool n_seen[8];
    for(int i = 0; i < 8; i++)n_seen[i] = seen[i];
    n_seen[start] = true;
    depth++;
    for (auto &&i : graph[start])
    {
        if(!n_seen[i])
        {
            ret+=dfs(i,depth,n_seen);
            counter++;
        }
    }
    if(counter == 0)
    {
        if(depth == v) ret = 1;
        else ret = 0;
    }
    return ret;
}
int main()
{
    
    cin >> v >> e;
    rep(i,e)
    {
        int from, to;
        cin >> from >> to;
        --from; --to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    bool seen[8];
    rep(i,8)seen[i] = false;
    cout << dfs(0,0, seen) << endl;

}

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

int main(){
    int n;
    cin >> n;
    int d[n][2] = {};

    for(int i=0; i<n; i++) {
        for(int j=0; j<2; j++) {
            cin >> d[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<2; j++) {
            if(d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] 
            && d[i+2][0] == d[i+2][1]) ans++;
        }
    }

    if(ans == 0) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;

    if(a<b && b<c)
    {
         cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3116
## ABC 086B
## B - 1 21
import sys

a,b = (int(_) for _ in input().split())

ab = int(str(a)+str(b))

for i in range(ab):
    if(i**2 == ab):
        print('Yes')
        sys.exit()
    elif(i**2 > ab):
        break
    else:
        continue
print('No')

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



using namespace std;

int main(){
  
  int n,x,t;
  cin >> n >> x >> t;
  if (n%x==0){
    cout << n/x*t << endl;
  }else {
    cout << (n/x+1)*t << endl;
  }
  
 
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=LLONG_MAX;
int32_t main()
{
	int n,k;cin>>n>>k;
	vector<int>A(n);
	for(int i=0;i<n;i++)cin>>A[i];
	sort(A.begin(),A.end());
	for(int i=0;i<=n-k;i++)
	{
		ans=min(ans,abs(A[i]-A[i+k-1]));
	}
	cout<<ans<<endl;
}
	
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 1024
N, M = list(map(int, input().split()))

D = list(map(int, input().split()))

S = {0 : 1}
t = 0
for i in range(N):
  t = (t + D[i]) % M
  if t in S:
    S[t] += 1
  else:
    S[t] = 1

r = 0

for i in S.values():
  r += i * (i - 1) // 2
  
print(r)


Measured memory_bytes: 14224