akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
from itertools import combinations
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    d=defaultdict(int)
    for _ in range(N):
        S=input()
        if S[0]=='M' or S[0]=='M' or S[0]=='A' or S[0]=='R' or S[0]=='C' or S[0]=='H':
            d[S[0]]+=1
    ans=0
    for t in combinations(d.keys(),3):
        ans+=d[t[0]]*d[t[1]]*d[t[2]]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41708
#include<stdio.h>
int main()
{
	int i,b=0,c=0;
	char s[5];
	scanf("%s",s);
	for(i=0;i<3;i++)
	{
		if(s[i]=='R')c++;
		else 
		c=0;
		b=c>b?c:b;
	}
	printf("%d\n",b);
}

Measured memory_bytes: 1728
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>



#define ll long long


/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;

int bin_search(int ele, vector<pair<int,int> > arr)
{
    int l = 0, r = arr.size()-1 , mid=0;
    while (l <= r) {
        mid = l + (r - l) / 2;
        if (arr[mid].first == ele) {
            return arr[mid].second;
        }
        else if (arr[mid].first > ele) {
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    return mid;
}

int main()
{
    int grid[3][3];
    int i, j;
    for (i = 0; i < 3; ++i) {
        for (j = 0; j < 3; ++j) {
            cin >> grid[i][j];
        }
    }

    int n,ele; 
    cin >> n;
    for (i = 0; i < n; ++i) {
        cin >> ele;
        for (int nig = 0; nig < 3; ++nig) {
            for (j = 0; j < 3; ++j) {
                if (ele == grid[nig][j]) {
                    grid[nig][j] = 0;
                }
            }
        }
    }

    for (i = 0; i < 3; ++i) {
        if (grid[i][0] == grid[i][1] && grid[i][1] == grid[i][2]) {
            cout << "Yes";
            return 0;
        }
    }
    for (i = 0; i < 3; ++i) {
        if (grid[0][i] == grid[1][i] && grid[1][i] == grid[2][i]) {
            cout << "Yes";
            return 0;
        }
    }

    if (grid[0][0] == grid[1][1] && grid[1][1] == grid[2][2]) {
        cout << "Yes";
        return 0;
    }
    if (grid[0][2] == grid[1][1] && grid[1][1] == grid[2][0]) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int a = sc.nextInt();
		final int b = sc.nextInt();
		final int c = sc.nextInt();
		
		final int cycle = (a + b);
		boolean[] visited = new boolean[cycle];
		
		
		for(long sum_time = c; ; sum_time += 60){
			final int mod_time = (int)(sum_time % cycle);
			if(visited[mod_time]){
				System.out.println(-1);
				break;
			}
			
			visited[mod_time] = true;
			if(mod_time <= a){
				System.out.println(sum_time);
				break;
			}
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
 
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
    
    pair<int,int> p[1000000];

       cin >> n;
      rep(i,n){
          cin >> a >> b;
          p[i]=make_pair(a,b);
      }
       sort(p,p+n);
       ans+=p[n-1].second;
      // Cout(ans);
       if(p[0].first!=1){
           ans+=p[0].first-1;
       }
      // Cout(ans);
       rep(i,n-1){
           if(p[i+1].first-p[i].first<=p[i].second-p[i+1].second){
               ans+=p[i+1].first-p[i].first-1;
           }
           else{
               ans+=p[i].second-p[i+1].second-1;
           }
       }
       Cout(ans+n);
return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,a[n+1],dp[n+1];
    
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++) dp[i]=1e9;
    dp[1]=0;
    for(i=1;i<=n;i++)
    {
        if(i-1>=1) dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i-2>=1) dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
    return 0;
}

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

using namespace std;


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    qsort(d,N,sizeof(int),compare_int);

    cout << d[N/2] - d[N/2-1] <<endl;

    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double pi = acos(-1);
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
double A, B;
int H, M;

void solve()
{
    cin >> A >> B >> H >> M;
    double theta2 = M / 60.0 * 360.0;
    double theta1 = H / 12.0 * 360.0 + 0.5 * M;
    double delta = fabs((theta1 - theta2) / 360.0 * 2 * pi);
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(delta));
    printf("%.12lf\n", ans);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 4204
n = int(input())
x = 0
a = 0
b = 0
flag = True
for _ in range(n):
    s = input()
    if s[0] == 'B':
        b += 1
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B' and s[-1] == 'A':
        pass
    elif s[0] == 'B' or s[-1] == 'A':
        flag = False
    for i in range(len(s)-1):
        if s[i:i+2] == 'AB':
            x += 1
if a == 0 or b == 0:
    print(x)
elif a == b and flag:
    print(x + a - 1)
else:
    print(x + min(a,b))

Measured memory_bytes: 46040
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <numeric>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(p.begin(), p.end(), greater<int>());
    LL ans = p[0] / 2 + accumulate(p.begin() + 1, p.end(), 0,
                               [](int acc, int i) {
                                   return acc + i;
                                       });
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x,-1,sizeof(x))
using namespace std;


int main()
{
    long long i,j,k,n,ans,tc,ca=1,x,a,b;
    map<string,int>ma,ma2;
    string s[5000],ss[5000];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        ma[s[i]]++;
    }
    cin>>k;
    for(i=0;i<k;i++)
    {
        cin>>ss[i];
        ma2[ss[i]]++;
    }
    ans=0;
    for(i=0;i<n;i++)
    {
        x=ma[s[i]];
        x-=ma2[s[i]];
        ans=max(ans,x);
    }
    cout<<ans<<endl;


    return 0;

}


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

typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.find('a') != string::npos &&
        s.find('b') != string::npos &&
        s.find('c') != string::npos) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

int main(void)
{
	int H, W;
	std::cin >> H >> W;

	std::vector< std::vector<char> > a;
	
	std::vector<int> H_del;
	std::vector<int> W_del;
	
	a.resize(H);
	for (auto &it : a) {
		it.resize(W);
		for (auto &iit : it) {
			std::cin >> iit;
		}
	}

	for (int i = 0; i < a.size(); ++i) {
		int sum_w = 0;
		for (int j = 0; j < a.front().size(); ++j) {
			if (a[i][j] == '.') ++sum_w;
		}
		if (sum_w == W)
			H_del.push_back(i);
	}

	for (int i = 0; i < a.front().size(); ++i) {
		int sum_h = 0;
		for (int j = 0; j < a.size(); ++j) {
			if (a[j][i] == '.') ++sum_h;
		}
		if (sum_h == H)
			W_del.push_back(i);
	}

	for (auto it = H_del.rbegin(); it != H_del.rend(); ++it) {
		a.erase(a.begin() + (*it));
	}

	for (auto it = W_del.rbegin(); it != W_del.rend(); ++it) {
		for (auto &a_it : a) {
			a_it.erase(a_it.begin() + (*it));
		}
	}


	for (auto it : a) {
		for (auto iit : it) {
			std::cout << iit;
		}std::cout << std::endl;
	}

	return 0;

}

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

#define int long long

template <class T> inline bool amin(T &a, T const &b){if(a > b) {a = b; return 1;} return 0;}

const int INF = 1001001001;

signed main(){

    int n; cin >> n;
    int k; cin >> k;
    vector<int> a(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
    
    vector<int> dp(n+1, INF);

    dp[0] = 0;

    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            amin(dp[i+j], dp[i] + abs(a[i] - a[i+j]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  set<int> s;
  REP(i, n) {
    int a;
    cin >> a;
    a /= 400;
    if (a < 8) s.insert(a);
    else ans++;
  }

  cout << max(SZ(s), 1ll) << " " << SZ(s) + ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
import numpy as np

def a():
  n, p = list(map(int, input().split()))
  num = [int(s) for s in input()]
  
  if(p==2 or p==5):
    count=0
    for i in range(1,n+1):
      if(num[-i]%p == 0):
        count += n-i+1
    print(count)
    return
  
  counts = np.zeros(p)
  tmp = 0
  tens = 1
  for i in range(1,n+1):
    tmp = (tens*num[-i] + tmp) % p
    counts[tmp] += 1
    tens = (tens*10)%p
  ret = int(counts[0] + sum(counts*(counts-1)//2))
  print(ret)
  return
a()

Measured memory_bytes: 14560
def solve(x):
    cnt = 1
    while x > 0:
        x %= bin(x).count('1')
        cnt += 1
    return cnt

n = int(input())
x = input()
one = x.count('1')
num = int(x, 2)

up = num%(one+1)
if one == 1:down = 0
else:down = num%(one-1)

for i in range(n):
    if x[i] == '1':
        if one == 1:
            print(0)
            continue
        s = (down - pow(2, n-i-1, one-1))%(one-1)
    else:
        s = (up + pow(2, n-i-1, one+1))%(one+1)
    print(solve(s))

Measured memory_bytes: 83132
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


int cnt[100010];
void solve() {
	int N; cin >> N;
	FOR(x, 1, 101) {
		FOR(y, 1, 101) {
			FOR(z, 1, 101) {
				int res = x * x + y * y + z * z + x * y + y * z + z * x;
				if (res <= 10000)cnt[res]++;
			}
		}
	}
	FOR(i, 1, N + 1)print(cnt[i]);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 3700
//	????????????????????????????????°???????????????????????\?????????????????????

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		/*	?¨??????\???????????????????????????????????????	*/
		Scanner sc = new Scanner(System.in);
		
		/*	 ????£???¨?¨??£??????¬??°?????\??????*/
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		/*	????£??????°????????????	*/
		int[] values = new int[w];
		for(int i = 0; i< values.length; i++){
			values[i] = i + 1;
		}
		
		/*	?¨??£??????????	*/
		for(int i=0; i<n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			/*????£????????????????????????????????????????(?????????)???*/
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) -1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
			
		}
		for(int i=0; i<values.length; i++){
			System.out.println(values[i]);
		}
	}

}

Measured memory_bytes: 25992
#include <stdio.h>
#include <string.h>

int main(){
    int N=0;
    if(scanf("%d", &N)==1){ 
    }
    char ans[10010];
    scanf("%s", &ans);
    
    int n = strlen(ans);

    for(int i=0; i<n; i++){
        ans[i]+=N;
        if(ans[i]>'Z'){
            ans[i]=ans[i]-'Z'+'A'-1;
        }
        printf("%c", ans[i]);
    }

    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

const char* mcxi = "mcxi";

int mcxi_to_int(const char* str)
{
    int i, res = 0, t = 1;

    for(i = 0; str[i]; i++)
        if(strchr(mcxi, str[i]))
        {
            switch(str[i])
            {
              case 'm': res += t * 1000; break;
              case 'c': res += t * 100; break;
              case 'x': res += t * 10; break;
              default: res += t;
            }
            t = 1;
        }
        else
            t = str[i] - '0';

    return res;
}

void print_mcxi(int n)
{
    int i;
    char buf[4];

    for(i = 3; i >= 0; i--, n /= 10)
        buf[i] = n % 10;

    for(i = 0; i < 4; i++)
        if(!buf[i])
            continue;
        else if(buf[i] == 1)
            putchar(mcxi[i]);
        else
            printf("%d%c", buf[i], mcxi[i]);

    puts("");
}

int main(void)
{
    char buf[9];
    int a, b;

    scanf("%*d%*c");

    while(~scanf("%s%*c", buf))
    {
        a = mcxi_to_int(buf);
        scanf("%s%*c", buf);
        b = mcxi_to_int(buf);
        print_mcxi(a + b);
    }

    return 0;
}

Measured memory_bytes: 620
n, k = io.read("*n", "*n")
minpos = 1
min = io.read("*n")
for i = 2, n do
  local a = io.read("*n")
  if(a < min) then min, minpos = a, i end
end
-- find min(s) where minpos - (k-1) * s <= 1
s = math.ceil((minpos - 1) / (k - 1))
minpos = 1 + s * (k - 1)
-- find min(t) where n <= minpos + (k-1) * t
t = math.ceil((n - minpos) / (k - 1))
print(s + t)


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

int main(){
  int n;
  cin >>n;
  
  if(n%2!=0){
  cout<< (n+1.0)/2.0/n<<endl;
  }
  else{
    cout<< 0.5<<endl;
  }

  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,k,count=0;
	cin >> N;
    for (int i = 1; i <= N;i+=2){
        k=0;
        for (int j = 1; j <= i; j++){
            if (i%j==0){
                k++;
            }
        }
        if (k==8){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
xy=[[] for _ in range(n+1)]
for _ in range(m):
    x,y,z=map(int,input().split())
    xy[x].append(y)
    xy[y].append(x)

from collections import deque

visited=[0]*(n+1)
count=0

for i in range(1,n+1):
    if visited[i]==0:
        stack=deque()
        stack.append(i)
        visited[i]+=1
        while stack:
            a=stack.pop()
            for j in xy[a]:
                if visited[j]==0:
                    visited[j]+=1
                    stack.append(j)
        count+=1
print(count)

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

int main()
{
  ll n, k;
  cin >> n >> k;
  if(n % k == 0) cout << 0 << endl;
  else{
    ll ans = n;
    while(ans > abs(ans - k)){
      if(ans > k) ans %= k;
      else ans = k % ans;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {

    ll mod_num = 1000000000+7;

    ll n; cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    vector<ll> sabun(n-1);
    rep(i, n-1) {
        sabun[i] = x[i+1]-x[i];
    }

    ll kaijo = 1;
    for(ll i=1; i < n; i++) {
        kaijo *= i % mod_num;
        kaijo %= mod_num;
    }

    ll ans = 0;
    ll kaijo_tmp = kaijo;
    rep(i, n-1) {
        ll tmp = kaijo_tmp * sabun[i] % mod_num;
        ans += tmp;
        ans %= mod_num;
        kaijo_tmp += (kaijo*modinv(i+2, mod_num)) % mod_num;
        kaijo_tmp %= mod_num;
    }

    cout << ans%mod_num << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

h,w,d = map(int,input().split())
ahw = [0]*(h*w)
dp = [0]*(h*w)
for i in range(h):
  temp = [int(i)-1 for i in input().split()]
  for j in range(w):
    ahw[temp[j]] = (i,j)
for i in range(d):
  dp[i] = 0
for i in range(d,h*w):
  dp[i] = dp[i-d] + abs(ahw[i][0]-ahw[i-d][0]) + abs(ahw[i][1]-ahw[i-d][1])

q = int(input())
for i in range(q):
  l,r = map(int,input().split())
  print(dp[r-1]-dp[l-1])

Measured memory_bytes: 14516
from collections import *
n, k = map(int, input().split())
d, t = zip(*sorted(tuple(map(int, input().split()))[::-1] for _ in range(n))[::-1])
c = Counter(t[:k])
x = len(c)
a = [sum(d[:k])]
for i in range(k)[::-1]:
    if c[t[i]] > 1:
        c[t[i]] -= 1
        a.append(a[-1] - d[i])
b = [0]
for i in range(k, n):
    if c[t[i]] <= 0:
        c[t[i]] += 1
        b.append(b[-1] + d[i])
r = 0
for i, (v, w) in enumerate(zip(a, b)):
    r = max(r, v+w+(x+i)**2)
print(r)

Measured memory_bytes: 29244
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > 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;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
ll K;
vl lunlun;

void dfs(ll d,ll res,ll add,vl &vec){
    vec.push_back(res);
    d++;
if(d==10) return;
if(add!=0) dfs(d,res*10+add-1,add-1,vec);
if(add!=9) dfs(d,res*10+add+1,add+1,vec);
dfs(d,res*10+add,add,vec);
}

int main() {
    cin>>K;
    rep(i,9){
        dfs(0,i+1,i+1,lunlun);
    }
    sort(all(lunlun));
    cout<<lunlun.at(K-1)<<endl;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    long long n;
    long long result=0;
    cin >> n;
    vector<long long> b(n-1);
    for(int i=0; i < n-1; i++) cin >> b[i];
    
    for(int i=0; i < n; i++) {
        if(i == 0) {
            result += b[0];
        }else if(i == n-1){
            result += b[i-1];

        } else{
            result += min(b[i], b[i-1]);
            
        }
        
    }
    cout << result << endl;

}

Measured memory_bytes: 256
while tmp = gets
  m,f,r = tmp.chomp.split.map(&:to_i)
  t = m + f
  break if t == -2 && f == -1
  if 80 <= t
    puts "A"
  elsif 65 <= t && t < 80
    puts "B"
  elsif (50 <= t && t < 65) || 50 <= r  && ( -1 < m && -1 < f )
    puts "C"
  elsif (30 <= t && t < 50) && ( -1 < m && -1 < f )
    puts "D"
  elsif
    puts "F"
  end
end


Measured memory_bytes: 6872
// 2020-07-25 05:46:11
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 998244353;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

const int MX = 3030;
int a[MX];
mint dp[MX], p[MX];
void answer() {
  int n, s;
  cin >> n >> s;
  rep(i, n) cin >> a[i];
  dp[0] = 1;
  rep(i, n) {
    swap(p, dp);
    repc(j, s) {
      dp[j] = p[j] * 2;
      if(a[i] <= j) dp[j] += p[j-a[i]];
    }
  }
  cout << dp[s] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<map>
#include<cassert>
#include<utility>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<deque>
#include<fstream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<functional>
#include<stack>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++)
	if(a[i]==i)
	{
		ans++;
		swap(a[i],a[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String str1 = sc.next();
		String str2 = sc.next();
		String str3 = sc.next();
		
		String result = str1.substring(0,1) + str2.substring(0,1) + str3.substring(0,1);
		
		System.out.println(result);
	}
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
int main(){
    bool q=0;
    string s1,s2;
    cin >> s1 >> s2;
    if (s1.length()>s2.length()){
        printf("GREATER");
    } else if(s1.length()<s2.length()){
        printf("LESS");
    }else{
        for (int i = 0; i <s1.length() ; ++i) {
            int x=(int)s1[i];
            int y=(int)s2[i];
           if (x>y){
               printf("GREATER");
               exit(0);
           }
           else if(x<y){
               printf("LESS");
               exit(0);
           }else if(x==y){
               q=1;
           }
        }
             if(q==1)
            printf("EQUAL");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool func(vector<int>&);
int main() {
	int N;
	cin >> N;
	vector<int> line(N);
	for (int i = 0; i < N; ++i) {
		cin >> line[i];
	}
	vector<int> line2;
	line2 = line;
	reverse(line2.begin(), line2.end());
	cout << (func(line) && func(line2) ? "yes" : "no") << endl;
	return 0;
}

bool func(vector<int>&line) {
	int fp = 1;
	int power = line.front();
	while (fp < line.size()) {
		if (power < 10)return false;
		power -= 10;
		power = max(power, line[fp++]);
	}
	return true;
}

Measured memory_bytes: 5252
#include<stdio.h>
 
int main(){
	int a;
	while(scanf("%d", &a) != EOF){
		if(a % 39 == 0) printf("3C%d\n", 39);
		else if(a % 39 < 10) printf("3C0%d\n", a % 39);
		else printf("3C%d\n", a % 39);
	}
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	lmax := 1
	rmin := n
	for i := 0; i < m; i++ {
		sc.Scan()
		l, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ := strconv.Atoi(sc.Text())

		lmax = max(lmax, l)
		rmin = min(rmin, r)
	}
	ans := max(rmin-lmax+1, 0)
	fmt.Println(ans)
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] c = new int[N];
        int[] t = new int[N];
        for(int i = 0; i < N; i++){
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }
        int ans = 1001;
        for(int i = 0; i < N; i++){
            if(t[i] <= T){
                ans = Math.min(ans, c[i]);
            }
        }
        if(ans == 1001){
            System.out.println("TLE");
        }else{
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23124
n=int(input())
h=list(map(int,input().split()))

ans=[]
sum=0


for i in range(1,n):
  if h[i]<=h[i-1]:
    sum=sum+1
    ans.append(sum)
  else:
    sum=0
  
if len(ans)==0:
  print(0)
else:
  print(max(ans))


    
  

Measured memory_bytes: 14252
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    query.append((s,p,i+1))
  query.sort()
  count = 0
  while count<n/2:
    count += 1
    for i in range(n):
      for j in range(i+1,n):
        if query[i][0] == query[j][0]:
          if int(query[i][1]) <int(query[j][1]):
            buf = query[i]
            query[i] = query[j]
            query[j] = buf
            
    
  for i in range(n):
    print(query[i][2])
solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#define NILL 2000000010
using namespace std;

struct tree{
	int key;
	tree *r,*l,*p;
};

tree *root,*NIL;

void insert(int k){
	tree *x=root,*y=NULL,*z;
	z = (tree *)malloc(sizeof(tree));
	z->key = k;
	z->l=NULL,z->r=NULL;
	while( x != NULL ){
		y = x;
		if(z->key < x->key ){
			x = x->l;
		} else {
			x = x->r;
		}
	}
	z->p = y;
	if( y == NULL ){
		root = z;
	} else {
		if( z->key > y->key ){
			y->r = z;
			z->p = y;
		} else {
			y->l = z;
			z->p = y;
		}
	}
}

void inorder(tree *u){
	if( u == NULL ) return;
	inorder(u->l);
	printf(" %d",u->key);
	inorder(u->r);
}

void preorder(tree *u){
	if( u == NULL ) return;
	printf(" %d",u->key);
	preorder(u->l);
	preorder(u->r);
}

int main(){
	int i,n,j,x;
	string com;
	cin >> n;
	root = NULL;
	while(n--){
		cin >> com;
		if( com == "insert" ){
			cin >> x;
			insert(x);
		}else if( com == "print" ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
}


Measured memory_bytes: 26728
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int X = sc.nextInt();
        int L[] = new int[N];
        for(int i=0; i<N; i++) {
            L[i] = sc.nextInt();
        }
        int D[] = new int[N+1];
        D[0] = 0;

        for(int i=1; i<N+1; i++){
            D[i] = D[i-1] + L[i-1];
        }
        int ans=0;
        for(int i=0; i<N+1; i++) {
            if(D[i] <= X) ans++;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
int absi(int a,int b){
  return max(a-b,b-a);
}

int main(){
  int N,Z,W;
  cin>>N>>Z>>W;
  int a[N];
  REP(i,N)cin>>a[i];
  int ans=0;
  ans=max(ans,absi(a[N-1],W));
  if(N>1)ans=max(ans,absi(a[N-2],a[N-1]));
  cout<<ans<<endl;
  return 0;
}


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


int solve(vector<int> arr)
{
    int N = arr.size();
    bool flag = false, a0 = true;
    for(int i=0; i<N; ++i)
    {
        if(arr[i] == 1) flag = true;
        if(arr[i] != 0) a0 = false;
    }
    if(a0) return 0;
    if(!flag)
    {
        for(int i=0; i<N; ++i) arr[i] /= 2;
        return 2*solve(arr);
    }
    int ans = 0;
    for(int i=0; i<=N-1; ++i)
        if( ((N-1)&i) == i ) ans ^= arr[i]&1;
    return ans;
}

int main()
{
    int N; scanf("%d", &N);
    vector<int> arr;
    for(int i=0; i<N; ++i)
    {
        int t;
        scanf("%1d", &t);
        arr.push_back(t-1);
    }
    printf("%d\n", solve(arr));
}

Measured memory_bytes: 12268
n,d=map(int,input().split())
x=[]
for i in range(n):
    X=list(map(int,input().split()))
    x.append(X)
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        t=0
        for l in range(d):
            t+=(x[i][l]-x[j][l])**2
        if t==int(t**(1/2))**2:
            ans+=1
print(ans)

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

int main()
{
    int s,n,x1=3,x2,r[4]={0},i=3;
    cin>>s;
    n=4;
    for(i=0;i<n;i++)
    {
        r[x1]=s%10;
        s=s/10;
        x1--;
    }
    x2=r[2]*10+r[3];
    x1=r[0]*10+r[1];
    if(x1==0 && x2==0)
    {
        cout<<"NA";
    }
    else if(x1>0 && x1<=12 && x2>0 && x2 <=12)
    {
        cout<<"AMBIGUOUS";
    }
    else if(x2>0 && x2<=12 && x1>12)
    {
        cout<<"YYMM";
    }
    else if(x1>0 && x1<=12 && x2>12)
    {
        cout<<"MMYY";
    }
    else if(x1==0 && x2<=12)
    {
        cout<<"YYMM";
    }
    else if(x2==0 && x1<=12)
    {
        cout<<"MMYY";
    }
    else
        cout<<"NA";
    return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    ll a[n][m];
    ll b[m][l];
    ll c[n][l];
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    rep(i, m) {
        rep(j, l) {
            cin >> b[i][j];
        }
    }
    rep(i, n) {
        rep(j, l) {
            c[i][j] = 0;
        } 
    }
    rep(i, n) {
        rep(j, l) {
            rep(k, m) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    rep(i, n) {
        rep(j, l) {
            if (j == l-1) cout << c[i][j] << endl;
            else cout << c[i][j] << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 3360
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
print("Sunny" if s=="Rainy" else "Cloudy" if s=="Sunny" else "Rainy")

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

char s[200010];

int main () {
        cin >> s;
        int len = strlen (s);
        if (s[0] != s[len - 1]) {
                if (len % 2 == 0)       cout << "Second" << endl;
                else    cout << "First" << endl;
        } else {
                if (len % 2 == 0)       cout << "First" << endl;
                else    cout << "Second" << endl;
        }
        return 0;
}


Measured memory_bytes: 384
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    /////////////////////
    // Write code below /
    /////////////////////

    int numberOf1YenCoin;
    int amountOfPayment;
    cin  >> amountOfPayment >> numberOf1YenCoin;
    
    int remainingAmountOfPayment = amountOfPayment % 500;
    if (numberOf1YenCoin >= remainingAmountOfPayment) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = parseInt(input.trim());
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  //var output = 0;
  if(input[0] + input[1] >= input[2]){
     myout(input[1] + input[2]);
  }else{
    myout(input[0] + input[1] * 2 + 1);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  if (k % 2 == 0) {
    long long r0 = n / k;
    long long rh = (n + k / 2) / k;
    cout << r0 * r0 * r0 + rh * rh * rh << endl;
  } else {
    cout << (n / k) * (n / k) * (n / k) << endl;
  }
  return 0;
}


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

S=input()
LEN=len(S)
END='EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE'
S += END

R=S.count('R')
G=S.count('G')
B=S.count('B')


cnt=0
for j in range(1, int((LEN-1)/2)+1):
    for i in range(LEN-j*2):
        if S[i+j+j]=='E':
            break
        if (S[i] != S[i+j]) and (S[i+j] != S[i+j+j]) and (S[i] != S[i+j+j]):
            cnt+=1

print(R*G*B-cnt)

Measured memory_bytes: 73760
#include <bits/stdc++.h>
#define LL long long int
#define Max(x, y) (x > y ? x : y)
#define Min(x, y) (x < y ? x : y)
#define Abs(x) ( (x) > 0 ? (x) : -(x) )
#define Swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0)
#define IO_BOOST                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0)
#define setp(x) fixed << setprecision(x)
#define INF 0x3f3f3f3f
#define Lowbit(x) ((x) & (-x))
#define Pii pair<int, int>
#define x first
#define y second
#define MOD ((int)1e9+7)
using namespace std;
 
int a[(int)2e5+5], n, k;
void solve(){
    int dp[(int)2e5+5] = {0};
    for(int i = 2 ; i <= n ; i++){
        dp[i] = INF;
        for(int j = Max(i-k, 1) ; j < i ; j++){
            dp[i] = Min( dp[i], dp[j] + Abs( a[i]-a[j] ) );
        }
    }
    cout << dp[n] << '\n';
}
int main(){
    IO_BOOST;
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i];
    solve();

}

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

int uf[100001], p[100001];
int n,m,x,y;

void init(){
    for(int i = 1; i <= n; i++)  uf[i] = i;
}

int root(int x){
    if(uf[x] == x){
        return x;
    }else{
        return uf[x] = root(uf[x]);
    }
}

bool same(int x, int y){
    return root(x) == root(y);
}

void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    uf[x] = y;
}

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> p[i];
    init();
    for(int i = 1; i <= m; i++){
        cin >> x >> y;
        unite(x,y);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(same(i, p[i]))   ans++;
    }

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

Measured memory_bytes: 1024
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

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

using namespace std;

int main()
{
    list<int>ls;
    list<int>:: iterator it = ls.begin();
    
    int n,a,b;
    cin >> n;
    while(n>0 ){
        cin >> a  ;
        if( a == 0){
            cin >> b;
          it =   ls.insert(it,b);
        }
        else if( a  == 1){
            cin >> b;
            if( b > 0){
                 
                for(int i = 0 ; i < b; i++){
                    it++;
                }
                 
            }
            else {
                     for(int i = 0 ; i < abs(b); i++){
                    it--;
                     
                }
                
            }
            
        }
        
        else {
                   it =   ls.erase(it);
                     
        }
        
        n--;
         
    }
    
    for(list<int>:: iterator it = ls.begin() ; it != ls.end(); it++){
             
             cout << *it << "\n";
         }

    return 0;
}



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

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

ll patan(ll _i, ll _j) {
	ll num = (_i + _j) * (_j - _i + 1) / 2;

	return num;
}

int main() {
	mint ans = 0;
	int n, k;
	cin >> n >> k;

	for (int i = k; i <= n + 1; i++) {
		ll min, max;
		min = patan(0, i - 1); max = patan(n - i + 1 ,n);
		ans += max - min + 1;
	}

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


Measured memory_bytes: 3664