akhauriyash/Code-Regression huggingface dataset:
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x*y//gcd(x, y)


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    k = A[0]
    for a in A[1:]:
        k = lcm(k, a)
    k = modint(k)
    ans = modint(0)
    for a in A:
        ans += k/a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43708
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H")
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline LL Scan(){
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
///coding...................................

int a[100005];

int main()
{
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    int n,ans=0,b=0,c=0;
    cin>>n;
    FOR(i,1,n) {
        cin>>a[i];
        if(a[i]%4==0)ans++;
        else if(a[i]%2==1)b++;
        else c++;
    }
    if(ans+1==b&&c)cout<<"No"<<endl;
    else if(ans+1>=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
///delete # define FLAG......................




















Measured memory_bytes: 640
n=int(input())
s=[input() for _ in range(n)]
dic={}
for i in range(n):
  if s[i] not in dic:
    dic[s[i]]=1
  else:
    dic[s[i]]+=1
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)
for words in ans:
  print(words)


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
  }

  void reset(){
    rep(i,check.size()){
      check[i]=false;
      dist[i]=-1;
    }
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }//-----------------------

};

int main(void) {
  int n;
  cin >> n;
  Graph g(n);
  g.addedge_cin(n-1);

  g.bfs(0);
  vecll dist_f = g.dist;
  g.reset();
  g.bfs(n-1);
  vecll dist_s = g.dist;

  int fen=0, snu=0;
  //prtall(dist_f);
  //prtall(dist_s);
  rep(i,n){
    if(dist_f[i]<=dist_s[i]) fen++;
    else snu++;
  }

  prt(fen>snu ? "Fennec" : "Snuke");


}


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

typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end();
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());

int main(void){
    int X,Y,Z;
    int A,B,C;

    //標準入力
    cin >> X >> Y >> Z;


    A = Z;
    B = X;
    C = Y;

    cout << A << " " << B << " " << C << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

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


Measured memory_bytes: 3972
while True:
    n = input()

    if n == "-":
        break
    else:
        n = list(n)
        c = int(input())
        for i in range(c):
            h = int(input())
            p = []
            for j in range(h):
                p.append(n[j])
            q = "".join(p)
            del n[:h]
            n.extend(p)

        print("".join(n))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll times = (x + d - 1) / d;
	if (times <= k) {
		
		k -= times;
		if (x%d == 0) {
			if (k & 1)cout << d;
			else cout << 0;
			return;
		}
		if (k & 1) {
			cout << x%d;
		}
		else {
			cout << d - x%d;
		}
	}
	else {
		cout << x - k*d;
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nx[0];
            var x = nx[1];
            var l = Console.ReadLine().Split().Select(int.Parse).ToList();
            l.Add(0);

            var d = 0;
            var ans = 0;
            var i = 0;

            while(i <= n && d <= x)
            {
                ans++;
                d += l[i];
                i++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28184
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n = int(input())
li = list(map(int, input().split()))

count2 = []
for i in range(n):
    fact = prime_factorize(li[i])
    count = Counter(fact)
    try:
        count2.append(count[2])
    except:
        print(0)
        exit()
print(min(count2))

Measured memory_bytes: 39536
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int count = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<int> f = {1},fi = {1};
int fact(int x){
    while((int)f.size() <=x)f.push_back((f.back()*f.size())%mod);
    return f[x];
}
int ifact(int x){
    return modpow(fact(x),mod-2,mod);
}
int C(int x,int y){
    if(x < y)return 0;
    return fact(x)*ifact(y)%mod*ifact(x-y)%mod;
}
int H(int x,int y){
    return C(x+y-1,y)%mod;
}
signed main(){
    int s;cin >> s;
    int ret = 0;
    for(int n = 1; 3*n <= s;n++){
        int ss = s - 3*n;
        // trace(H(ss,n),ss,n);
        ret = (ret + H(n,ss))%mod;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] s = new int[4];
		int[] t = new int[2];
		
		t[0] = sc.nextInt();
		s[0] = sc.nextInt();
		s[3] = sc.nextInt();
		s[1] = sc.nextInt();
		s[2] = sc.nextInt();
		t[1] = sc.nextInt();
		
		int q = sc.nextInt();
		
		for(int i = 0; i < q; i++) {
			int qt = sc.nextInt();
			int qf = sc.nextInt();
			
			for(int is = 0; is < 4; is++) {
				if(s[is] == qt) {
					if(s[(is+1)%4] == qf) {
						System.out.println(t[1]);
					}else if(s[(is+3)%4] == qf) {
						System.out.println(t[0]);
					}else if(t[0] == qf) {
						System.out.println(s[(is+1)%4]);
					}else {
						System.out.println(s[(is+3)%4]);
					}
				}
			}
			
			for(int is = 0; is < 4; is++) {
				if(s[is] == qf) {
					if(t[0] == qt) {
						System.out.println(s[(is+3)%4]);
					}else if(t[1] == qt){
						System.out.println(s[(is+1)%4]);
					}
				}
			}
			
		}
	}
}


Measured memory_bytes: 26036
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string ans = "";
		if(str=="Sunny"){
			ans = "Cloudy";
		} else if(str=="Cloudy"){
			ans = "Rainy";
		} else {
			ans = "Sunny";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int k = S.size();
	int OK = 1;
	while (k) {
		if (k >= 7) {
			if (S.substr(k - 7, 7) == "dreamer") {
				k -= 7;
				continue;
			}
		}
		if (k >= 6) {
			if (S.substr(k - 6, 6) == "eraser") {
				k -= 6;
				continue;
			}
		}
		if (k >= 5) {
			if (S.substr(k - 5, 5) == "dream" || S.substr(k - 5, 5) == "erase") {
				k -= 5;
				continue;
			}
		}
		OK = 0;
		break;
	}

	if (OK) co("YES");
	else co("NO");


	Would you please return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
  int n;
  cin >> n;
  vector<int>a(n),b;
  rep(i, 0, n)cin >> a[i];
  b = a;
  sort(b.begin(),b.end());
  rep(i, 0, n){
    if(a[i]==b[n-1]){
      cout << b[n-2] << endl;
    }else{
      cout << b[n-1] << endl;
    }
  }
}

Measured memory_bytes: 4836
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 0
    cnt = 0
    m = 10**10
    for i in a:
        if i < 0:
            cnt += 1
        res += abs(i)
        m = min(m, abs(i))
    if cnt%2==1:
        print(res-m*2)
    else:
        print(res)
if __name__ == '__main__':
    main()

Measured memory_bytes: 60272
N=int(input())
S=[]
T=[]
for i in range(N):
    R=int(input())
    S.append(R)
    T.append(R)

T.sort()
T.reverse()

first=T[0]
second=T[1]

for i in range(N):
    if S[i]==T[0]:
        print(T[1])
    else:
        print(T[0])



Measured memory_bytes: 14120
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> A(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }

    map<long long, set<long long> > residual_index;
    vector<long long> sums(N + 1, 0);
    sums[0] = 0;
    residual_index.insert(make_pair(0, set<long long>()));
    residual_index[0].insert(0);
    for (long long i = 1; i < N + 1; ++i) {
        sums[i] = sums[i - 1] + A[i - 1];

        long long r = sums[i] % M;
        if (residual_index.count(r) == 0) {
            residual_index.insert(make_pair(r, set<long long>()));
        }
        residual_index[r].insert(i);
    }

    long long ans = 0;
    for (auto e : residual_index) {
        long long n = e.second.size();
        if (n >= 2) {
            ans += n * (n - 1) / 2;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15220
#include <iostream>
#include <vector>
 
using namespace std;
 
int solve( const int n ) {
 
	int sum = 0;
 
	for( int i = 0; i < n/4; i++ ) {
		int j;
		cin >> j;
		sum += j;
	}
 
	return sum;
}
 
int main( void ) {
 
	int n;
	cin >> n;
	while( n ) {
		cout << solve( n ) << endl;
		cin >> n;
	}
 
	return 0;
}

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

public class Main{
	public static String judge(double[][] n){
		boolean length = false;
		boolean width = false;		
		if( (n[2][0]-n[0][0])*(n[3][0]-n[0][0]) <= 0 || (n[2][0]-n[1][0])*(n[3][0]-n[1][0]) <= 0 ){
			width = true;
		} else if( (n[0][0]-n[2][0])*(n[1][0]-n[2][0]) <= 0 || (n[0][0]-n[3][0])*(n[1][0]-n[3][0]) <= 0 ){
			width = true;
		}
		if( (n[2][1]-n[0][1])*(n[3][1]-n[0][1]) <= 0 || (n[2][1]-n[1][1])*(n[3][1]-n[1][1]) <= 0 ){
			length = true;
		} else if( (n[0][1]-n[2][1])*(n[1][1]-n[2][1]) <= 0 || (n[0][1]-n[3][1])*(n[1][1]-n[3][1]) <= 0 ){
			length = true;
		}
		if( length && width ){
			return "YES";
		}
		return "NO";
	}
	
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<String> result = new ArrayList<String>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				double[][] n = new double[4][2];
				for(int i = 0; i < 4; i++){
					for(int j = 0; j < 2; j++){
						n[i][j] = stdIn.nextDouble();
					}
				}
				result.add(judge(n));
			}
			for(String str : result){
				System.out.println(str);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

	

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s)
    {
        if(s == "0") break;
        int a = 0, b = 0;
        for(int i = 1; i < s.size(); i++)
        {
            if(s[i] == 'A') a++;
            else b++;
        }
        if(a > b) a++;
        else b++;
        cout << a << " " << b << endl;
    }
    return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int n,w,h,s,t,x,y;
	
	while(1){
		cin>>n;
		if(n==0)break;
		cin>>w>>h;
		int f[100][100];
		for(int i=0;i<100;i++)for(int j=0;j<100;j++)f[i][j]=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			f[x-1][y-1]=1;
		}
		cin>>s>>t;
		int max=0;
		for(int i=0;i<w-s+1;i++)for(int j=0;j<h-t+1;j++){
			int tr=0;
			for(int k=0;k<s;k++)for(int l=0;l<t;l++){
			if(f[i+k][j+l]==1)tr+=1;
			}
			if(tr>max)max=tr;
		}
		cout<<max<<endl;
	}
}

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

int main() {
 string s; cin >> s;
 int n=s.size();
 int cnt=0,m;
 if(n%2==0){
    m=n/2;
   }
 else m=(n-1)/2;

 for(int i=0;i<m;i++){
   if(s[i]!=s[n-i-1])cnt++;
 }
 cout << cnt << endl;
}


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

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n, A[N], B[N], c[N];

int Ans, tot;
void Add(int x, int k) {
    for ( ; x <= tot; x += x & -x)
        c[x] = max(c[x], k);
}
int Que(int x) {
    int res = 0;
    for ( ; x > 0 ; x -= x & -x)
        res = max(res, c[x]);
    return res;
}

int main() {
    rep (i, 1, n = read<int>()) A[i] = B[i] = read<int>();

    sort(B + 1, B + n + 1);
    tot = unique(B + 1, B + n + 1) - B - 1;
    rep (i, 1, n) A[i] = lower_bound(B + 1, B + tot + 1, A[i]) - B;

    dep (i, n, 1) {
        int ans = Que(A[i]) + 1;
        Ans = max(Ans, ans);
        Add(A[i], ans);
    }

    cout << Ans << endl;
    return 0;
}



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


using namespace std;
using ll = long long;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto& x : a) cin >> x;
    sort(begin(a), end(a));
    int res = 0;
    for(int i = 0; i < k; i++) {
      res += a[i];
    }
    cout << res << "\n";



  return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,m;
pair<ll,ll> a[101010];
int main(){
	cin>>n>>m;
	fo(i,0,n){
		ll x,y;
		cin>>x>>y;
		a[i]=mp(x,y);
	}
	sort(a,a+n);
	ll ans=0,b=0;
	fo(i,0,n){
		if(b+a[i].se>=m){
			ans+=(m-b)*a[i].fi;
			break;
		}
		b+=a[i].se;
		ans+=a[i].fi*a[i].se;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <climits>


const int inf = INT_MAX / 3;
const int max_v = 16;

int d[max_v][max_v];
int dp[(1 << max_v) - 1][max_v];  // S?????¢????????£????????????????????????v??????????????´???


using namespace std;

int main() {
	int V, E;
	cin >> V >> E;

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			d[i][j] = (i == j) ? 0 : inf;

		}
	}

	for (int i = 0; i < E; i++) {
		int ts,tt , td;
		cin >> ts >> tt >> td;
		d[ts][tt] = td;
	}

	for (int s = (1 << V) - 1; s >= 0; s--) {
		for (int v = 0; v < V; v++) {
			dp[s][v] = inf;
		}
	}

	dp[(1 << V) - 1][0] = 0;

	for (int s = (1 << V) - 1; s >= 0; s--) {
		for (int v = 0; v < V; v++) {
			for (int u = 0; u < V;u++) {
				//cout << "s:" << s << " v:" << v << " u:" << u << endl;
				if (!((s >> u) & 1)) {
					dp[s][v] = min(dp[s][v], dp[s | 1 << u][u] + d[u][v]);
				//	cout << " dp:" << dp[s][v] << endl;

				}
			}
		}
	}

	if (dp[0][0] >= inf) {
		cout << -1 << endl;
	} else {
		cout << dp[0][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 5252
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int countr = 0;
        for(int i = 0; i < n; i++) {
            if(s.charAt(i) == 'R') {
                countr++;
            }
        }
        int count = 0;
        for(int i = 0; i < countr; i++) {
            if(s.charAt(i) == 'R') {
                count++;
            }
        }
        System.out.println(countr - count);
    }
}

Measured memory_bytes: 40492
#include <iostream>
#include <map>
#include <tuple>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

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

typedef tuple<int,int,int> state;
map<state,long long> dp;

long long f(int i,int n,int rest){
    //trivial
    if(0){}
    else if(n==0&&rest==0) return 1;
    else if(i>100||n<0||rest<0) return 0;

    //not trivial
    else{
        long long res;
        state s;
        s=state(i,n,rest);
        if(dp.count(s))
            return dp[s];
        else
            res=f(i+1,n-1,rest-i)+f(i+1,n,rest);
        dp[s]=res;
        return res;
    }
}

int main(){
    int n,s;
    while(1){
        cin>>n>>s;
        if(n==0&&s==0) break;
        cout<<f(0,n,s)<<endl;
    }
}

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

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);

  return 0;

}



Measured memory_bytes: 256
x = int(input())
p = 0
for i in range(120):
    for j in range(120):
        if(i**5-j**5 == x):
            print(i,j)
            p = 1
        elif(i**5+j**5 == x):
            print(i,-j)
            p = 1
    if(p == 1):
        break

Measured memory_bytes: 9188
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int H;
  int64_t W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    printf("1\n");
    return 0;
  }
  int a = (int)((W + 1) / 2);
  int64_t res = W * (int)(H / 2) + (H % 2) * a;
  printf("%lld\n", res);
}

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

string check(string s) {
	for (int i = 0; i < s.size(); i++)
		if (i % 2 == 0 && s[i] == 'L')
			return "No";
		else if (i % 2 == 1 && s[i] == 'R')
			return "No";
	return "Yes";
}

int main() {
	string s;
	cin >> s;
	cout << check(s);
}

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

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

const ll INF = 1LL << 60;

int main(){
  int n,a[100000];
  cin >> n;
  FOR(i,n){
    cin >> a[i];
  }
int ans=0;
  FOR(i,n){
    ans+=a[i];
  }
  ans-=n;
  cout << ans << endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int mm[200001];

int f(int v){
	if(v==0) return 0;
	if(mm[v]!= -1) return mm[v];
	int c=0;
	rep(i, 32) if((v>>i)&1==1) c++;
	int nv = v%c, ret;
	if(nv==0) ret=1;
	else ret=1+f(nv);

	mm[v]=ret;
	return ret;
}

int main(){
	rep(i, 200001) mm[i]= -1;
	int n;
	cin>>n;
	string x;
	cin>>x;
	reverse(x.begin(), x.end());

	int m=0;
	rep(i, n) if(x[i]=='1') m++;

	ll mp=m+1, mn=max(m-1, 1), sp=0, sn=0;
	ll kp=1, kn=1;
	rep(i, n){
		if(x[i]=='1') sp=(sp+kp)%mp;
		if(x[i]=='1') sn=(sn+kn)%mn;
		kp=(kp*2)%mp;
		kn=(kn*2)%mn;
	}

	vector<int> ans(200001);
	kp=1, kn=1;
	rep(i, n){
		if(x[i]=='0'){
			int fx=(sp+kp)%mp;
			ans[i]=1+f(fx);
		}
		if(x[i]=='1'){
			if(m-1==0) ans[i]=0;
			else{
				int fx=(sn-kn+mn)%mn;
				ans[i]=1+f(fx);
			}
		}
		kp=(kp*2)%mp;
		kn=(kn*2)%mn;
	}

	rep(i, n) cout<<ans[n-1-i]<<endl;


	return 0;
}


Measured memory_bytes: 5228
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++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(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pii a,pii b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  ll x,y;
  cin>>x>>y;
  ll ans = 0;
  ll ax=abs(x),ay=abs(y);
  if(ax<ay){
    if(x<0) ans++;
    if(y<0) ans++;
  }else if(ax>ay){
    if(x>0) ans++;
    if(y>0) ans++;
  }else{
    if(x*y<0) ans++;
  }
  cout<<abs(ax-ay)+ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
N, = (int(x) for x in input().split())

info_arr = []
for _ in range(N):
    info_arr.append(tuple(int(x) for x in input().split()))

H_mat = [[-1]*101 for _ in range(101)]

for x, y, h in [a for a in info_arr if a[2] != 0]:
    for i in range(101):
        for j in range(101):
            height = h+abs(x-i)+abs(y-j)
            if H_mat[i][j] == -1:
                H_mat[i][j] = height
                continue
            if H_mat[i][j] != height:
                H_mat[i][j] = 0

for x, y, h in [a for a in info_arr if a[2] == 0]:
    for i in range(101):
        for j in range(101):
            if H_mat[i][j] > h+abs(x-i)+abs(y-j):
                H_mat[i][j] = 0

max_h = 0
max_ij = (-1, -1)
for i in range(101):
    for j in range(101):
        if H_mat[i][j] > max_h:
            max_h = H_mat[i][j]
            max_ij = (i, j)

print(max_ij[0], max_ij[1], max_h)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> d(n);
  rep(i,n){
    cin >> d[i];
  }
  int ans = 0;

  for(int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, j, i;
    cin>>n;
    int xd[n];
    for(i=1; i<=n; i++){
        cin>>xd[i];
    }
    int ans=0;
    for(i=1; i<n; i++){
        for(j=i+1; j<=n; j++){
            ans += xd[i]*xd[j];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    ll sum = 0;
    ll max_price = 0;
    for (int i = 0; i < N; ++i) {
        ll price; cin >> price;
        max_price = max(price, max_price);
        sum += price;
    }
    sum -= max_price/2;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int num;
	scanf("%d", &num);
	char str[num+2];
	scanf("%s", &str);
	if(num % 2 != 0){
		printf("No\n");
		return 0;
	}
	for(int i =0; i<num/2; i++){
		if(str[i]!=str[(num/2)+i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	
	return 0;
}


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

int main() {
  int N;
  string result = "Three";
  string color;
  
  cin >> N;
  
  for (int i = 0; i < N; i ++){
    cin >> color;
    if (color == "Y"){
      result = "Four";
      break;
    }
  }
  
  cout << result << endl;
}


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

#define ll long long

int tc, n;

void solve(int kk)
{
    ll x;
    cin >> x;
    x == 0 ? cout << 1 << "\n" : cout << "0\n";

}

int main(){
//   #ifndef ONLINE_JUDGE
//freopen("D:\\Codings\\CPP\\input.in", "r", stdin);
//freopen("D:\\Codings\\CPP\\output.in", "w", stdout);
//#endif
	ios::sync_with_stdio(0), cin.tie(0);
	int t=1;
    //cin >> t;
    while(++tc<=t)
        solve(tc);
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<bool> A(30, true);
  for (ll i = 0; i < N; ++i) {
    ll K;
    cin >> K;
    vector<bool> temp(30, false);
    for (ll j = 0; j < K; ++j) {
      ll a;
      cin >> a;
      temp.at(a - 1) = true;
    }
    for (ll j = 0; j < 30; ++j) {
      A.at(j) = (A.at(j) & temp.at(j));
    }
  }
  ll ans = 0;
  // for (ll i = 0; i < N; ++i) {
  //   if (A.at(i)) {
  //     cout << i << endl;
  //   }
  // }
  for (ll i = 0; i < 30; ++i) {
    if (A.at(i)) {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    r,s,p = LI()
    t = S()
    dp = [[0]*3 for _ in range(k)]
    for i in range(n):
        c = t[i]
        b = -1
        cp = dp[i%k]
        np = cp[:]
        mp = max(cp)
        if c == "r":
            np[2] = max(max(cp[0], cp[1]) + p, cp[2])
            np[1] = np[0] = mp
        elif c == "s":
            np[0] = max(max(cp[2], cp[1]) + r, cp[0])
            np[1] = np[2] = mp
        else:
            np[1] = max(max(cp[2], cp[0]) + s, cp[1])
            np[2] = np[0] = mp

        dp[i%k] = np

    return sum(map(max, dp))


print(main())




Measured memory_bytes: 17740
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;

class UnionFind{
public:
  vector<ll> par; //各元の親を表す配列
  vector<ll> siz; //素集合のサイズを表す配列

  UnionFind(ll sz_): par(sz_), siz(sz_,1){
    for (int i=0; i<sz_; ++i) par[i] = i;
  }
  void init(ll sz_){
    par.resize(sz_);
    siz.assign(sz_,1);
    for (int i=0; i<sz_; ++i) par[i] = i;
  }

  // Find
  ll root(ll x){ //根の検索
    if (par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y){
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x,y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(ll x, ll y){
    return root(x) == root(y);
  }
  ll size(ll x){
    return siz[root(x)];
  }
};

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

  UnionFind uf(N);
  vector<int> f(N, 0);
  vector<int> b(N, 0);
  vector<int> can_friend(N, 0);
  for (int i = 0; i < M; ++i){
    int A, B; cin >> A >> B;
    A--; B--;
    uf.merge(A, B);
    f[A]++;
    f[B]++;
  }
  for (int i = 0; i < K; ++i){
    int C, D; cin >> C >> D;
    C--; D--;
    if (uf.issame(C, D)){
      b[C]++;
      b[D]++;
    }
  }

  for (int i = 0; i < N; ++i){
    can_friend[i] = (uf.size(i) - 1) - f[i] - b[i];
  }

  for (int i = 0; i < N; ++i){
    cout << can_friend[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3584
MOD=998244353
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

from collections import Counter
N,*D=map(int, open(0).read().split())
ans=Fp(D[0]==0 and 0 not in D[1:])
C=Counter(D)
for k, v in sorted(C.items())[1:]:
    ans*=Fp(C[k-1])**v if k-1 in C else 0
print(ans)

Measured memory_bytes: 21396
#include<bits/stdc++.h>
using namespace std;
int N;
string X,Y;
vector<int> ret;

int SI(string S){
    int len=S.size(),ans=0,t=1;
    for(int i=0;i<len;i++){
        if(S[i]=='m'){
            ans+=t*1000;
            t=1;
        }else if(S[i]=='c'){
            ans+=t*100;
            t=1;
        }else if(S[i]=='x'){
            ans+=t*10;
            t=1;
        }else if(S[i]=='i'){
            ans+=t;
            t=1;
        }else{
            t=S[i]-'0';
        }
    }
    return ans;
}

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>X>>Y;
        ret.push_back(SI(X)+SI(Y));
    }
    for(int i=0;i<N;i++){
        int x=ret[i]/1000;
        if(x==1)cout<<"m";
        else if (x!=0) cout<<x<<"m";
        ret[i]%=1000;

        x=ret[i]/100;
        if(x==1)cout<<"c";
        else if (x!=0) cout<<x<<"c";
        ret[i]%=100;

        x=ret[i]/10;
        if(x==1)cout<<"x";
        else if (x!=0) cout<<x<<"x";
        x=ret[i]%10;
        if(x==1)cout<<"i";
        else if (x!=0) cout<<x<<"i";

        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 5000 + 10;
constexpr int mod = 1000000007;
int N, A, B;
void add(int& x, int y){
    x += y;
    if(x >= mod) x -= mod;
}
int dp[maxn + 1][maxn + 1];
int sumh[maxn + 1][maxn + 1];
int shit[maxn + 1][maxn + 1];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N >> A >> B;
    if(A < B) swap(A, B);
    dp[0][0] = 1;
    for(int i = 0; i <= N; i += 1)
        for(int j = 0; j <= i; j += 1){
            add(dp[i][j], shit[i][j]);
            add(dp[i][j], sumh[i][j]);
            add(shit[i + 1][j + 1], shit[i][j]);
            add(sumh[i + 1][j], sumh[i][j]);
            {
                int ni = i + 1;
                int nj = j + 1;
                add(dp[ni][nj], dp[i][j]);
            }
            {
                int ni = i + B + 1;
                int nj = j + B + 1;
                add(shit[ni][nj], dp[i][j]);
            }
            {
                int ni1 = i + 2;
                int ni2 = i + B + 1;
                int nj = j >= A ? j : 1;
                add(sumh[ni1][nj], dp[i][j]);
                add(sumh[ni2][nj], (mod - dp[i][j]) % mod);
            }
            int ni = N;
            int nj = j >= A ? j : (N - i >= B ? j + N - i : 0);
            add(dp[ni][nj], dp[i][j]);
        }
    int ans = 0;
    for(int i = A; i <= N; i += 1) add(ans, dp[N][i]);
    cout << (LL)ans * (mod + 1) / 2 % mod << "\n";
    return 0;
}

Measured memory_bytes: 226864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> s(D, vector<int>(26));

  // 入力 (2重ループを用いる)
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  vector<int> t(D);
  for (int i = 0; i < D; i++) {
    cin >> t.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<vector<int>> dp(M, vector<int>(2));
  // 入力 (2重ループを用いる)
  for (int i = 0; i < M; i++) {
    cin >> dp.at(i).at(0);
    cin >> dp.at(i).at(1);
  }
  
  for (int k = 0; k < M; k++) {
    int man = 0;
    vector<int> last(26,0);
    vector<int> change = dp.at(k);
    int before = t.at(change.at(0)-1);
    t.at(change.at(0)-1) = change.at(1);
    for(int i=0; i<D; i++){
      int kaisai = t.at(i) - 1;
      man += s.at(i).at(kaisai);

      last.at(kaisai) = i+1;

      for(int j=0; j<26; j++){
        man -= c.at(j)*(1 + i - last.at(j));
      }
    }
    //t.at(change.at(0)-1) = before;
    cout << man << endl;
  }
  
  
  
  return 0; 
}


Measured memory_bytes: 8640
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut s = read::<String>().chars().collect::<Vec<_>>();
    if s[s.len() - 1] == 's' {
        s.push('e');
    }
    s.push('s');
    let s = s.iter().collect::<String>();
    println!("{}", s);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#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 double ld;
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> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
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 = 207;
int mo,n,lim;
int res,fac[N],ifac[N],f[N][N],qz[N];
inline void add(int &x,int y){x=(x+y)%mo;}
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1ll*res*a%mo;
		a=1ll*a*a%mo;n>>=1;
	}
	return res;
}
inline void red(int &x){x+=x>>31&mo;}
int main() {
	read(n);read(lim);read(mo);
	fac[0]=1;rep(i,1,n)fac[i]=1ll*fac[i-1]*i%mo;
	rep(i,0,n)ifac[i]=power(fac[i],mo-2);
	rep(x,0,n)rep(y,1,n-1-x)if(y<=lim-x&&n-1-x-y>=1){
		rep(i,0,y)rep(j,0,n-1-x-y)f[i][j]=0;
		f[0][0]=1;
		rep(i,1,y){
			qz[0]=f[i-1][0];
			rep(j,1,n-1-x-y)qz[j]=qz[j-1]+f[i-1][j]-mo,red(qz[j]);
			rep(j,0,n-1-x-y)if(j+y+x-i<=lim&&n+i-j-y-1<=lim){
				if(max(n-2+i-lim-y,0)<=j-1)
					f[i][j]=qz[j-1]-(max(n-2+i-lim-y,0)<0?0:qz[max(n-2+i-lim-y,0)-1]),red(f[i][j]);
				add(f[i][j],f[i-1][j]);
			}
		}
		int cur=0;rep(j,1,n-1-x-y)add(cur,f[y][j]);
		if(cur){
			res=(res+1ll*cur*fac[n]%mo*ifac[n-x]%mo*fac[n-1-x]%mo)%mo;
		//	printf("%d %d:%d %d\n",x,y,cur,1ll*cur*fac[n]%mo*ifac[n-x]%mo*fac[n-1-x]%mo);
		}
		//*ifac[n-1-x-y]%mo*fac[n-1-x-y]
	}
	if(n-1<=lim)add(res,fac[n]);//suowanle
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 3900
class queue:
    def __init__(self):
        self.q = []
    def enqueue(self, x):
        self.q.append(x)
    def dequeue(self):
        ret = self.q[0]
        del self.q[0]
        return ret
    def size(self):
        return len(self.q)

que = queue()
n, q = map(int, input().split())
q = int(q)
for i in range(n):
    name, time = map(str, input().split())
    time = int(time)
    que.enqueue([name, time])
currentTime = 0
answerL = []
while que.size():
    cur = que.dequeue()
    if cur[1] <= q:
        currentTime += cur[1]
        answerL.append(cur[0]+' '+str(currentTime))
    else:
        currentTime+=q
        que.enqueue([cur[0], cur[1]-q])
for ans in answerL:
    print(ans)


Measured memory_bytes: 13012