akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	unsigned char convert[256];
	int n,m,i;
	unsigned char cfrom[2];
	unsigned char cto[2];
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<256;i++)convert[i]=i;
		for(i=0;i<n;i++) {
			scanf("%s %s",cfrom,cto);
			convert[cfrom[0]]=cto[0];
		}
		scanf("%d",&m);
		for(i=0;i<m;i++) {
			scanf("%s",cfrom);
			putchar(convert[cfrom[0]]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; string s; cin >> n >> s;
    VL cnt(26);
    each(c, s)++cnt[c - 'a'];

    ll ans = 1;
    FOR(i, 0, 26)(ans *= cnt[i] + 1) %= mod;
    cout << ans - 1 << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9+7;
const ll mod= 1e9 + 7;

vector<ll> K(3000001);

ll mod_pow(ll x, ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x % mod, n / 2);
	if (n & 1) res = res * x % mod;
	return res;
}

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


	K[0] = 1;
	FOR(i, 1, 3000001)K[i] = (K[i-1] * i) % mod;

	ll X, Y,ans;
	cin >> X >> Y;
	ll A = 2 * X - Y, B = 2 * Y - X;
	if (A < 0 || A % 3 != 0)cout << 0 << endl;
	else if (B < 0 || B % 3 != 0)cout << 0 << endl;
	else {
		A /= 3; B /= 3;
		cout << (K[A+B]*mod_pow((K[A]*K[B])%mod,mod-2))%mod << endl;
	}
	

	return 0;
}

Measured memory_bytes: 23680
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	cin >> N;
	VP AB;
	LL ans = 0;
	FOR(i, 0, N) {
		LL a, b;
		cin >> a >> b;
		AB.push_back(MP(a, b));
	}
	sort(AB.begin(), AB.end());
	FOR(i, 0, AB.size()) {
		if (i == 0) {
			ans += AB[i].first;
		}
		else {
			ans += AB[i].first - AB[i - 1].first;
		}
		if (i == AB.size() - 1) {
			ans += AB[i].second;
		}
	}
	O(ans);

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define ub  upper_bound
#define lb  lower_bound
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  ll n;
  cin >> n;
  
  ll ans = 0;

  for(ll i=1;i<=n;i++)
    for(ll j=1;j<=n/i;j++){
      ll c = n-i*j;
      if(c > 0)
        ans++;
    }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        int ans = 0;

        for (int i = 0; i + 1 < N; i++)
            if (A[i] == i + 1)
            {
                ans++;
                Swap(ref A[i], ref A[i + 1]);
                i++;
            }
        if (A[N - 1] == N) ans++;

        Console.WriteLine(ans);
    }

    static void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 22112
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 9 + 7

N = int(readline())
T = list(map(int, readline().split()))
M = int(readline())

num = sum(T)
for _ in range(M):
    P, X = map(int, readline().split())
    print(num + X - T[P - 1])


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;

signed main(){

  ios::sync_with_stdio(false);cin.tie(0);

  int a, b;
  cin >> a >> b;

  if(a==1 && b==2){
    cout << 3 << '\n';
  }
  else if(a==2 && b==1){
    cout << 3 << '\n';
  }
  else if(a==2 && b==3){
    cout << 1 << '\n';
  }
  else if(a==3 && b==2){
    cout << 1 << '\n';
  }
  else cout << 2 << '\n';

  
}


Measured memory_bytes: 256
import sys;

v,e=map(int, input().split());

v_l=[0]*v;
e_b=[0]*e;
e_l=[0]*e;
result=0;

for i in range(v):
    v_l[i] = 0;
for i in range(e):
    e_b[i], e_l[i] = map(int, input().split());

def DFS(u):
    global result
    global v_l
    v_l[u] = 1
    for i in range(e):
        if(e_b[i] == u):
            if(v_l[e_l[i]] == 0):
                DFS(e_l[i])
            if(v_l[e_l[i]] == 1):
                result=1
    v_l[u] = 2

for i in range(v):
    DFS(i)
print(result)



Measured memory_bytes: 5636
import java.util.Scanner;
import java.lang.Math;
import java.math.BigDecimal;

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

       BigDecimal result = a.multiply(b).setScale(0, BigDecimal.ROUND_DOWN);
       System.out.println(result.toString());
    }
}

Measured memory_bytes: 35964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 998244353;
// const ll INF = 1000000000000000000LL;

int main(){
   int n;
   cin >> n;
   vector<ll> d(n);
   rep(i,n) cin >> d[i];
   bool zf = false;
   if(d[0]!=0) zf = true;
   for(int i=1;i<n;i++){
      if(d[i]<1) zf = true;
   }
   if(zf){
      cout << 0 << endl;
      return 0;
   }
   map<ll,ll> mp;
   rep(i,n){
      mp[d[i]]++;
   }
   ll ans=1;
   ll before;
   bool flag=false;
   if(*max_element(d.begin(),d.end())+1!=mp.size()){
      cout << 0 << endl;
      return 0;
   }
   for(auto a:mp){
      if(flag){
         rep(i,a.second) ans = ans*before%MOD;
         flag = false;
      }
      if(a.second>1){
         flag = true;
         before = a.second;
      }
   }
   cout << ans%MOD << endl;
   return 0;
}

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

int main() {
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    int sum = 0;
    for(int i = 0;i<N;i++){
        sum+=A.at(i);
    }
    if(sum<H) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 768
//============================================================================
// Name        : rough.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;



int main() {

	string s;
	cin>>s;

	int n=s.length();

	if(s[n-1]=='s')
	{
		s+='e';
		s+='s';
		cout<<s;
	}

	else
	{
		s+='s';
		cout<<s;
	}

}


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

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

  int a[n], b[n - 1], i;

  for (i = 0; i < n - 1; i++) {
    cin >> b[i];
  }

  int score = 0;

  for (i = 0; i < n - 1; i++) {
    if (i == 0)
      a[0] = b[0];
    else
      a[i] = min(b[i - 1], b[i]);
    score += a[i];
  }
  score += b[n - 2];

  cout << score << endl;

  return 0;
}


Measured memory_bytes: 256
n = input()
for i in range(int(n)):
    a,b,c = list(map(int,input().split()))
    a,b,c = int(a),int(b),int(c)
    if a**2 + b**2 == c**2 or c**2 + a**2 == b**2 or b**2 + c**2 == a**2:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5596
using System;
using System.Linq;

namespace _7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] a = new int[x[0] + 1, x[1] + 1];
            // r???c????????????
            for (int i = 0; i < x[0]; i++)
            {
                int[] now = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[1]; j++)
                {
                    a[i, j] = now[j];
                }
                a[i, x[1]] = now.Sum();
                Console.Write(a[i, 0]);
                for (int j = 1; j <= x[1]; j++)
                {
                    Console.Write(" " + a[i, j]);
                }
                Console.WriteLine();
            }
            int sum = 0;
            for (int i = 0; i < x[0]; i++)
            {
                sum += a[i, 0];
            }
            Console.Write(sum);
            for (int j = 1; j <= x[1]; j++)
            {
                sum = 0;
                for (int i = 0; i < x[0]; i++)
                {
                    sum += a[i, j];
                }
                Console.Write(" " + sum);
            }
            Console.WriteLine();
        }
    }
}

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

int main() {
	string S, T, U;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	cin >> U;
	if (U == S) A--;
	else B--;
	cout << A << ' ' << B << endl;
	return 0;
}


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

using namespace std;

class Rectangle{
public:
  int h;
  int w;
  Rectangle(int _h,int _w) : h(_h), w(_w) {}
};

int main(){
  int h, w;
  vector<Rectangle> data;
  while(!cin.eof()){
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    data.push_back(Rectangle(h, w));
  }

  for (vector<Rectangle>::size_type i = 0; i < data.size(); i++)
  {
    for(int j = 0; j < data[i].h; j++){
      for(int k = 0; k < data[i].w; k++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  


  return 0;
}


Measured memory_bytes: 3072
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	string s = to_string(a) + to_string(b);
	int x = stoi(s), ret = 0;
	for (int i = 0; i <= 1000; i++) {
		if (i * i == x) ret = 1;
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
	int a, b, c, d;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);

	int flag[10] = {};

	flag[a] = 1;
	flag[b] = 1;
	flag[c] = 1;
	flag[d] = 1;

	if (flag[1] && flag[9] && flag[7] && flag[4]) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] In = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            int a = In[0];
            int b = In[1];
            int[] P = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int x = 0, y = 0, z = 0;
            for(int i=0; i < n; i++)
            {
                if (P[i] <= a) x++;
                else if (P[i] <= b) y++;
                else z++;
            }
            int min = (int)Math.Min(x, Math.Min(y,z));
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 28104
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))

    X.sort()
    result = []
    for i in range(1, M):
        result.append(X[i] - X[i - 1])
    result.sort()

    if N >= M:
        print(0)
    else:
        print(sum(result[:M - N]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
string s[101];
int main() {
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s+n);
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

ll mod=1e9+7;

ll dp[13][100001];

ll modPow(ll n, ll place)
{
    int mods[6] = {1,10,9,12,3,4};
    place%=6;
    return (n*mods[place])%13;
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string st;
    cin >> st;
    // cout << st.size() << endl;
    if(st[st.size()-1]=='?')
    {
        F0R(i,13)
            dp[i][0]=0;
        F0R(i,10)
            dp[i][0]=1;
    }
    else
    {
        F0R(i,13)
            dp[i][0]=0;
        // cout << st[st.size()-1]-48 << endl;
        dp[st[st.size()-1]-48][0]=1;
    }
    // cout << "REACHED HERE" << endl;
    FOR(c,1,st.size())
    {
        if(st[st.size()-1-c]=='?')
        {
            F0R(r,13)
            {
                F0R(dig,10)
                {
                    dp[r][c]=(dp[r][c]+dp[(13-modPow(dig,c)+r)%13][c-1])%mod;
                }
            }
        }
        else
        {
            F0R(r,13)
            {
                dp[r][c]=dp[(13-modPow(st[st.size()-1-c]-48,c)+r)%13][c-1];
            }
        }
    }
    // cout << "st.size() " << st.size() << endl;
    // F0R(i,13)
    // {
        // F0R(j,st.size())
        // {
            // cout << dp[i][j] << " ";
        // }
        // cout << endl;
    // }
    cout << dp[5][st.size()-1];

    return 0;
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> input(n);
    for (int i=0;i<n;i++){
        cin >> input.at(i);
    }
    int cnt = 0;
    int nin = INF;
    for (int i=0;i<n;i++){
        if(input.at(i)<nin){
            cnt++;
            nin = min (nin , input.at(i));
        }
    }
    cout << cnt << endl;
    return 0;
}



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

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ll n,p;
  cin >> n >> p;
  map<ll,int> mp = prime_factor(p);
  ll ans=1;
  for(auto p:mp){
    if(p.second>=n)ans*=pow(p.first,p.second/n);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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 factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    // vector<ll> a(n);
    // rep(i, n) cin >> a[i];
    map<ll, ll> m;
    rep(i, n) {
        ll a; cin >> a; 
        m[a]++;
    }
    ll ans = 0;
    rep(x, (int)1e5+5) {
        ll tmp = 0;
        if (m.find(x-1) != m.end()) tmp += m[x-1]; 
        if (m.find(x) != m.end()) tmp += m[x];
        if (m.find(x+1) != m.end()) tmp += m[x+1];
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var dict = new Dictionary<string, int>();
        for (var i = 0; i < N; i++)
        {
            var s = Console.ReadLine();

            if (!dict.ContainsKey(s))
            {
                dict.Add(s, 1);
            }
            else
            {
                dict[s] += 1;
            }
        }
        
        var M = int.Parse(Console.ReadLine());
        for (var i = 0; i < M; i++)
        {
            var s = Console.ReadLine();

            if (dict.ContainsKey(s))
                dict[s] -= 1;
        }

        var max = dict.Select(d => d.Value).Max();
        Console.WriteLine(max < 0 ? 0 : max);
    }
}


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

int main() {
  int N, T, L, B;
  cout << fixed << setprecision(6);
  while (cin >> N >> T >> L >> B, N) {
    map<int, bool> Lose;
    for (int i = 0; i < L; i++) {
      int l;
      cin >> l;
      Lose[l] = true;
    }
    map<int, bool> Back;
    for (int i = 0; i < B; i++) {
      int b;
      cin >> b;
      Back[b] = true;
    }

    vector<vector<double>> dp(T + 2, vector<double>(N + 1, 0.0));
    dp[0][0] = 1.0;
    auto f = [&](int n, int p) {
      return (Lose[p]) ? n + 1 : n;
    };
    auto g = [&](int p) {
      int q = min(N, p) - max(0, p - N);
      return (Back[q]) ? 0 : q;
    };
    for (int i = 0; i < T; i++) {
      for (int j = 0; j < N; j++) {
        for (int k = 0; k < 6; k++) {
          dp[f(i + 1, j)][g(j + k + 1)] += 1.0 / 6.0 * dp[i][j];
        }
      }
    }

    double ans = 0;
    for (int i = 0; i < T + 1; i++) {
      ans += dp[i][N];
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;

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

    vector<int> W(n + 1);

    for (int i = 0; i < n; i++) {
        W[i + 1] += W[i] + (s[i] == 'W');
    }

    int ans = 1 << 20;
    for (int i = 0; i < n; i++) {
        ans = min(ans, W[i] + (n - i - 1 - (W[n] - W[i + 1])));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1796
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static boolean solve(String s){
		//System.out.println(s.charAt(0));
		int[] memo = new int[26];
		for(int i = 0;i < 26;i++){
			memo[i] = 0;
		}
		int index = -1;
		for(int i = 0;i < s.length();i++){
			index = (int)s.charAt(i) - 97;
			memo[index] += 1;
		}
		for(int i = 0;i < memo.length;i++){
			if(memo[i] > 1){
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        if(solve(s)){
        	System.out.println("yes");
        }else{
        	System.out.println("no");
        }
    }

}

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

#define MAXN 101

int main(void)
{
	int x = 0;
	int max = 0;
	char s[MAXN];
	int i, l;

	scanf("%d", &l);
	scanf("%s", s);

	for (i = 0; i < l; i++) {
		if (s[i] == 'I') {
			x++;
		} else if (s[i] == 'D') {
			x--;
		}
		if (max < x) {
			max = x;
		}
	}

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

	return (0);
}

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int a[3];
    rep(0, 3) cin >> a[i];

    sort(a, a + 3);

    int sum = 0;
    rep(1, 3) {
        sum += abs(a[i] - a[i-1]);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

def f():
    N = int(input())
    SL = [int(i) for i in input().split()]
    SL.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            ab = SL[i] + SL[j]
            r = bisect.bisect_left(SL, ab)
            l = j + 1
            ans += max(0, r - l)
    print(ans)

if __name__ == "__main__":
    f()

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);  
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0;i < n;i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		int sum = 0;
		for(int i = 0;i < n-1;i++) {
			sum += list.get(i);
		}
		System.out.println(sum += list.get(n-1) / 2);
		sc.close();
	}
}

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

int main()
{
    int N;
    string ST;

    scanf("%d",&N);
    getchar();
    getline(cin,ST);

    for(int x=0; x<ST.length(); x++)
    {
        if(ST[x] - 'A' + N >= 26)
            ST[x] = (ST[x] - 'A' + N - 26) + 'A';
        else
            ST[x] = (ST[x] - 'A' + N) + 'A';
    }

    cout << ST << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n, m;
	cin>>n>>m;
	ll x[m];
	scan(x, 0, m);
	
	if(m == 1){
		cout<<0<<endl;
		return 0;
	}
	sort(x, x+m);
	vlli v;
	forn(i, 1, m){
		v.pb(x[i] - x[i-1]);
	}
	sort(all(v));
	forn(i, 1, n){
		v.pop_back();
		if(v.size() == 0){
			break;
		}
	}
	ll ans = 0;
	forn(i, 0, v.size()){
		ans+=v[i];
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005],b[200005];
int main()
{
	ll n,m,k,x,ans=0;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) cin>>x,a[i]=a[i-1]+x;
	for(int i=1;i<=m;i++) cin>>x,b[i]=b[i-1]+x;
	ll j=m;
	for(int i=0;i<=n;i++)
	{
		if(a[i]>k) break;
		while(a[i]+b[j]>k) j--;
		ans=max(ans,i+j);
	}
	cout<<ans;
}

Measured memory_bytes: 6636
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function lineIn(){
		$buf = fgets(STDIN);
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->lineIn();
		
		if(2018 >= ($s[0].$s[1].$s[2].$s[3])){
			echo "Heisei\n";
			return true;
		}else if(2020 <= ($s[0].$s[1].$s[2].$s[3])){
			echo "TBD\n";
			return false;
		}else{
			if(0 == $s[5]){
				switch ($s[6]){
					case (1):
					case (2):
					case (3):
					case (4):
					echo "Heisei\n";
					return true;
					break;
					default:
					echo "TBD\n";
					return false;
					break;
				}
			}else{
				echo "TBD\n";
				return false;
			}
		}
	}
}
?>


Measured memory_bytes: 4604
class Stack:
    def __init__(self, max):
        self.max = max
        self.data = list(range(max))
        self.top = 0
    def initialize(self):
        self.top = 0
    def isEmpty(self):
        return self.top == 0
    def isFull(self):
        return self.top >= len(self.data)
    def push(self, x):
        #TODO: if isFull: error
        self.top += 1
        self.data[self.top] = x
    def pop(self):
        #TODO: if isEmpty: error
        self.top -= 1
        return self.data[self.top+1]

D = input().split()
# D = ['1', '2', '+', '3', '4', '-', '*']

s = Stack(300)

for i in range(len(D)):
    s.push(D[i])
    if D[i] == '+' or D[i] == '-' or D[i] == '*' or D[i] == '/':
        operator = s.pop()
        operand2 = s.pop()
        operand1 = s.pop()
        temp = eval(operand1 + operator + operand2)
        s.push(str(temp))
        # print('i: ' + str(i) + ' result: ' + str(temp) + '   ' + operand1 + operator + operand2)
print(s.pop())


Measured memory_bytes: 5572
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, x;
  std::vector<long> xs;
  Solver() {
    S002 r;
    r >= n >= x >n>= xs;
  }
  void solve() {
    xs.push_back(0);
    long res = 0;
    for(long i = n - 1; i >= 0; --i) {
      long t = xs[i] + xs[i+1] - x;      
      if( t > 0 ) {
        xs[i] -= t;
        res += t;
      }
    }
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env ruby

sum = 0

while line = gets
  stc = line.split('')
  ary = []

  stc.each do |chr|
    if chr =~ /^[0-9]+$/
      ary << chr.to_i
    else
      unless ary.length.zero?
        ary = ary.reverse
        (ary.length).times do |i|
          sum += ary[i] * (10 ** i)
        end
        ary = []
      end
    end
  end
end

puts sum

Measured memory_bytes: 8660
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	while(a>=b){
		b*=2;
		k--;
	}
	while(b>=c){
		c*=2;
		k--;
	}
	if(k>=0){
		cout<<"Yes";
	}
	else
		cout<<"No";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<":\n";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; ++i)
        if (n % i == 0 && 1 <= n / i && n / i <= 9) {
            cout << "Yes\n";
            return 0;
        }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;

ll dp[10000];

ll go(ll n){
	if(n==0) return 1;
	if(n==1 || n==2) return 0;
	ll &ans = dp[n];
	if(ans!=-1) return ans;
	ans=0;
	f(i,3,n+1){
		ans+=go(n-i);
		ans=ans%MOD;
	}
	return ans;
}

void solve(){

ll n;
cin>>n;

f(i,0,10000) dp[i]=-1;
ll ans=go(n);
cout<<ans<<endl;


}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3696
import numpy as np
n,d= map(int,input().split())
a=[]
for i in range(n):
    l=list(map(int,input().split()))
    a.append(l)
ans=0


for j in range(n):
    for k in range(n):
        bb=0
        for l in range(d):
            bb+=abs(a[j][l]-a[k][l])**2
        sq=np.sqrt(bb)
        if sq.is_integer():
            ans+=1
print(int((ans-n)/2))
    

Measured memory_bytes: 13188
import java.util.Scanner;


public class Main {
    
    public static void main(String[] args) {
        
        String s1,s2,s3;
        
        Scanner input = new Scanner(System.in);
        
        s1 = input.next();
        s2 = input.next();
        s3 = input.next();
        
       String a = s1.toUpperCase();
       String b = s2.toUpperCase();
       String c = s3.toUpperCase();
        
       char x = a.charAt(0);
       char y = b.charAt(0);
       char z = c.charAt(0);
       
       
        System.out.print(x);
        System.out.print(y);
        System.out.print(z);
        
        
        
    }
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    vector<int> arr;
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        arr.push_back(n);
    }

    long long ans=0;
    for(int i=1;i<arr.size();i++) {
        if(arr[i]<arr[i-1]) {
            ans+=(arr[i-1]-arr[i]);
            arr[i]+=(arr[i-1]-arr[i]);
        }
    }
    cout<<ans<<endl;

}




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

int main() {
  int n,a,x = 0;
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a;
    if(i %2 == 1 && a %2 == 1) x += 1;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3640
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = input[0];
    var b = input[1];
	//出力
	console.log(a*b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29444
#include<stdio.h>
int main(){
  int n,a[1000],save;
  int i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  if(n%2==0){
    for(i=0;i<n/2;i++){
      save = a[i];
      a[i] = a[n-1-i];
      a[n-1-i] = save;
    }
  }
  else for(i=0;i<=n/2;i++){
      save = a[i];
      a[i] = a[n-1-i];
      a[n-1-i] = save;
    }

  for(i=0;i<n;i++){
     printf("%d",a[i]);
     if(i<n-1) printf(" ");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int a,b,c,d;cin>>a>>b>>c>>d;
	cout<<max(0,min(b,d)-max(a,c))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long int
#define ld                   long double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define ppf                  pop_front
#define ppb                  pop_back
#define pi 		     acos(-1.0)
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  9000000000000000
#define en                   "\n"

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

    ll n, fh, fv; cin>>n;
    fh=n/500; n%=500;
    fv=n/5;
    cout<<fh*1000+fv*5<<en;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> x(n+1), y(m+1);
  cin >> x[0] >> y[0];
  rep(i, n) cin >> x[i+1];
  rep(i, m) cin >> y[i+1];

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  if (y[0] > x[n]) cout << "No War" << endl;
  else cout << "War" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

 fast();
  


  ll a,s,x,y;
  cin>>x>>y>>a>>s;
  ll q1=x/a;
  ll q2=y/a;
  ll q3=x/s;
  ll q4=y/s;
  ll q5=x/((a*s)/__gcd(a,s));
  ll q6=y/((a*s)/__gcd(a,s));
  
  if(x%a==0)
  	q1--;
  // if(x%s==0)
  // 	q3--;

  // cout<<q1<<" "<<q2<<" "<<q3<<" "<<q4<<" "<<q5<<" "<<q6<<edl;
  if(a>y&&s>y)
  	cout<<y-x+1;
  else if(a==s&&x==y&&x==a)
  	cout<<0;
   else if(a==s&&a<y)
   	cout<<y-x+1-(q2-q1); 
   else
  cout<<y-x+1-((q2-q1)+(q4-q3)-(q6-q5));




















  


    
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let calc_p n k a =
  let rec bin_search l r =
    if r < l then l
    else
      let p = (l + r) / 2 in
      if count_n (0, 0, 0, p) < n then bin_search (p + 1) r
      else bin_search l (p - 1)
  and count_n = function
    | (i, j, _, _) when i = n || j = k -> i
    | (i, j, cur_p, p) ->
      if cur_p + a.(i) <= p then count_n (i + 1, j, cur_p + a.(i), p)
      else count_n (i, j + 1, 0, p) in
  bin_search 0 (100000 * 10000)

let () =
  match read_line () |> split_on_char ' ' |> List.map int_of_string with
  | [n; k] -> Array.init n (fun _ -> read_int ()) |> calc_p n k |> Printf.printf "%d\n"
  | _ -> assert false

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

using namespace std;

const long long inf = 1e18 + 7;
const int maxn = 1e2 + 5;
const int maxv = 1e5 + 5;
bool dp[maxn][maxv];
long long sz[maxn][maxv];
int n, w, g;
pair<int, int> a[maxn];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> w;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second; // first is weight, second is value
    }
    dp[0][0] = 1;
    int total = 0;
    for(int i = 1; i <= n; i++) {
        total += a[i].second;
        for(int j = 0; j <= total; j++) {
            if(a[i].second <= j && sz[i - 1][j - a[i].second] + a[i].first <= w) {
                dp[i][j] = dp[i - 1][j - a[i].second] || dp[i - 1][j];
                if(dp[i - 1][j - a[i].second] && dp[i - 1][j]) {
                    sz[i][j] = min(sz[i - 1][j - a[i].second] + a[i].first, sz[i - 1][j]);
                } else if(dp[i - 1][j - a[i].second]) {
                    sz[i][j] = sz[i - 1][j - a[i].second] + a[i].first;
                } else if(dp[i - 1][j]) {
                    sz[i][j] = sz[i - 1][j];
                }
            } else {
                dp[i][j] = dp[i - 1][j];
                if(dp[i - 1][j]) {
                    sz[i][j] = sz[i - 1][j];
                }
            }
        }
    }
    for(int v = total; v >= 0; v--) {
        if(dp[n][v]) {
            cout << v << '\n';
            return 0;
        }
    }
} 

Measured memory_bytes: 88320
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<ext/rope>
#define int long long
using namespace std;
using namespace __gnu_cxx;
typedef long long LL;
const int MAXN = 2e6+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
signed main(){
	int n,m; cin>>n>>m;
	cout<<n*m/__gcd(n,m)<<endl;
    return 0;
}


Measured memory_bytes: 256