akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
	cout << 5 + max({ (n-1) / a,(n-1) / b,(n-1) / c,(n-1) / d,(n-1) / e }) << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indices = []
  maximum = -1
  for i in range(len(L)):
    if L[i] > maximum:
      indices = [i]
      maximum = L[i]
    elif L[i] == maximum:
      indices.append(i)
  return indices,maximum

indices_H,max_H = argmax(count_H)
indices_W,max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)

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

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

    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct dat{
  char col[4];
};
struct dat2{
dat F,B,U,D,L,R;
};

dat2 cube;
dat F,B,U,D,L,R;

dat write(dat A,int a1,int a2,dat B,int b1,int b2){
  A.col[a1] = B.col[b1];
  A.col[a2] = B.col[b2];
  return A;
}

void cp(){
  F = cube.F;
  B = cube.B;
  U = cube.U;
  D = cube.D;
  L = cube.L;
  R = cube.R;
}

dat rot(dat A){
  swap(A.col[0],A.col[2]);
  swap(A.col[2],A.col[3]);
  swap(A.col[3],A.col[1]);
  return A;
}

void Front(){
  cp();
  cube.F  = rot(F);
  cube.U  = write(U,2,3,L,3,1);
  cube.L  = write(L,3,1,D,1,0);
  cube.D  = write(D,1,0,R,0,2);
  cube.R  = write(R,0,2,U,2,3);
}

void Up(){
  cp();
  cube.U = rot(U);
  cube.F = write(F,0,1,R,0,1);
  cube.R = write(R,0,1,B,0,1);
  cube.B = write(B,0,1,L,0,1);
  cube.L = write(L,0,1,F,0,1);
}

void Down(){
  cp();
  cube.D = rot(D);
  cube.F = write(F,2,3,L,2,3);
  cube.L = write(L,2,3,B,2,3);
  cube.B = write(B,2,3,R,2,3);
  cube.R = write(R,2,3,F,2,3);
  
}

void Left(){
  cp();
  cube.L=rot(L);
  cube.U = write(U,0,2,B,3,1);
  cube.B = write(B,3,1,D,0,2);
  cube.D = write(D,0,2,F,0,2);
  cube.F = write(F,0,2,U,0,2);
}

void Right(){
  cp();
  cube.R = rot(R);
  cube.U =write(U,1,3,F,1,3);
  cube.F =write(F,1,3,D,1,3);
  cube.D =write(D,1,3,B,2,0);
  cube.B =write(B,2,0,U,1,3);
}

void Back(){
  cp();
  cube.B = rot(B);
  cube.U = write(U,0,1,R,1,3);
  cube.R = write(R,1,3,D,3,2);
  cube.D = write(D,3,2,L,2,0);
  cube.L = write(L,2,0,U,0,1);
}

dat ume(char c){
  dat a;
  for(int i=0;i<4;i++) a.col[i] = c;
  return a;
}

signed main(){
  string str;
  cin>>str;

  cube.F = ume('y');
  cube.B = ume('w');
  cube.L = ume('g');
  cube.R = ume('b');
  cube.U = ume('r');
  cube.D = ume('o');
  

  for(int i=0;i<str.size();i++){
    if(str[i] == 'R') Right();
    if(str[i] == 'L') Left();
    if(str[i] == 'U') Up();
    if(str[i] == 'D') Down();
    if(str[i] == 'F') Front();
    if(str[i] == 'B') Back();
  }

  char mp[6][8];
  memset(mp,'.',sizeof(mp));
  
  for(int i=0;i<4;i++){
    mp[0+(i/2)][2+(i%2)]=cube.U.col[i];
    mp[2+(i/2)][0+(i%2)]=cube.L.col[i];
    mp[2+(i/2)][2+(i%2)]=cube.F.col[i];
    mp[2+(i/2)][4+(i%2)]=cube.R.col[i];
    mp[2+(i/2)][6+(i%2)]=cube.B.col[i];
    mp[4+(i/2)][2+(i%2)]=cube.D.col[i];
  }

  for(int i=0;i<6;i++){
    for(int j=0;j<8;j++)cout<<mp[i][j];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
int main(){
  using BS = bitset<32>;
  Int x;
  cin>>x;
  BS b(x);
  cout<<b<<endl;
  cout<<(~b)<<endl;
  cout<<(b<<1)<<endl;
  cout<<(b>>1)<<endl;
  return 0;
}



Measured memory_bytes: 3164
import bisect

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()

ans = 0
for j in range(N):
    i = bisect.bisect_left(A, B[j])
    k = bisect.bisect_right(C, B[j])
    ans += i * (N - k)

print(ans)

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

namespace Atc_0045
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            long N = long.Parse(S.Split(' ')[0]);
            long K = long.Parse(S.Split(' ')[1]);

            var Ps = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();



            for (long i = K; i < N; i++)
            {
                if (Ps[i - K] < Ps[i])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


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

int main(){
  string s, p, ans = "No";
  int init;
  cin >> s >> p;
  init = s.length();
  s.append(s);

  for(int i=0; i<init; i++){
    bool flag = true;
    for(int j=0; j<p.length(); j++){
      if(p[j] != s[j+i]){
	flag = false;
	break;
      }
    }
    if(flag){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string.h>
int max(int a, int b){
    if(a<b)return b;
    else return a;
}
int min(int a, int b){
    if(a<b)return a;
    else return b;
}
int main(void){
    char s[500000+5];
    scanf("%s", s);
    int n=strlen(s);
    
    long int ans=0;
    // aの各項について、左に連続する < の個数と右の連続する > の個数の max が条件を満たす数列
    int i=0;
    while(i<n){
        int l=0, r=0;
        for(l=0 ; s[i]=='<'; i++, l++){}
        for(r=0 ; s[i]=='>'; i++, r++){}

        for(int j=1; j<min(r, l); j++)ans+=j;
        for(int j=1; j<=max(r, l); j++)ans+=j;
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 2224
// AOJ 0339: Geometric Data
// 2017.11.13 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int p1, p2, p3; } T;
T tbl[1002];

int cmp(T *a, T *b)
{
	if (a->p1 == b->p1 && a->p2 == b->p2) return a->p3 - b->p3;
	if (a->p1 == b->p1) return a->p2 - b->p2;
	return a->p1 - b->p1;
}

int main()
{
	int n, i, p1, p2, p3, x;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d", &p1, &p2, &p3);
		if (p1 > p2) x = p1, p1 = p2, p2 = x;
		if (p1 > p3) x = p1, p1 = p3, p3 = x;
		if (p2 > p3) x = p2, p2 = p3, p3 = x;
		tbl[i].p1 = p1, tbl[i].p2 = p2, tbl[i].p3 = p3;
	}
	qsort(tbl, n, sizeof(T), cmp);
	for (x = 0, i = 1; i < n; i++) {
		if (!memcmp(tbl+i, tbl+i-1, sizeof(T))) x++;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 1884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, n = 0;
  cin >> A >> B;

  for (int i = A; i < (B+1); i++){
//    cout <<i<< endl;
    int X = i, j = 0;
    while (X >= 1) {
//      int x_j = X%10;
      X /= 10;
      j++;
    }
//    cout <<j<< endl;

    bool flag = true;
    for (int k = 0; k < (j/2); k++) {
//      if (x_k == x_(j-k+1))
      int a = 1, b = 1, x, y;
      for (int l = 0; l < k; l++)
        a *= 10;
      x = (i / a) % 10;
      for (int l = 0; l < (j-k-1); l++)
        b *= 10;
      y = (i / b) % 10;
      
      if (x == y)
        continue;
      else {
        flag = false;
        break;
      }
    }

    if (flag)
      n++;
  }

  cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

int n;
int ans = 0;

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

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (ans == 0) {
      ans = x;
    } else {
      ans = gcd(ans, x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int a[100002], b[100002];
    set<P> st;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        st.insert(P(a[i], b[i]));
    }
    int ans[10] {0};
    for(int k = 0; k < n; k++){
        for(int l = max(1, a[k] - 2); l <= min(a[k], h - 2); l++){
            for(int u = max(1, b[k] - 2); u <= min(b[k], w - 2); u++){
                int count = 0;
                for(int i = l; i <= l + 2; i++){
                    for(int j = u; j <= u + 2; j++){
                        if(st.find(P(i, j)) != st.end()) count++;
                    }
                }
                if(count != 0) ans[count]++;
            }
        }
    }
    ll sum = 0;
    for(int i = 1; i < 10; i++){
        sum += ans[i] / i;
    }
    ll hh = h - 2, ww = w - 2;
    ll ans0 = hh * ww - sum;
    cout << ans0 << endl;
    for(int i = 1; i < 10; i++) cout << ans[i] / i << endl;
}

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

int main(void){
    unsigned long long int L, R;
    int l, r, ans;
    cin >> L >> R;
    l = L % 2019;
    r = R % 2019;
    if(R - L >= 2019){
        ans = 0;
    }else{
        if(l > r){
            ans = 0;
        }else{
            ans = (l * r) % 2019;
            for(int i = l; i < r ; i++){
                for(int j = i + 1; j <= r; j++){
                    if((i * j) % 2019 < ans){
                        ans = (i * j) % 2019;
                        if(ans == 0)
                            break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

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

    set<char> arares;
    for (int i = 0; i < N; ++i) {
        char s;
        cin >> s;
        arares.insert(s);
    }

    cout << (arares.size() == 3 ? "Three" : "Four") << endl;

}

Measured memory_bytes: 256
using namespace std;
#include <iostream>/*{{{*/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

#include <bits/stdc++.h>

#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#define DEBUG_ // 提出時はコメントアウト
#ifdef DEBUG_
#define DEB
#else
// DEB と打つとデバッグ時以外はコメントアウトになる
#define DEB /##/
#endif

// 変数ダンプ用マクロ。デバッグ時以外は消滅する
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DEB DUMPOUT<<"  "; \
DUMPOUT<<#__VA_ARGS__; \
DUMPOUT<<":=> "; \
dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/
#define debug(x)                 cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define debug2(x, y)             cerr << __LINE__ << #x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define debug3(x, y, z)          cerr << __LINE__ << #x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug4(a, b, c, d)       cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define debug5(a, b, c, d, e)    cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define debug6(a, b, c, d, e, f) cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define db_2d(d,n,m) rep(i,n){rep(j,m){ cerr << (d)[i][j] << (((j)==(m-1))?"\n":" "); }}
#define db_1d(d,n) rep(i,n){cout << d[i] << (((i)==(n-1))?"\n":" ") << __LINE__}
#define INF 999999999
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  cout << ((a+b>=10) ? "error":to_string(a+b)) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.FileInputStream
import java.util.*


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    val A = Math.min(sc.nextInt(), sc.nextInt())
    val B = Math.min(sc.nextInt(), sc.nextInt())


    //println(brues)
    println(A + B)

}



Measured memory_bytes: 31280
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>


int main(void)
{
	long long int n=0;
	char s[100];
	char t[100];
	long long int i,j,k;
	long long int m=0,a=0,r=0,c=0,h=0;
	long long int ki=123456789123456789;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%s",&s);
		if(s[0]=='M'){m++;}
		if(s[0]=='A'){a++;}
		if(s[0]=='R'){r++;}
		if(s[0]=='C'){c++;}
		if(s[0]=='H'){h++;}
	}
	//if(k==1){printf("Four\n");}else{printf("Three\n");}
	//printf("%d%d%d%d%d\n",m,a,r,c,h);
	printf("%lld\n",m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h);
	//printf("%lld",ki);
	return 0;
}




Measured memory_bytes: 128
///Mn kotr el labawy mb2t4 nawy
#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MOD =  998244353;
vector<int> adj[N];
int u[N], v[N], col[N];
void dfs(int node, int par, int c = 0){
  int ptr = 1;
  for(auto child : adj[node]){
    int to = u[child] ^ v[child] ^ node;
    if(to == par)continue;
    if(ptr == c)ptr++;
    col[child] = ptr++;
    dfs(to, node, col[child]);
  }
}
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;

  for(int i = 1; i < n; i++){
    cin >> u[i] >> v[i];
    adj[u[i]].push_back(i);
    adj[v[i]].push_back(i);
  }

  dfs(1, 1);

  cout << *max_element(col+1,col+n+1) << endl;

  for(int i = 1; i < n; i++)
    cout << col[i] << endl;


  return 0;
}


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


int main() {
	int h, w;
	scanf ("%d %d", &h, &w);
	int n;
	scanf ("%d", &n);
	vector<int> a(n+1);
	for (int i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
	}
	
	int form[105][105];
	for (int i = 0; i < 105; i++) {
		for (int j = 0; j < 105; j++) {
			form[i][j] = 0;
		}
	}

	int b = 0;
	int cnt = a[0];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			form[i][j] = b+1;
			cnt--;
			if (cnt == 0) {
				b++;
				cnt = a[b];
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (form[i][j] != 0) {
				if (i%2 == 0) {
					printf("%d", form[i][j]);
				} else {
					printf("%d", form[i][w-j-1]);
				}
			}
			if (j == w-1) {
				printf("\n");
			} else {
				printf(" ");
			}
		}
	}
	
	return 0;
}


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

typedef long long LL;

LL X;

int main() {
  cin >> X;
  LL v = 1;
  for (int j = 0; j < X+1; ++j) { v = 2 * v + 1; }
  cout << v-1 << endl;  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1566,mo=998244353;
int n;char s[N][N];
int bh[N][N],num,fa[N*N],val[N*N],dfn[N*N],deg[N];Vi e[N][N],to[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void merge(int x, int y){
	x=find(x);y=find(y);
	if(x!=y){
		if(val[x]+val[y]==1){puts("0");exit(0);}
		fa[x]=y;if(val[x]>=0)val[y]=val[x];
	}
}
void access(int x, int y, int bel){
	if(e[x][y].empty()||e[x][y].back()!=bel)e[x][y].pb(bel);
}
void addedge(int u, int v){to[u].pb(v);}
bool vis[N];int len,se[N];
void dfs(int u){
	vis[u]=1;se[++len]=u;
	rep(i,0,SZ(to[u])-1)if(!vis[to[u][i]])dfs(to[u][i]);
}
int solve(int n){
	if(n%2==0){
		int res=1;
		rep(u,1,n)rep(i,0,SZ(to[u])-1)if(u<to[u][i])res=2*res%mo;
		return res;
	}
	memset(vis,0,sizeof(vis));
	int res=1;
	rep(i,1,n)if(!vis[i]){
		len=0;dfs(i);
		if(len==1&&deg[i])return 0;
		int tot=-(len-1);
		rep(j,1,len)rep(k,0,SZ(to[se[j]])-1)if(se[j]<to[se[j]][k])tot++;
		while(tot--)res=2*res%mo;
	}
	return res;
}
int main() {
	read(n);
	rep(i,1,n-1){
		scanf("%s",s[i]+1);
	}
	rep(i,1,n-1)rep(j,1,n-1){
		bh[i][j]=++num;
		val[num]=s[i][j]=='?'?-1:(s[i][j]=='x');fa[num]=num;
	}
	rep(i,1,n-1){
		merge(bh[i][i],bh[n-i][n-i]);
		merge(bh[i][n-i],bh[n-i][i]);
	}
	rep(i,1,n-1)rep(j,1,n-1)if(i!=j&&i+j!=n){
		merge(bh[i][j],bh[j][i]);
		merge(bh[i][j],bh[n-i][n-j]);
		merge(bh[i][j],bh[n-j][n-i]);
	}
	rep(x,1,n){
		rep(i,x,n)access(i,i-x,x),access(n-i,n-(i-x),x);
		rep(i,0,x)access(i,x-i,x),access(n-i,n-(x-i),x);
	}
	int res=1;
	static int bh1[N];memset(bh1,0,sizeof(bh1));
	int tot=0;for(int i=0;i<=n;i+=2)bh1[i]=++tot;
	rep(i,1,n-1)rep(j,1,n-1)if(find(bh[i][j])==bh[i][j]&&bh1[e[i][j].back()])
		if(val[bh[i][j]]>=0){deg[bh1[e[i][j][0]]]^=val[bh[i][j]];deg[bh1[e[i][j][1]]]^=val[bh[i][j]];}
		else addedge(bh1[e[i][j][0]],bh1[e[i][j][1]]),addedge(bh1[e[i][j][1]],bh1[e[i][j][0]]);
	res=solve(tot);
	memset(bh1,0,sizeof(bh1));tot=0;for(int i=1;i<=n;i+=2)bh1[i]=++tot;
	memset(deg,0,sizeof(deg));rep(i,0,n)to[i].clear();
	rep(i,1,n-1)rep(j,1,n-1)if(find(bh[i][j])==bh[i][j]&&bh1[e[i][j].back()])
		if(val[bh[i][j]]>=0){deg[bh1[e[i][j][0]]]^=val[bh[i][j]];deg[bh1[e[i][j][1]]]^=val[bh[i][j]];}
		else addedge(bh1[e[i][j][0]],bh1[e[i][j][1]]),addedge(bh1[e[i][j][1]],bh1[e[i][j][0]]);
	res=1LL*res*solve(tot)%mo;printf("%d\n",res);
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<int>p(n+1);
    rrep(i,n) cin>>p[i];
    int a = -1;
    rep(i,n) {
        if(p[i+1]-p[i]!=1) {
            if(a != -1) {
                swap(p[a],p[i+1]);
                break;
            }
            a = i+1;
            i++;
        }
    }
    rrep(i,n) {
        if(p[i] != i) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll gcl(ll a, ll b){
    return a / gcd(a, b) * b;
}

using namespace std;

int main()
{
    ll l, r;
    cin >> l >> r;
    ll m = l % 2019;
    ll n = r % 2019;
    ll ans = INF;
    ll f = 0;
    rep(i, 2020){
        for(ll j=i+1; j<2020; j++){
            if(l + j > r){
                break;
            }    
            ans = min(((l+i) * (l+j))%2019, ans);
        }
        if((l+i) > r) break;
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int fact[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

signed main()
{
    int N;
    cin >> N;
    int ans = 0;
    REP(i, 10) {
        if(N < fact[i]) {
            break;
        } else {
            ans = fact[i];
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

 int n, a[100], i, j, min, z;
 min=0;
 scanf("%d", &n);

 for(i=0; i<n; i++){
  scanf("%d", &a[i]);
 }
 i=0;
 for(j=0; j<n; j++){
  z=0;
  while(a[i]==a[i+1]){
   z+=1;
   i+=1;
  }
   if(z%2==0){
    min+=z/2;
   }
   else{
    min+=(z+1)/2;
   }

 if(z==0)
  i+=1;

 if(i==n-1)
  break;
}

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

return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  
  vector<int>::iterator max_itr = max_element(l.begin(), l.end());
  int sum = 0;
  for(vector<int>::iterator it=l.begin(); it!=l.end(); it++)
  {
    if(it != max_itr)
      sum += *it;
  }
  
  if(*max_itr < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0)
    {
        cout << (B - A) / 2 << endl;
    }
    else
    {
        long long a = (A - 1) + ((B - (A - 1) - 1) - 1) / 2 + 1;
        long long b = (N - B) + (N - (A + (N - B) + 1)) / 2 + 1;
        cout << min(a, b) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define P ((ll)(1e9+7))
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

ll n, k;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

ll fac[MAX], inv[MAX];
void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; i--){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

ll C(ll n, ll m){
    return fac[n]*inv[m]%P*inv[n-m]%P;
}

ll calc(ll n, ll m){
    return C(n+m-1, m-1);
}

int main()
{
    init();
    cin >> n >> k;
    ll x = min(n, k);
    ll ans = 0;
    for(int i = 1; i <= x; i++){
        ans = (ans + C(n, i)*calc(i, n-i)%P)%P;
    }
    if(k > 1) ans = (ans+1)%P;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
#include <iomanip>

using namespace std;

int main()
{
	int N,K;

	double ans = 0;

	cin >> N >> K;

	for(int i=1;i<=N;i++)
	{
		int point = i;
		int cnt = 0;
		if(i >= K)
		{
			ans += 1.0/N;
			continue;
		}

		while(point < K)
		{
			point *= 2;
			cnt++;
		}
		ans += pow(0.5,cnt)/N;
	}

	cout << std::setprecision(11) << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  long long int a = 1, b = 1;
  int n; cin >> n;

  for(int i=0;i<n;++i){
    long long int c = a + b;
    a = b;
    b = c;
  }
  cout << a << endl;

  return 0;
}

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else cout <<  "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
string s;
vector<int> ax[2];
vector<int> ay[2];
struct e {
	int s;
	int k;
	int r;
};
map<pair<int, int>, bool> mm[2];
bool solve(int s, int k, int r) {
	if (mm[s].find(make_pair(k, r)) != mm[s].end()) {
		return mm[s][make_pair(k, r)];
	}
	if (ax[s].size() == k) {
		return mm[s][make_pair(k, r)] = (r == 0);
	}
	if (abs(ay[s][k]) < abs(r)) {
		return mm[s][make_pair(k, r)] = 0;
	}
	if (abs(ay[s][k]) == abs(r)) {
		return mm[s][make_pair(k, r)] = 1;
	}
	return mm[s][make_pair(k, r)] = (solve(s, k + 1, r + ax[s][k]) || solve(s, k + 1, r - ax[s][k]));
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	string s;
	cin >> s;
	int a = -1;
	rep(i, s.length()) {
		if (s[i] == 'T') {
			a = i;
			break;
		}
	}
	int x, y;
	cin >> x >> y;
	if (a == -1) {
		if (y == 0 && x == s.length()) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	x -= a;
	vector<int> p, q;
	int pp = 0;
	int r = 0;
	for (int i = a + 1; i < s.length(); i++) {
		if (s[i] == 'T') {
			if (pp) {
				if (r == 0) {
					q.push_back(pp);
				}
				else {
					p.push_back(pp);
				}
			}
			pp = 0;
			r++;
			r %= 2;
		}
		else {
			pp++;
		}
	}
	if (pp) {
		if (r == 0) {
			q.push_back(pp);
		}
		else {
			p.push_back(pp);
		}
		pp = 0;
	}
	ax[0] = p, ax[1] = q;
	ay[0] = ax[0], ay[1] = ax[1];
	reverse(ay[0].begin(), ay[0].end());
	reverse(ay[1].begin(), ay[1].end());
	rep(i, ax[0].size()) {
		if (i) {
			ay[0][i] += ay[0][i - 1];
		}
	}
	rep(i, ax[1].size()) {
		if (i) {
			ay[1][i] += ay[1][i - 1];
		}
	}
	reverse(ay[0].begin(), ay[0].end());
	reverse(ay[1].begin(), ay[1].end());
	if (solve(0, 0, x) && solve(1, 0, y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 42752
#include<bits/stdc++.h>
using namespace std;
int n,d,x[11][11],sum,cnt;
int main(){
    int i,j,k;
    scanf("%d %d",&n,&d);
    for(i=1;i<=n;i++){
        for(j=1;j<=d;j++){
            scanf("%d",&x[i][j]);
        }
    }
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            sum=0;
            for(k=1;k<=d;k++){
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(((int)sqrt(sum))*((int)sqrt(sum))==sum) cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int data[252];
void init(){
  REP(i,252)data[i]=-1;
}
int root(int a){
  return data[a]<0?a:data[a]=root(data[a]);
}
void unite(int a,int b){
  a=root(a);b=root(b);
  if(a!=b){
    if(data[a]<data[b])swap(a,b);
    data[a]+=data[b]; data[b]=a;
  }
}
bool same(int a,int b){
  return root(a)==root(b);
}

int main(){
  while(true){
    int n,m;
    cin>>n; if(!n)break;
    cin>>m;
    pair<int,pii> es[m];
    REP(i,m){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      es[i].first = c;
      es[i].second.first = a;
      es[i].second.second = b;
    }
    sort(es,es+m);
    init();
    int res = 0;
    REP(i,m){
      int a,b,c;
      a=es[i].second.first;
      b=es[i].second.second;
      c=es[i].first;
      if(!same(a,b)){
        unite(a,b);
        res += (c-100)/100;
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

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

template <typename T>
class weighted_quick_find {
	vector<pair<int, T>> data;
	vector<vector<int>> all;
public:
	weighted_quick_find(int n) : data(n), all(n, vector<int>(1)) {
		for (int i = 0; i < n; i++) {
			data[i].first = i;
			all[i][0] = i;
		}
	}
	void unite(int a, int b, T d) {
		if (same(a, b)) return;
		d += data[a].second - data[b].second;
		a = data[a].first;
		b = data[b].first;
		if (all[a].size() < all[b].size()) swap(a, b), d = -d;
		for (auto& id : all[b]) {
			data[id] = { a, data[id].second + d };
		}
		all[a].reserve(all[a].size() + all[b].size());
		copy(all[b].begin(), all[b].end(), back_inserter(all[a]));
	}
	bool same(int a, int b) const {
		return data[a].first == data[b].first;
	}
	T dist(int a, int b) const {
		return data[b].second - data[a].second;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	weighted_quick_find<int> wqf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			int z;
			cin >> z;
			wqf.unite(x, y, z);
		}
		else if (wqf.same(x, y)) {
			printf("%d\n", wqf.dist(x, y));
		}
		else {
			puts("?");
		}
	}
	return 0;
}



Measured memory_bytes: 10672
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
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> inline void in(T &a) { cin >> a; }
template <class T, class U> inline void in(T &a, U &b) { cin >> a >> b; }
template <class T, class U, class V> inline void in(T &a, U &b, V &c) {
  cin >> a >> b >> c;
}
template <class T> inline void out(T a) { std::cout << a << endl; }
template <class T, class U> inline void out(T a, U b) {
  cout << a << ' ' << b << endl;
}
template <class T, class U, class V> inline void out(T a, U b, V c) {
  cout << a << ' ' << b << ' ' << c << endl;
}
#define inf 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  int a, b, cc;
  in(a, b, cc);

  if (a == cc) {
    out(b);
  } else if (a == b) {
    out(cc);
  } else {
    out(a);
  }

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
 
int main(void){

  int a, b, c, x, y, z;
  a = b = c = x = y = z = 0;

  cin >> a >> b >> c;
 
  if(a > b){ x = a; a = b; b = x;}
  if(b > c){ y = b; b = c; c = y;}
  if(a > b){ z = a; a = b; b = z;}
 
  cout << a << " " << b << " " << c << endl;
 
  return 0;
 
}

Measured memory_bytes: 1164
import sys

N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
# print(S)

t = sum(S)
if t % 10 != 0:
    print(t)
    sys.exit()

for i in range(N):
    if S[i] % 10 == 0:
        continue
    t -= S[i]
    if t % 10 != 0:
        print(t)
        sys.exit()
print(0)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
//c++ templte for help...........................................................
 
//#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
//#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
//#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			
 
typedef long long ll;
	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 998244353
//const int INF=1e9+5;
 
 
 
 
//c++ template for help........................................................

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	//cout<<setprecision(2);
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 
		
			ll s,w;
			cin>>s>>w;
			if(w>=s) cout<<"unsafe"<<endl;
			else cout<<"safe"<<endl;
		
		
		
		
		
		
		
		
		
		
		
		
	 

	return 0;
}


Measured memory_bytes: 3636
input = gets.chomp
arr = input.split(' ')
a = arr[0].to_i
b = arr[1].to_i

### plag_num = 1
### count = a
###
### while true
###   break if count >= b
###   count += (a - 1)
###   plag_num += 1
### end
###
### p plag_num

ans = 0
outlet = 1
while outlet < b
  outlet -= 1
  outlet += a
  ans += 1
end

p ans

Measured memory_bytes: 3836
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var lrList = (1..n).map {
        val (l, r) = readLine()!!.split(" ").map(String::toLong)
        Pair(l, r)
    }
    lrList = lrList.sortedBy{ it.second }
    lrList = lrList.sortedBy { it.first }

    val leftSecondMinMap = Array(n) { lrList.first().second }
    val rightSecondMinMap = Array(n) { lrList.last().second }
    (1 until n).forEach { leftSecondMinMap[it] = Math.min(lrList[it].second, leftSecondMinMap[it - 1]) }
    (n - 2 downTo 0).forEach { rightSecondMinMap[it] = Math.min(lrList[it].second, rightSecondMinMap[it + 1]) }

    var maxScore = 0L
    for (i in 0 until n - 1) {
        val s1 = Math.max(0, leftSecondMinMap[i] - lrList[i].first + 1)
        val s2 = Math.max(0, rightSecondMinMap[i + 1] - lrList.last().first + 1)
        maxScore = Math.max(maxScore, s1 + s2)
    }

    lrList = lrList.sortedByDescending { it.second - it.first }
    val s3 = lrList[0].second - lrList[0].first+1
    val s4 = Math.max((1 until n).map{lrList[it].second}.min()!! - (1 until n).map{lrList[it].first}.max()!! + 1,0)
    maxScore = Math.max(maxScore,s3+s4)

    println(maxScore)
}

Measured memory_bytes: 88788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << ' ' << x << ' ' << y << endl;
}


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

using namespace std;

int main(void){
	vector<int> vId, vuId;
	map<int,int> mLastMonth, mCrrMonth;
	while(1){
		int id, day;
		char buf[32];
		
		cin.getline(buf,sizeof(buf)/sizeof(buf[0]));
		if( strlen(buf) == 0 )break;

		sscanf(buf, "%d,%d", &id, &day);
		mLastMonth[id]++;
		vId.push_back(id);
	}
	while(1){
		int id, day;
		string s;
		
		cin >> s;
		if( cin.eof() )break;

		sscanf(s.c_str(), "%d,%d", &id, &day);
		mCrrMonth[id]++;
	}
	sort( vId.begin(), vId.end() );
	vuId.resize(vId.size(),0);
	unique_copy( vId.begin(), vId.end(), vuId.begin() );
	for(unsigned int i = 0; i < vuId.size(); i++){
		if( mLastMonth[vuId[i]] > 0 && mCrrMonth[vuId[i]] > 0 ){
			cout << vuId[i] << ' ' << mLastMonth[vuId[i]] + mCrrMonth[vuId[i]] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,i,j,a[1010],b,c,co[1010]={},dp[1010][4100];
  cin >> n >> m;
  for (i=1;i<=m;i++){
    cin >> a[i] >> b;
    for (j=0;j<b;j++){
      cin >> c;
      co[i] |= 1<<(c-1);
    }
  }
  
  int y;
  const int INF=1e9;
  for (i=0;i<=m;i++) for (j=0;j<(1<<n);j++) dp[i][j]=INF;
  for (i=0;i<=m;i++) dp[i][0]=0;
  for (i=0;i<m;i++) for (j=0;j<(1<<n);j++){
    if (dp[i][j]==INF) continue;
    y=j|co[i+1];
    dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    dp[i+1][y]=min(dp[i+1][y],dp[i][j]+a[i+1]);
  }
  if (dp[m][(1<<n)-1]==INF) cout << -1 << endl;
  else cout << dp[m][(1<<n)-1] << endl;
  return 0;
}

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

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}

int main() {
    
    ll N;
    cin >> N;

    vector<string> S(N);
    unordered_map<string, ll> mp;
    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        cin >> S.at(i);

        if(!has_key(mp, S.at(i))) {
            mp[S.at(i)] = 1;
            ans += 1;
        }

    }

    cout << ans << endl;


    return 0;
}

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

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


Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n,x;
  scanf("%d%d",&n,&x);
  int a;
  scanf("%d",&a);
  int64 ans=0;
  if(a>x){
    ans+=a-x;
    a=x;
  }
  while(--n){
    int b;
    scanf("%d",&b);
    if(a+b>x){
      ans+=a+b-x;
      b-=a+b-x;
    }
    a=b;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
   char str[5];
   cin >> str;

   char str1[6]="Sunny";
   if(strcmp(str, str1)==0)
     cout<<"Cloudy";

   char str2[7]="Cloudy";
   if(strcmp(str,str2)==0)
     cout<<"Rainy";

   char str3[6]="Rainy";
   if(strcmp(str, str3)==0)
     cout<<"Sunny";
    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    string s;
    cin >> s;
    cout << s.front() << s.size() - 2 << s.back() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main (void){
int n,d;
scanf("%d%d",&n,&d);
int e=0;
int a[100][100];
for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
        scanf("%d",&a[i][j]);
    }
}
for(int i=0;i<n-1;i++){
    int c;
    int f[100];
    for(int p=i+1;p<n;p++){
    int b=0;
    for(int j=0;j<d;j++){
            b=b+(a[i][j]-a[p][j])*(a[i][j]-a[p][j]);
    }
    //printf("%d\n",b);
    c=sqrt(b);
    if(c*c==b){
        e++;
    }
    }
}
printf("%d",e);
return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        readInt;
        val arr = readLine.split(" ").map(_.toInt);
        readInt;
        val es = new ExhaustiveSearch(arr);
        readLine.split(" ").map(_.toInt).foreach { target => if (es.solve(target)) println("yes") else println("no")}
    }
}
class ExhaustiveSearch(arr: Array[Int]) {
    val size = arr.length;
    val sum = arr.foldLeft(0){ (s, v) => s + v};
    val dpArr = Array.ofDim[Int](size, sum + 1);
    def solve(target: Int): Boolean = {
        def _solve(idx: Int, t: Int): Boolean = {
            if (t == 0) {
                true;
            } else if (t < 0 || t > sum || idx >= size) {
                false;
            } else {
                if (dpArr(idx)(t) == 1) {
                    true;
                } else if (dpArr(idx)(t) == -1) {
                    false;
                } else {
                    if (_solve(idx + 1, t) || _solve(idx + 1, t - arr(idx))) {
                        dpArr(idx)(t) = 1;
                        true;
                    } else {
                        dpArr(idx)(t) = -1;
                        false;
                    }
                }
            }
        }
        _solve(0, target);
    }
}


Measured memory_bytes: 44564
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string s; cin >> s;
     cout << count(ALL(s), '1') << endl;
    return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n;cin>>n;
  string s;cin >>s;
  vector<int> vr(n),vw(n);
  int cr=0;
  int cw=0;
  for(int i=0;i<n;++i){
    auto tmp = s.substr(i,1);
    if(tmp=="R"){
      ++cr;
    } else {
      ++cw;
    }
    vr[i] = cr;
    vw[i] = cw;
  }
  cout << cr - vr[cr-1] << endl;
  return 0;
}


Measured memory_bytes: 5164