akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

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

inline int unit(char c){
    return c == 'm'? 1000: c == 'c'? 100: c == 'x'? 10: 1;
}

int decode(string& s){
    int res = 0;
    char c = '1';
    rep(i, (int)s.size()){
        if(isdigit(s[i]))c = s[i];
        else res += (c - '0') * unit(s[i]), c = '1';
    }
    return res;
}

string encode(int n){
    string res = "", num = "mcxi";
    rep(i, 4){
        int c = n / unit(num[i]);
        if(c)res += (1 < c? to_string(c): "") + num[i];
        n %= unit(num[i]);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    while(n--){
        string s, t;
        cin >> s >> t;
        cout << encode(decode(s) + decode(t)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1216
n, m = map(int, input().split())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
    A[i].pop(0)

cnt = 0
for i in range(m):
    flag = True
    for a in A:
        if i + 1 not in a:
            flag = False
    if flag:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int meat[n], plate[n];
	int x = min(n, k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &meat[i]);
	}
	int ans = 0;
	for (int a = 0; a <= x; a++) {
		for (int b = 0; a + b <= x; b++) {
			int t = 0;
			for (int i = 0; i < a; i++) {
				plate[t++] = meat[i];
			}
			for (int i = 0; i < b; i++) {
				plate[t++] = meat[n - i - 1];
			}
			sort(plate, plate + a + b);
			int i = 0;
			while(i < k - a - b && plate[i] < 0) {
				i++;
			}
			int sum = 0;
			for ( ; i < a + b; i++) {
				sum += plate[i];
			}
			ans = max(sum, ans);
		}
	}
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,m,i=1,j,x;
	vector<int> reizo;
	vector<int> renge;
	vector<int> waribiki;
	int ans = INT_MAX;
	
	cin >> a >> b>> m;
	for (i = 1; i <= a;i++) {
		cin >> x;
		reizo.push_back(x);
	}

	for (i = 1; i <= b; i++) {
		cin >> x;
		renge.push_back(x);
	}
	for (i = 1; i <= m*3; i++) {
		cin >> x;
		waribiki.push_back(x);
	}


	//割引券適用価格
	for (i = 0; i < m*3; i = i + 3) {
		x = reizo[waribiki[i]-1] + renge[waribiki[i+1]-1] - waribiki[i + 2];
		if (ans > x)ans = x;
	}
	//全探索・・・の前にソート
	sort(reizo.begin(), reizo.end());
	sort(renge.begin(), renge.end());

	//cout << reizo[0] << renge[0] << reizo[1] << renge[2]<<endl;//ソート確認
	x = reizo[0] + renge[0];
	if (ans > x) ans = x;
	
	/*割引券なしの全探索
	for (i = 0; i < a; i++) {
		if (reizo[i] < ans) {
			for (j = 0; j < b; j++) {
				if (ans > (reizo[i] + renge[j])) ans = reizo[i] + renge[j];
			}
		}
	}
	*/
	cout << ans << "\n";
}


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,x,i,j,k,result=-1;
  int a[LIMIT1][15];
  int c[LIMIT1];
  int tes[15],tmp=1,sum=0;
  
  scanf("%lld %lld %lld",&n,&m,&x);
  rep(i,n){
    scanf("%d",&c[i]);
    rep(j,m){
      scanf("%d",&a[i][j]);
    }
  }
  
  for(i=0;i<(1<<(n));i++){
    rep(j,n) tes[j]=0;
    tmp=1;
    sum=0;
    for(j=0;j<n;j++){
      if(i & (1<<(j))){
        sum += c[j];
        rep(k,m) tes[k] += a[j][k];
      }
    }
    for(j=0;j<m;j++){
      if(tes[j]<x){
        tmp=0;
        break;
      }
    }
    if(tmp==1){
      if(result==-1) result = (ll)sum;
      result = min(result,(ll)sum);
    }
  }
  printf("%lld",result);
  return 0;
}



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

const int N = 1000;

int main() {
    int n;
    int m[N + 1][N + 1];
    int p[N+ 1];
    for (int i = 1; i <= N; i++)
        m[i][i] = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> p[i + 1];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= n - i + 1; j++) {
            int k = j + i - 1;
            m[j][k] = (1<<21);
            for (int l = j; l < k; l++) {
                m[j][k] = min(m[j][k], m[j][l] + m[l + 1][k] + p[j - 1] * p[l] * p[k]);
            }
        }
    }
    cout << m[1][n] << endl;
    return 0;
}





Measured memory_bytes: 7004
s = input()
n = len(s)
a = [0]*(n+1)
for i in range(n):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)
    if s[n-i-1] == '>':
        a[n-i-1] = max(a[n-i-1], a[n-i]+1)
print(sum(a))

Measured memory_bytes: 23368
n, m = map(int, input().split())
p = []
for i in range(m):
  r, l = map(int, input().split())
  p.append((r, l))

p.sort()
mr = 0
c = 0
for l, r in p:
  if l >= mr:
    mr = r
    c += 1
    continue
  mr = min(mr, r)

print(c)

Measured memory_bytes: 17008
def RankSum(n):
  s = str(n)
  array = list(map(int,s))
  return sum(array)
n,a,b = map(int,input().split())
count = 0
s =[]
list_a=[]
for i in range (1,n+1):
  list_a.append(i)
  s.append(RankSum(i))
for i in range(n):
  if s[i] >= a and s[i] <= b:
    count += i+1
print(count)

Measured memory_bytes: 3552
import java.util.Scanner;

/**
 * Sum of Numbers
 */
public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}

Measured memory_bytes: 18120
#include<bits/stdc++.h>
using namespace std;
struct res{
    string name;
    int score;
    int num;
}a[110];
bool cmp(const res &a,const res &b){
    if(a.name==b.name)
        return a.score>b.score;
    else
        return a.name<b.name;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].name>>a[i].score;
        a[i].num=i+1;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
        cout<<a[i].num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	int ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		int just_e = 0;
		if (i % 2 == 1)
		{
			for (int j = 1; j <= i; ++j)
			{
				if (i % j == 0)
				{
					just_e += 1;
				}
			}
		}

		if (just_e == 8)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define forn(i,a,b) for (ll i =a; i <=b; ++i)
void debug()
{
    cerr << "\n";
}
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cerr << H << " ";
    debug(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] : ";debug(__VA_ARGS__);
const ll maxn = 1e6 + 10;
void solve()
{
    ld a,b;
    cin>>a>>b;
    a*=b;
    cout<<(ll)a;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t;
    // cin >> t;
    t=1;
    rep(i, t)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3748
#IPT1_8_C　アルファベットカウント
import sys

uppers = [chr(i) for i in range(65,65+26)]
lowers = [chr(i) for i in range(97,97+26)]
alphabet = lowers + uppers
count_dict = dict(zip(lowers , [0 for i in range(len(lowers))]))

sentence = sys.stdin.read()

for s in sentence:
    for a in alphabet:
        if s == a:
            count_dict[a.lower()] += 1

for key, value in count_dict.items():
    print(key, ":", value)


Measured memory_bytes: 5580
n = int(input())

from scipy.special import comb


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(n).lower())

Measured memory_bytes: 42276
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N),B(N+1,0);
  int i;
  for(i=0;i<N;i++) {
    cin >> A[i];
    B[i+1] = (B[i] + A[i])%1000000007;
  }
  long long ans = 0;
  for(i=1;i<N;i++)ans = (ans + A[i]*B[i]%1000000007)%1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 6436
#include<iostream>
using namespace std;
int main(){
	int a=0;
	int x=0;
	int y=0;
	int i=0;
	
	for(i=0;i<4;i++){
		cin>>a;
		x+=a;
	}
	y=x/60;
	x=x%60;
	
	cout<<y<<endl<<x<<endl;
	
	return 0;
}
	
	

Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define bin(x,b) bitset<b> vb(x); cout << vb << '\n';
 
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif
 
typedef unsigned long long ll;
typedef pair <int,int> pi;
 
const long double EPS = 1e-10;
const ll MOD = 1e9 + 7;
const long double PI = 3.1415926535897932384626433832795028841;
 
ll powmod(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
 
 
const int maxn = 1e5 + 5;
const int maxm = 1e5 + 5;
const int maxk = 1e5 + 5;
 

int main(){
	string s; cin >> s;
	int n = s.size();
	int ans = n;
	for (int i = 0;i < n-1;i++){
		if (s[i] != s[i+1]) ans = min(ans , max(i+1,n-1-(i+1)+1));
	}
	cout << ans << '\n';
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const int MX = 40005;
int H,N,mx,ans,a[MX],b[MX],f[MX];

int main(){
	scanf("%d%d",&H,&N);
	for(int i=1;i<=N;++i){
		scanf("%d%d",&a[i],&b[i]);
		mx = max(mx,a[i]);
	}
	for(int i=0;i<=H+mx;++i)
		f[i] = 0x7ffffff;
	f[0] = 0;
	for(int j=1;j<=N;++j){
		for(int i=0;i<=H+mx;++i){
			if(i>=a[j])
				f[i] = min(f[i],f[i-a[j]]+b[j]);
		}
	}
	ans = 0x7ffffff;
	for(int i=H;i<=H+mx;++i)
		ans = min(ans,f[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1e9+7
using namespace std;
int main()
{
    int r;
    cin>>r;

    double peri;

    peri = 2 * 3.14*r;

    cout<<peri<<endl;

    return 0;
}


Measured memory_bytes: 3788
/**
 *    author:  Sushil Sekhar Satapathy
 *    created: 30.Jul.2020 18:38:25
 *
 *    Only the ladder is real!! The climb is all there is.
 *
**/

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N];

int solve(char C[], int n)
{
    int i, r = 0,pre = 0;
    for(i=0;i<n;i++)
    {
        if(C[i] == 'R')
            r++;
    }

    for(i=0;i<r;i++)
    {
        if(C[i] == 'R')
            pre++;
    }
    return r - pre;
}

int32_t main()
{
    //code
	IOS;
	//#ifndef ONLINE_JUDGE
    //freopen("alchemy_input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        char C[n];
        for(i=0;i<n;i++)
            cin>>C[i];
        cout<<solve(C, n)<<endl;
    }

	return 0;
}


Measured memory_bytes: 3808
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int wDay = scan.nextInt();
			int j = scan.nextInt();
			int m = scan.nextInt();
			int c = scan.nextInt();
			int d = scan.nextInt();
			int t = 0;
			if(j % c != 0){
				t = 1;
			}
			j /= c;
			j += t;
			t = 0;
			if(m % d != 0){
				t = 1;
			}
			m /= d;
			m += t;
			if(j > m){
				System.out.println(wDay-j);
			}else{
				System.out.println(wDay-m);
			}
		}
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  long long R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  auto score = [&](char c, int x) {
    if (c == 'r' && x == 2) return P;
    if (c == 's' && x == 0) return R;
    if (c == 'p' && x == 1) return S;
    return 0ll;
  };
  long long dp[K][3];
  for (int i = 0; i < K; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = score(T[i], j);
  for (int i = K; i < N; i++) {
    long long tmp[3] = {0, 0, 0};
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        if (k != j) tmp[j] = max(tmp[j], dp[i % K][k] + score(T[i], j));
    for (int j = 0; j < 3; j++) dp[i % K][j] = tmp[j];
  }
  long long ans = 0;
  for (int i = 0; i < K; i++) ans += max({dp[i][0], dp[i][1], dp[i][2]});
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5704
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/07/20 20:52:21
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int t; cin>>t;
  while (t--) {
    int n; cin>>n;
    vector<unsigned long long> A(n); for (auto& a:A) cin>>a;
    string s; cin>>s;
    vector<unsigned long long> B(64, -1ull);
    auto set_base = [&B](unsigned long long x) {
      for (int i = 0; i < 64; i++) {
        if ((x & (1ull<<i)) == 0) continue;
        if (B[i] == -1ull) {
          B[i] = x;
          return;
        }
        x ^= B[i];
      }
    };
    auto offset = [&](unsigned long long x) {
      for (int i = 0; i < 64; i++) {
        if ((x & (1ull<<i)) == 0) continue;
        if (B[i] == -1)
          return false;
        x ^= B[i];
      }
      return true;
    };
    auto solve = [&]() {
      for (int i = n-1; i >= 0; i--) {
        if (s[i] == '0') {
          set_base(A[i]);
        } else {
          if (!offset(A[i]))
            return false;
        }
      }
      return true;
    };
    cout << (solve() ? 0 : 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    FastIO;
    int N, sum;
    cin >> N;
    sum = N / 2;
    if (N % 2 != 0) sum++;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int s[5];
int main()
{
	int i;
	int a=0,b=0,c=0;
	for(i=1;i<=3;i++)
	{
		scanf("%c",&s[i]);
		if(s[i]=='a')
			a++;
		if(s[i]=='b')
			b++;
		if(s[i]=='c')
			c++;
	}
	if(a==1&&b==1&&c==1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

string kc[38]={
  "a", "b", "c", "d", "e", "f", "g",
  "h", "i", "j", "k", "l", "m", "n",
  "o", "p", "q", "r", "s", "t", "u",
  "v", "w", "x", "y", "z",
  "ld", "mb", "mp", "nc", "nd", "ng",
  "nt", "nw", "ps", "qu", "cw", "ts"
};

int main(){
  map<string, int> id;
  int n; cin >> n;
  string str;
  int ans[38][38];

  REP(i,38){
    id[kc[i]] = i;
    REP(j,38) ans[i][j] = 0;
  }

  while(cin >> str){
    vector<int> v;

    for(int i = 0; i < str.size(); ){
      if(i != str.size() - 1){
	string cand = str.substr(i, 2);
	if(id.count(cand)){
	  v.push_back(id[cand]);
	  i += 2;
	  continue;
	}
      }
      v.push_back(id[str.substr(i, 1)]);
      i++;
    }

    for(int i = 0; i < v.size() - 1; i++){
      ans[v[i]][v[i+1]]++;
    }
  }
  
  for(int i = 0; i < 38; i++){
    int cnt = 0;
    for(int j = 0; j < 38; j++){
      cnt = max(cnt, ans[i][j]);
    }

    for(int j = 0; j < 38; j++){
      if(ans[i][j] == cnt){
	printf("%s %s %d\n", kc[i].c_str(), kc[j].c_str(), cnt);
	break;
      }
    }
  }

  return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

void Main() {
  string s;
  cin >> s;
  const int N = SZ(s);

  vi a(N);
  vi o(N);

  vi ra(N+1);
  vi ro(N+1);

  rep(c, 26) {
    int t = 'a' + c;

    rep(i, 1, N) {
      if (s[i-1] == t && s[i+1] == t) {
        _p("%d %d\n", i-1+1, i+1+1);
        return;
      }
      else if (s[i-1] == t && s[i] == t) {
        _p("%d %d\n", i-1+1, i+1);
        return;
      }
    }
  }
  puts("-1 -1");
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 2000
#include<stdio.h>

int kouyaku(int,int);

int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  printf("%d\n",kouyaku(x,y));
  return 0;
}

int kouyaku(int x,int y){
  int e,a;
  if(x<y){
    a = x;
    x = y;
    y = a;
  }
  while(y>0){
    e = x % y;
    x = y;
    y = e;
  }
  return x;
}



Measured memory_bytes: 2144
n, k = map(int, input().split())

# 前処理の追加
n %= k

min_ = n

def r(min_, k):
  if min_ > abs(min_ - k):
    min_ = abs(min_ - k)
    return r(min_, k)
  else:
    return min_

print(r(min_, k))


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

int A[100][100] = {};
int b[100] = {};
int c[100] = {};

int main() {
    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i=0; i<m; ++i) {
        cin >> b[i];
    }
    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            c[i] += A[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007

ll fact[100005];
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll komb(ll a, ll b){
	if(a < b) return 0;
	if(a == b) return 1;
	return (fact[a] * ((exp(fact[a-b], mod - 2) * exp(fact[b], mod - 2))%mod)) % mod;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	vector<ll> vec(n);
	fact[0] = 1;
	for(ll i = 1; i < 100005; i++){
		fact[i] = (i * fact[i-1]) % mod;
	}
	for(int i = 0; i < n; i++){
		cin>>vec[i];
	}
	sort(vec.begin(), vec.end());
	vector<ll> eksiler(n), artilar(n);
	ll temp = n-1;
	for(int i = 0; i < n; i++){
		eksiler[i] = komb(temp, k-1);
		artilar[i] = komb(n-1-temp, k-1);
		//cout<<eksiler[i]<<artilar[i]<<endl;
		temp--;
	}
	ll sum = 0;
	for(int i = 0; i < n; i++){
		sum = (sum + (vec[i]+mod)*(((artilar[i] - eksiler[i] + mod))%mod)) % mod;
		//cout<<vec[i];
	}
	cout<<sum;
	return 0;
}


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

void input_vector(vector<string>& v) {
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
}

int find_all(const std::string str, const std::string subStr) {
    int count = 0;
    int subStrSize = subStr.size();
    int pos = str.find(subStr);

    while (pos != std::string::npos) {
        count++;
        pos = str.find(subStr, pos + subStrSize);
    }

    return count;
}

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

    vector<string> v;
    for (int i = 0; i < n; ++i) {
        input_vector(v);
    }

    string target = "AB";
    vector<int> nums_ab;
    nums_ab.reserve(n);

    for (int j = 0; j < n; ++j) {
        nums_ab.push_back(find_all(v.at(j), target));
    }

    int cnt_end_a = 0;
    int cnt_top_b = 0;
    int both = 0;
    bool is_b = false;

    for (int j = 0; j < n; ++j) {
        if (v.at(j).at(0) == 'B') {
            cnt_top_b++;
            is_b = true;
        }
        if (v.at(j).at(v.at(j).size()-1) == 'A') {
            cnt_end_a++;
            if (is_b) {
                cnt_top_b--;
                cnt_end_a--;
                both++;
            }
        }

        is_b = false;
    }

    int ans = 0;

    for (int k = 0; k < n; ++k) {
        ans += nums_ab.at(k);
    }

    if (both == 0) {
        ans += min(cnt_end_a, cnt_top_b);
    } else {
        if (cnt_end_a == 0 && cnt_top_b == 0) {
            ans += both-1;
        } else {
            ans += both+min(cnt_end_a, cnt_top_b);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdlib.h>
using namespace std;
 
int main(){
  int n;
  vector<double> x;
  vector<double> y;
  double tmp;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    x.push_back(tmp);
  }
   
  for (int i = 0; i < n; i++){
    cin >> tmp;
    y.push_back(tmp);
  }
 
  // p = 1
  double p1 = 0.0;
  for (int i = 0; i < n; i++){
    p1 += fabs(x[i] - y[i]);
  }
   
  // p = 2
  double p2 = 0.0;
  for (int i = 0; i < n; i++){
    p2 += pow(x[i] - y[i], 2);
  }
  p2 = pow(p2, 0.5);
 
  // p = 3
  double p3 = 0.0;
  for (int i = 0; i < n; i++){
    p3 += pow(fabs(x[i] - y[i]), 3);
  }
  p3 = cbrt(p3);
 
  // p = mugen
  double p4 = -100000;
  for (int i = 0; i < n; i++){
    if (fabs(x[i] - y[i]) > p4){
      p4 = fabs(x[i] - y[i]);
    }
  }
 
  cout << fixed;
  cout << setprecision(9) << p1 << endl;
  cout << setprecision(9) << p2 << endl;
  cout << setprecision(9) << p3 << endl;
  cout << setprecision(9) << p4 << endl;
}


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

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Measured memory_bytes: 53636
#include <iostream>

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;

	if ( C > A && C < B )
	{
		std::cout << "Yes" << std::endl;
	}
	else if ( C < A && C > B )
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 888
a,b,c,x,y = gets.chomp!.split(" ").map(&:to_i)
cost = Array.new

hash={x => a, y => b }
price = [a, b]
hm = [x, y]

if c * 2 > a + b
  cost[0] = a * x + b * y
else
  cost[0] = 2*c*hm.min + hash[hm.max]*(hm.max-hm.min)
  cost[1] = 2*c*hm.max
end

p cost.min

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int big(int x, int y) {
    if(x > y)
        return x;
    else
        return y;
}
int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x[n];
    int y[n];
    int x_1;
    int x_2;
    int y_1;
    int y_2;
    int counter = 0;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i < n - 1; i++) {
        int x_1 = x[i];
        int y_1 = y[i];
        int x_2 = x[i + 1];
        int y_2 = y[i + 1];
        if((x_1 >= x_2 && y_1 <= y_2) || (x_1 <= x_2 && y_1 >= y_2)) {
            counter += abs(x_1 - x_2) + abs(y_1 - y_2);
        } else {
            counter += big(abs(x_1 - x_2), abs(y_1 - y_2));
        }
    }
    cout << counter << endl;
    return 0;
}


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

int main(){
  int n,r,t,p[100];
  cin>>n>>r>>t;
  for(int i=0;i<n;i++)cin>>p[i];
  int cnt[1000]={},ans=0,pos[100]={};
  for(int i=0;i<t;i++){
    int dc[1000]={};
    for(int j=0;j<n;j++){
      int npos=(pos[j]+p[j])%r;
      if(cnt[npos])cnt[npos]--;
      else ans++;
      pos[j]=npos;
      dc[npos]++;
    }
    if(i)for(int j=0;j<r;j++)cnt[j]+=dc[j];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cstring>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main()
{
	fastio;
	int k;
	cin >> k;
	char s[101];
	cin >> s;
	int len = strlen(s);
	if ( len <= k )
	cout << s;
	else
	{
		for ( int i=0; i<k; i++ )
		cout << s[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

bool solve() {
    string S; cin >> S;
    rep(i, 0, S.size()) {
        if(i % 2 && S[i] == 'R') return false;
        if(i % 2 == 0 && S[i] == 'L') return false;
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 100000;

ll X, Y, A, B, C, ans=0, tmp=0;
vector<ll> AS(MAXN, 0), BS(MAXN, 0), CS(MAXN, 0);

signed main(){
    cin >> X >> Y >> A >> B >> C;
    for(int i=0;i<A;i++) cin >> AS[i];
    for(int i=0;i<B;i++) cin >> BS[i];
    for(int i=0;i<C;i++) cin >> CS[i];
    sort(AS.begin(), AS.end());
    sort(BS.begin(), BS.end());
    sort(CS.begin(), CS.end());
    ll i=0;
    ll j=0;
    ll k=0;
    AS[MAXN-X-1] = -1;
    BS[MAXN-Y-1] = -1;
    while(i+j+k!=X+Y) {
        if(AS[MAXN-1-i]>=BS[MAXN-1-j]) {
            if(AS[MAXN-1-i]>=CS[MAXN-1-k]){
                //cout << "OK A" << AS[MAXN-1-i] << endl;
                ans += AS[MAXN-1-i];
                i++;
            }
            else {
                //cout << "OK C1" << endl;
                ans += CS[MAXN-1-k];
                k++;
            }
        }
        else {
            if(BS[MAXN-1-j]>=CS[MAXN-1-k]) {
                //cout << "OK B" << endl;
                ans += BS[MAXN-1-j];
                j++;
            }
            else {
                //cout << "OK C1" << endl;
                ans += CS[MAXN-1-k];
                k++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
n, k = map(int, input().split())
d = list(map(int, input().split()))
while True:
  n = str(n)
  flg = True
  for k in range(len(n)):
    if int(n[k]) in d:
      flg = False
      break
  if flg:
    ans = int(n)
    break
  n = int(n)
  n += 1
print(ans)

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

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

  int max=1;
  int ans;
  rep(i,x){
    ans=1;
    rep(j,x){
      if(j<1)continue;
      ans*=(i+1);
      if(ans>x)break;
      else if(ans>max && j>1)max=ans;
    }
  }

  cout << max << endl;  
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int n[3] = {A, B, C};
  sort(n, n + 3);
  if (n[0] == 5 && n[1] == 5 && n[2] == 7){
    cout << "YES" << endl;
  } else cout << "NO" << endl;
}
        
  

Measured memory_bytes: 256
#include<stdio.h>

int minmin(int a,int b,int c,int d);

int main(void)
{
        int n,m,i,j,min,tmp,jj;
        int a[50],b[50],c[50],d[50];

        scanf("%d%d",&n,&m);

        for(i=0;i<n;i++)
                scanf("%d%d",&a[i],&b[i]);
        for(i=0;i<m;i++)
                scanf("%d%d",&c[i],&d[i]);


        for(i=0;i<n;i++){
                tmp = minmin(a[i],b[i],c[0],d[0]);
                jj = 1;
                for(j=1;j<m;j++){
                        min = minmin(a[i],b[i],c[j],d[j]);
                        if(tmp>min){
                                tmp = min;
                                jj = j+1;
                        }
                }
                printf("%d\n",jj);
        }

        return 0;
}
int minmin(int a,int b,int c,int d)
{
        int min;
        if(c>a)
                min = c - a;
        else
                min =a-c;
        if(d>b)
                min +=d-b;
        else
                min +=b-d;

        return min;
}


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

#define pb push_back
#define mp make_pair
#define INF 1e16+1
#define se second
#define fi first

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pll> vpll;
typedef vector< vector<pll> > vvpll;

ll i,j,n,m,x,a,b,w,k;
vll dp,v;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	k=2;
	for(i=0;i<n;i++){
		cin>>a;
		v.pb(a);
	}
	dp.assign(n,INF);
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=1;j<=k&&i+j<n;j++){
			dp[j+i] = min(dp[j+i] , dp[i]+abs(v[i]-v[i+j]));
		}
	}
	cout<<dp[n-1]<<'\n';
}


Measured memory_bytes: 1908
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <stack>
#include <deque>
using namespace std;

int main(){
    string s;
    cin >> s;
    string t = "";
    for(int i =0; i < 10; i++){
        t += "hi";
        if(s == t){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 256
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    R, G, B, N = mi()
    cnt = 0

    for r in range(N//R+1):
        for g in range(N//G+1):
            bB = (N-R*r-G*g)
            if bB%B==0 and 0 <= bB:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int n = s.length();
		
		char lr[] = new char[n];
		
		lr[0] = 'R';
		for (int i = 1 ; i <n-1 ; i ++) {
			
			lr[i] = s.charAt(i);
		}
		
		lr[n-1] = 'L';
		
		int ch[] = new int [n];
		for(int i = 0 ; i < n ; i ++) {
			ch[i] = 0;
		}
		
		/*左から、Lが出現する場所を探す。
		 * その場所の左に、Rがいくつあるか数える。
		 * その場所から右に、次のRが出現するまでに、Lがいくつ続くか数える。
		 * Rの出た場所から、、、、一行目に戻る。
		 * 
		 */
		int i  = 0;
		
		while (i < n-1) {
			
		
		int count_R = 0;
		int count_L = 0 ;
		while(lr[i] == 'R') {
			
			i ++;
			count_R ++;
		}
		
		while(lr[i] == 'L' && i <n-1) {
		
			i++;
			count_L++;
		}
		
		if (i == n-1) {
			count_L ++;
			i++;
		}
		int type_A = count_R/2 + (count_L+1)/2;
		int type_B = count_R + count_L - type_A;
		
		ch[i-count_L] += type_A;
		ch[i-count_L-1] += type_B;
		
		}
		
		for ( int pp = 0 ; pp <n ; pp ++) {
			
			System.out.print(ch[pp]+" ");
		}
	}
}


Measured memory_bytes: 45248
s = input().replace("RL","R,L").replace("LR","L,R").split(",")
s = s[::-1]
h = list()


while s:
    a = len(s.pop())
    b = len(s.pop())
    h.append((a,b))

t = []
for x,y in h:
    t += [0]*(x-1) + [(x+1)//2+y//2,x//2+(y+1)//2] + [0]*(y-1)
    
print(" ".join(map(str,t)))

Measured memory_bytes: 13884
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#define residue(s,t) (capacity[s][t]-flow[s][t])
int main(){
  int N, M;
  while(cin>>N>>M && N){
    int capacity[300][300] = {};
    int flow[300][300] = {};
    int X[1000], Y[1000];
    REP(i, M){
      cin>>X[i]>>Y[i];
      X[i]--; Y[i]--;
      capacity[X[i]][Y[i]]++;
      capacity[Y[i]][X[i]]++;
    }
    int S, T;
    cin>>S>>T;
    S--; T--;
    int total = 0;
    while(true){
      queue<int> que;
      int prev[300]; memset(prev, -1, sizeof(prev));
      que.push(S); prev[S] = S;
      while(!que.empty() && prev[T] < 0){
        int u = que.front(); que.pop();
        REP(v, N) if(prev[v] < 0 && residue(u, v) > 0){
          prev[v] = u;
          que.push(v);
        }
      }
      if(prev[T] < 0) break;
      int inc = M;
      for(int u = T; prev[u] != u; u = prev[u]){
        inc = min(inc, residue(prev[u], u));
      }
      for(int u = T; prev[u] != u; u = prev[u]){
        flow[prev[u]][u] += inc;
        flow[u][prev[u]] -= inc;
      }
      total += inc;
    }
    vector<int> rev_road;
    REP(i, M){
      if(flow[X[i]][Y[i]] > 0){
        flow[X[i]][Y[i]]--;
      }else if(flow[Y[i]][X[i]] > 0){
        flow[Y[i]][X[i]]--;
        rev_road.push_back(i + 1);
      }
    }
    cout<<total<<endl;
    cout<<rev_road.size()<<endl;
    REP(i, rev_road.size()) cout<<rev_road[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1936
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    final int i0 = scanner.nextInt();
    final int i1 = scanner.nextInt();
    final int i2 = scanner.nextInt();

    if (Math.min(i0, Math.min(i1, i2)) == 5 &&
        Math.max(i0, Math.max(i1, i2)) == 7 &&
        i0 + i1 + i2 == 17) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21460
#include <iostream>
 using namespace std;
 int main()
 {
     int pair[2];
     pair[0] = 1001;
     int n, T;
     int x, y;
     cin >> n >> T;
     for(int i = 0; i < n; i++)
     {
         cin >> x >> y;
         if(y <= T && x <= pair[0]){
             pair[0] = x;
             pair[1] = y;
         }
     }
     if(pair[0] != 1001)
     {
         cout << pair[0];
     } else {
         cout << "TLE";
     }
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int counter = 0, K;
string s;
string search (string a) {
  char b;
  string sub, val;
  int flag;
  for(int j = 0; j < 26; j++) {
    flag = 0;
    b = 'a' + j;
    sub = a + b;
    for(int i = 0; i < s.size() - sub.size() + 1; i++){
      if(s.substr(i, sub.size()) == sub){
        counter++;
        if(counter == K)return sub;
        flag = 1;
        break;
      }
    }
    if(flag == 1){
      val = search(sub);
      if(val != "0") return val;
    }
  }
  return "0";
}
int main () {
  cin >> s >> K;
  cout << search("") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;

  int sum;
  if(n%2==0) sum = 1+n;
  else sum = n;
  vector<int> g[n];
  rep(i,n){
    rep(j,n){
      if((i+1)+(j+1)!=sum && i > j) g[i].pb(j);      
    }
  }
  vector<pair<int,int>> ans;
  rep(i,n){
    for(auto j:g[i]){
      ans.pb(make_pair(i+1,j+1));
    }
  }
  cout << ans.size() << endl;
  rep(i,ans.size()){
    int a = ans[i].first;
    int b = ans[i].second;
    cout << a << " " << b << endl;
  }

  
  return 0;
    

}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main 
{	
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) 
	{
		int m;
		int nmin;
		int nmax;
		
		while(true)
		{
			m = scan.nextInt();
			nmin = scan.nextInt();
			nmax = scan.nextInt();
			
			if(m == 0 && nmin == 0 && nmax == 0)
			{
				return;
			}
			else
			{
				new DataSet(m, nmin, nmax);
			}
		}

	}
	
	static class DataSet
	{
		int jukensha;
		int nmin;
		int nmax;
		List<Integer> score = new ArrayList<Integer>();
		
		public DataSet(int jukensha, int nmin, int nmax)
		{
			this.jukensha = jukensha;
			this.nmin = nmin;
			this.nmax = nmax;
			
			int largestGap = -1;
			int ans = -1;
			
			for(int i = 0; i < jukensha; i++)
			{
				score.add(scan.nextInt());
				//find biggest gap.
				
				if(i <= nmax && i > 0 && i >= nmin)
				{
					int gapWithPrev = score.get(i-1) - score.get(i);
//					System.out.println("hey " + i + " gap " + gapWithPrev);
					if(gapWithPrev >= largestGap)
					{
						largestGap = gapWithPrev;
						ans = i;
					}
				}
			}
			
			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 57504
n,m = gets.split.map(&:to_i)
b = Array.new(n+2,true)
m.times do
    a = gets.to_i
    b[a] = false
end
dp = Array.new(n+2,0)
mod = 10**9+7
dp[0] = 1
n.times do |i|
    if b[i+1]
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    end
    if b[i+2]
        dp[i+2] += dp[i]
        dp[i+2] %=  mod
    end
end
# p dp
puts dp[n]

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int m,d;
int ans=0;
int main()
{
    cin>>m>>d;
    for(int i=2;i<=m;i++)
    {
        for(int j=11;j<=d;j++)
        {
            int a= j/10;
            int b= j%10;

            if((a>=2&& b>=2)&& a * b == i)
            {
                ans++;
              //  cout<<a<<" "<<b<<endl;
            }

        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>
#include<string>

#define MAX 101

void init();
int isEmpty();
int isFull();
void push(int);
int pop();

int S[MAX];
int top = 0;

int main(){
    int x;
    char s[100];
    
    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            push(pop() + pop());
        } else if ( s[0] == '-' ){
            //push(-1*pop() + pop());
            x = -1*pop();
            x += pop();
            push(x);
        } else if ( s[0] == '*' ){
            push(pop()*pop());
        } else {
            x = atoi(s);
            push(x);
        }
        
#ifdef D
        for (int i = 1; i <= top; i++) {
            printf("%d ", S[i]);
        }
        printf("\n");
#endif
    }
    
    printf("%d\n",S[1]);
    
    return 0;
}

void init(){
    top = 0;
}

int isEmpty(){
    return top == 0 ? 1 : 0;
}

int isFull(){
    return top >= MAX-1 ? 1 : 0;
}

void push(int x){
    if (isFull()) {
        printf("Stack is Full\n");
    }else{
        top++;
        S[top] = x;
    }
}

int pop(){
    if (isEmpty()) {
        printf("Stack is Empty\n");
        exit(1);
    }else{
        top--;
        return S[top+1];
    }
}























Measured memory_bytes: 2748
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<int> l_gcd(n);
  vector<int> r_gcd(n);
  l_gcd[0] = a[0];
  r_gcd[n-1] = a[n-1];
  for(int i=1; i<n-1; i++){
    l_gcd[i] = __gcd(l_gcd[i-1],a[i]);
    r_gcd[n-1-i] = __gcd(r_gcd[n-i],a[n-1-i]);
  }

  int max = r_gcd[1];
  for(int i=1; i<n-1; i++){
    int temp = __gcd(l_gcd[i-1],r_gcd[i+1]);
    if(temp > max){
      max = temp;
    }
  }
  if(l_gcd[n-2] > max){
    max = l_gcd[n-2];
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A = rd_int();
  wt_L(A + A*A + A*A*A);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   int A = rd_int();
//   wt(A + A*A + A*A*A);
// }


Measured memory_bytes: 3592
#include<cstdio>
using namespace std;
typedef long long ll;
main(){
  ll n;
  while(~scanf("%lld",&n)){
    ll sum=0;
    for(int i=0;i<n;i++){
      ll m;
      scanf("%lld",&m);
      sum+=m;
    }
    printf("%lld\n",sum/n);
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string str;
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = sy; i < ty; ++i) {
		str.push_back('U');
	}
	for (int i = sx; i < tx; ++i) {
		str.push_back('R');
	}
	for (int i = sy; i < ty; ++i) {
		str.push_back('D');
	}
	for (int i = sx; i < tx; ++i) {
		str.push_back('L');
	}
	str.push_back('L');
	for (int i = sy; i < ty + 1; ++i) {
		str.push_back('U');
	}
	for (int i = sx - 1; i < tx; ++i) {
		str.push_back('R');
	}
	str.push_back('D');
	str.push_back('R');
	for (int i = sy; i < ty + 1; ++i) {
		str.push_back('D');
	}
	for (int i = sx - 1; i < tx; ++i) {
		str.push_back('L');
	}
	str.push_back('U');
	cout << str << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char in[10];
int main(){
  rd(in);
  if(in[0]=='9' || in[1]=='9'){
    wt_L("Yes");
    putchar_unlocked('\n');
  }
  else{
    wt_L("No");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20170908-1 [beta]

// --- original code ---
// char in[10];
// {
//   rd(in);
//   if(in[0]=='9' || in[1]=='9') wt("Yes"); else wt("No");
// }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
//		int t = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int min = a[0];
		int max = a[0];
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		for (int i = 1; i < n; i++) {
			if (a[i] < min) {
				min = a[i];
				max = a[i];
			} else if (a[i] > max) {
				max = a[i];
				putCntMap(map, max - min);
			}
		}
		System.out.println(map.lastEntry().getValue());
	}

	static void putCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 43000
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int x;
		int n = 0;
		int data[] = new int[10000];
		
		do {
			x = stdIn.nextInt();
			
			if( x == 0)break;
			
			data[n] = x;
			
			n++;
			
		}while(x >= 1 && x <= 10000);
		
		for(int i = 0; i < n; i++) {
			System.out.println("Case " + (i + 1) + ": " + data[i] );
		}
		
	}
}


Measured memory_bytes: 42652
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>

#pragma warning(disable:4996)

#
int main(void) {
	int a, p;
	scanf("%d %d", &a, &p);
	printf("%d", (a * 3 + p) / 2);

	return 0;
}

Measured memory_bytes: 128