akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x))
#define umin(m, x) (m = min(m, x))

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define bit(x, n) ((x) >> (n) & 1)
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    int n;
    cin >> n;
    vl a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(rng(a));
    sort(rng(b));
    sort(rng(c));

    vl cb(n + 1, 0);
    rrep(i, n)
        cb[i] = cb[i + 1] + (c.end() - upper_bound(rng(c), b[i]));

    ll ans = 0;
    rep(i, n)
        ans += cb[upper_bound(rng(b), a[i]) - b.begin()];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
    
N=II()
INL=LI()

a = [0]*N
for i in range(N):
    a[0] += INL[i] if i%2 == 0 else -INL[i]

for i in range(1, N):
    a[i] = 2*INL[i-1]-a[i-1]

print(*a)


Measured memory_bytes: 64612
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = onem()

a = []
b = []
for i in range(n):
	k = onem()
	a.append(k)
	b.append(k)

a.sort(reverse = True)

for i in range(n):
	if a[0] == b[i]:
		print(a[1])
	else:
		print(a[0])


Measured memory_bytes: 14484
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef long long LL;
const int SIZE = 1000001;
const int ESIZE = 1001;
LL L;
bool isPrime[SIZE];
LL P[SIZE];
int PC;
int E[ESIZE]; 
int EC;
int res;

void makePrimes() {
    PC = 0;
    memset( P, false, sizeof(P) );
    for ( int i = 3; i < SIZE; i += 2 ) {
        isPrime[i] = true; 
    }
    P[PC++] = 2;
    for ( int i = 3; i < SIZE; i += 2 ) {
        if ( ! isPrime[i] ) continue;
        P[PC++] = i;
        for ( int j = i + i; j < SIZE; j += i ) {
            isPrime[j] = false;
        }
    }
}

void init() {
    memset( E, 0, sizeof(E) );
}

void calcExp( LL L ) {
    EC = 0;
    int i = 0;
    for ( ; i < PC && L > 1; ++ i ) {
        LL p = P[i];
        if ( L % p == 0 ) {
            while ( L > 1 && L % p == 0 ) {
                E[EC] ++;
                L /= p;
            }
            EC ++;
        }
    }
    if ( i >= PC ) {
        E[EC++] = 1;
    }
}

void dfs( int k, int r ) {
    if ( k >= EC ) {
        res += r;
        return;
    }
    for ( int i = 0; i < E[k]; ++ i ) dfs( k+1, r );
    dfs( k+1, r*(E[k]+1) );
}

int solve() {
    calcExp(L);
    res = 0;
    dfs( 0, 1 );
    return (res+1)>>1;
}

int main() {
    makePrimes();
    while ( cin >> L && L ) {
        init();
        cout << solve() << endl;
    }
    return 0;
}

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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}


int n;
bool x[22][22];
ll dp[3000000][22];

ll solve(int mask,int i){
        if(i==n){
            return 1;
        }

        ll &res=dp[mask][i];
        if(res!=-1){
            return res;
        }

        res=0;
        for(int j=0;j<n;j++){
            int cur=n-1-j;
            if(x[i][j]&&!(mask&(1<<cur))){
                res+=solve(mask+(1<<cur), i+1  )%MOD;
                res%=MOD;
            }
        }

        return res%MOD;
}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



     cin>>n;
     for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>x[i][j];
        }
     }


     mem(dp,-1);

     cout<<solve(0,0)%MOD;






     return 0;

}


Measured memory_bytes: 515840
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

ll pow(ll n){
	return n * n * n * n * n;
}

int main(){
  ll x;
  cin >> x;
  for(int i = -200; i <= 200; ++i){
  	for(int j = -200; j <= 200; ++j){
  		if(pow(i) - pow(j) == x){
  			cout << i << " " << j << endl;
  			return 0;
  		}
  	}
  }

  return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  string a, b,c;
  cin>>a>>b>>c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 12160
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


from collections import defaultdict


def main():
    n, = get_ints()
    v = get_ints()

    tot = [0, 0]
    cnt = [defaultdict(int), defaultdict(int)]

    for i in range(n):
        tot[i % 2] += 1
        cnt[i % 2][v[i]] += 1

    p = [[], []]
    for r in [0, 1]:
        p[r] = [(v, k) for k, v in cnt[r].items()] + [(0, -1 - r)]
        p[r].sort()
        p[r] = p[r][-2:]

    ans = n

    for x in p[0]:
        for y in p[1]:
            if x[1] != y[1]:
                ans = min(ans, n - x[0] - y[0])

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 66668
n = int(input())
A = list(map(int, input().split()))

value = [0]*n

for i in range(n):
  value[A[i]-1]+=1
 
sum = 0
for i in range(n):
  sum += value[i]*(value[i]-1)//2

for i in A:
  print(sum - value[i-1]+1)

Measured memory_bytes: 32320
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
		char a[6];
    scanf("%s",a);
    if(a[2]==a[3]&&a[4]==a[5]){
      printf("Yes\n");
    }
    else{
      puts("No");
    }


		return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,K;
    cin>>N>>K;
    cout<<N-K+1<<endl;
}

Measured memory_bytes: 3580
# 2019/04/08
# AtCoder Beginner Contest 103 - B

# Input
s = input()
t = input()

# Init
ans = "No"

# Trans
for i in range(len(s)+1):
    ws = s[len(s)-1] + s[0:len(s)-1]
    s = ws

    if s == t:
        ans = "Yes"
        break

# Output
print(ans)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC120B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().SplitTryParseToList<int>();
            var k = new int[line[2]];

            int i = Math.Max(line[0], line[1]);
            int j = 1;
            while (i > 0 && j <= line[2])
            {
                if (line[0] % i == 0 && line[1] % i == 0)
                {
                    k[j - 1] = i;
                    j++;
                }
                i--;
            }
            WriteLine(k[line[2] - 1]);

        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14548
program main
  implicit none

  integer :: x, y

  read(*,*) x, y

  if (mod(4*x-y,2)/=0 .or. mod(y-2*x,2)/=0 .or. y-2*x < 0 .or. 4*x-y < 0 ) then
     write(*,*) 'No'
  else
     write(*,*) 'Yes'
  end if

end program main



Measured memory_bytes: 2860
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);
using ll = long long;
using namespace std;
typedef pair<int,int> ii;
const int mod= 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int n;
    string s;
    cin >>n;
    cin >> s;
    if (n>=3200) cout << s; else cout << "red";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
	int n; cin >> n;
	vector<pair<pair<string, int>, int>> sp(n);
    rep(i, n) {
        string s; int p;
        cin >> s >> p;
        p=-p;
        sp[i].first = make_pair(s, p);
        sp[i].second = i+1;
        // sp.push_back(make_pair(make_pair(s, p), i+1));
    }
    sort(sp.begin(), sp.end());
    rep(i, n){
        cout << sp[i].second << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
L = [0] * (n + 1)
for i in range(n + 1):
    if i == 0:
        L[i] = 2
    elif i == 1:
        L[i] = 1
    else:
        L[i] = L[i - 2] + L[i - 1]

print(L[n])

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const ll MOD = 1e9 + 7;
const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};
//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll cost[1010101];
ll diff(PII x,PII y){
  ll res = 0;
  res += abs(x.first - y.first);
  res += abs(x.second - y.second);
  return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    ll d;
    cin >> h >> w >> d;
    map<int,PII> mp;
    rep(i,h)rep(j,w){
      int x;
      cin >> x;
      mp[x] = make_pair( i , j );
    }


    FOR(i,1,h*w+1){
      if(i+d <= h*w) cost[i+d] = cost[i] + diff(mp[i],mp[i+d]);
    }
    int q;
    cin >> q;
    rep(i,q){
      int x,y;
      cin >> x >> y;
      cout << cost[y] - cost[x] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 7424
#include <string>
#include <iostream>
using namespace std;
int main(){
	int x, y;
	cin >> x >> y;
	int Xgroup = 0;
	int Ygroup = 0;
	if(x == 2){
		Xgroup = 0;
	}else if(x == 4 || x == 6 || x == 9 || x == 11){
		Xgroup = 1;
	}else{
		Xgroup = 2;
	}
	if(y == 2){
		Ygroup = 0;
	}else if(y == 4 || y == 6 || y == 9 || y == 11){
		Ygroup = 1;
	}else{
		Ygroup = 2;
	}
	if(Xgroup == Ygroup){
		cout << "Yes\n" << endl;
	}else{
		cout << "No\n" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i, j, k, n = 0;
    int h, t, w, m;
    char s;
    scanf("%d", &n);
    int array[4][3][10] = {0};
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &h, &t, &w, &m);
        array[h - 1][t - 1][w - 1] += m;
    }
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 3; j++)
        {
            for (k = 0; k < 10; k++)
            {
                printf(" %d", array[i][j][k]);
            }
            printf("\n");
        }
        if (i != 3)
            printf("####################\n");
    }

    return 0;
}


Measured memory_bytes: 2752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <map>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  
  long long ans = 0;
  if (a >= k) {
    ans += k;
    cout << ans << endl;
    return 0;
  } 

  ans += a;
  k -= a;
  k -= b;
  if(k>0) {
    ans -= k;
  }
  cout << ans << endl;
  return 0; 
}

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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = (B-A+1)-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/lcm(C,D)-(A-1)/lcm(C,D));
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
     int n;
     cin>>n;
     int arr[n];
     for(int i=0;i<n;i++) cin>>arr[i];
     int ans[n];
     ans[0]=0;
     ans[1]=abs(arr[1]-arr[0]);
     for(int i=2;i<n;i++)
     {
         ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
     }
     cout<<ans[n-1];
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "<" << endl;
  }
  if (a == b) {
    cout << "=" << endl;
  }
  if (a > b) {
    cout << ">" << endl;
  }
}

Measured memory_bytes: 3556
import java.io.*;
import java.util.*;
public class Main {
	BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
	String input = null;
	ArrayList<Integer> sleepedstart = new ArrayList<Integer>(0);
	ArrayList<Integer> sleepedend = new ArrayList<Integer>(0);
	int time = 0;
	int result = 0;
	int sleeptimerest = 0;
	int sleeptime = 0;
	int awaketimerest = 0;
	int ctime = 0;
	public static void main(String []args){
		Main r = new Main();
		r.Run();
	}
	public void Run(){
		try{
			input = buff.readLine();
			String get[] = input.split(" ");
			int a = Integer.parseInt(get[0]);
			int b = Integer.parseInt(get[1]);
			int c = Integer.parseInt(get[2]);
			awaketimerest = a;
			ctime = c;
			while(true){
				time++;
				ctime--;
				if(awaketimerest > 0 && ctime == 0){//テ」ツ?淌」ツ?ゥテ」ツつ甘ァツ敖?」ツ??」ツ??
					result = time;
					break;
				}else if(ctime == 0){//テ・ツッツ敕ゥツ?偲」ツ?氾」ツ?療」ツ??= bテ」ツ?ョテ・ツ個コテゥツ鳴禿・ツ??」ツ?ォテ・ツュツ佚・ツ慊ィテ」ツ?づァツ渉セテ・ツ慊ィテ」ツ?ョテヲツョツ凝」ツつ甘ヲツ卍づゥツ鳴禿・ツ按?ゥツ?イテ」ツつ?」ツつ凝」ツ?ィテ・ツッツ敕」ツ?淌ヲツ卍づゥツ鳴禿」ツ?ョテァツオツづ」ツつ湘」ツつ甘」ツ?古・ツ按、テヲツ伉?
					if(sleepedstart.contains((time+sleeptimerest) % 60) &&
							sleepedend.contains((time-sleeptime)%60)){
						result = -1;
						break;
					}
					sleepedstart.add((time+sleeptimerest) % 60);
					sleepedend.add((time-sleeptime) % 60);
					ctime = 60;
				}
				if(awaketimerest != 0){
					awaketimerest--;
					if(awaketimerest == 0){
						sleeptimerest = b;
						sleeptime = 0;
					}
				}else if(sleeptimerest != 0){
					sleeptimerest--;
					sleeptime++;
					if(sleeptimerest == 0){
						awaketimerest = a;
					}
				}
			}
			System.out.println(result);
		}catch(Exception e){
				
		}
	}
}

Measured memory_bytes: 17060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n, m;
        static string s, t;
        static int[] xs;

        public static void Main(string[] args)
        {
            input();

            for (int i = 1; i <= 5; i++)
            {
                if (xs[i-1] == 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            xs = new int[5];
            for (int i = 0; i < 5; i++)
            {
                xs[i] = int.Parse(buf[i]);
            }
            //n = int.Parse(buf[0]);
            //m = int.Parse(buf[1]);
            //s = buf[0];
            //t = buf[1];
        }

    }
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int K = nextInt();




		System.out.println(N%K!=0?1:0);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  string a,b;
  cin >> a >> b;
  int n = stoi (a+b) ;
  forn(i,n){
    if (i*i == n){
      cout << "Yes" << endl;
      return 0 ;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>

int	main()
{
	int A,B,C;

	scanf("%d %d %d", &A,&B,&C);
	
	if((A == B) || (A == C) || (B == C))
	{
		if((A != B) || (A != C))
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int a,b;
    cin>>a>>b;
    char S[100][100];
    rep(i,50)rep(j,100) S[i][j]='#';
    rep(i,50)rep(j,100) S[i+50][j]='.';
    rep(i,20)rep(j,50) if(a>1) S[2*i][2*j]='.',a--;
    rep(i,20)rep(j,50) if(b>1) S[2*i+70][2*j]='#',b--;
    cout<<100<<" "<<100<<endl;
    rep(i,100){rep(j,100) cout<<S[i][j];cout<<endl;}
}

Measured memory_bytes: 256
N = int(input())
 
ans = [0] * 10050
 
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+i*k+j*k
            if v < 10050:
                ans[v] += 1
 
for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9160
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
//using oset = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 17 * 7 * (1 << 23) + 1;
string s;
ll ans = 0;
ll a, b, c, type[300100], rth[300100], bth[300100], gth[300100];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n >> s;
	a = b = c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R')
			rth[a++] = i;
		if (s[i] == 'G')
			gth[b++] = i;
		if (s[i] == 'B')
			bth[c++] = i;
	}
	for (int i = 0; i < n; i++) {
		type[min( { rth[i], bth[i], gth[i] })] = 1;
		type[max( { rth[i], bth[i], gth[i] })] = 2;
	}
	b = c = 0, a = n;
	ll ans = 1;
	for (int i = 0; i < s.size(); i++) {
		if (type[i] == 1) {
			ans *= a;
			ans%=mod;
			b++, a--;
		}
		if (type[i] == 0) {
			ans *= b;
			ans%=mod;
			c++, b--;
		}
		if (type[i] == 2) {
			ans *= c;
			ans%=mod;
			c--;
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 8852
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	unsigned long long f[87]={2,1},n;
	cin>>n;
	for(int i=2;i<=n;i++) f[i]=f[i-1]+f[i-2];
	cout<<f[n];
    return 0;
}

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

int main() {
  int n, a, b, ans = 0;
  scanf("%d %d %d", &n, &a, &b);

  for (int k = 1; k <= n; k++) {
    string num = to_string(k);
    int sum = 0;
    for (int l = 0; l < num.size(); l++) {
      sum += int(num[l] - '0');
    }
    if (sum >= a && sum <= b) ans += k;
  }

  printf("%d\n", ans);
  return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

VI v[100010];
VI a[100010];
int l[100010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m, c;
  cin >> n >> m >> c;
  REP(i, c) cin >> l[i];
  REP(i, n) {
    int col, w;
    cin >> col >> w;
    v[col-1].PB(w);
  }

  VI vec;
  REP(i, c) {
    sort(ALL(v[i]));
    reverse(ALL(v[i]));
    REP(j, min(l[i], (int)v[i].size())) {
      vec.PB(v[i][j]);
    }
  }

  sort(ALL(vec));
  reverse(ALL(vec));

  int ret = 0;
  REP(i, min(m, (int)vec.size())) ret += vec[i];
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 11372
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    string s;
    cin >> s;

    if(s == "ARC") cout << "ABC" << endl;
    if(s == "ABC") cout << "ARC" << endl;


    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,init;
  cin>>N;
  vector<int> x(N),y(N),h(N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]!=0)init=i;
  }
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      int height=abs(x[init]-i)+abs(y[init]-j)+h[init];
      bool flag=true;
      for(int k=0;k<N;k++){
        flag = flag && (h[k]==max(0,height-abs(x[k]-i)-abs(y[k]-j)));
      }
      if(flag)cout<<i<<" "<<j<<" "<<height<<endl;
    }
  }
}


Measured memory_bytes: 256
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
//	fast();
 	int n, B;
    cin>>n>>B;
    vector<int> dp(B+1);
    // dp[i] - the number of ways such that we allocated i beds so far.
    dp[0]=1;
    for(int states=0;states<n;states++) 
	{
        int req;
        cin>>req;
        vector<int> pref(B+1,0);
        //For each state,we consider the number of beds allocated so far(used).
        for(int used=B;used>=0;used--) 
		{
            int tmp = dp[used];
            //Each state can take minimum 0 beds and maximum req beds
            int L = used+1;//We allocate 1 bed
            int R = used+min(req,B-used);//Or we allocate the number of beds equal to req taking into account beds remaining 
            
            /*for(int i=L;i<=R;i++) 
			{
                dp[i]=(dp[i]%mod+tmp%mod)%mod;
            }*/
            if(L <= R)
			{
               	pref[L]=pref[L]%mod+tmp%mod;;
                if(R + 1 <= B)
				{
                   pref[R+1]=pref[R+1]-tmp;
                   if(pref[R+1]<0)
                   pref[R+1]+=mod;
                }
            }
            
        }
        int sum = 0;
        for(int i=0;i<=B;i++)
		{
			sum=sum%mod+pref[i]%mod;
			dp[i]=dp[i]%mod+sum%mod;
        }
        
    }
    //final answer is dp[k].
    cout<<dp[B]%mod;
}

Measured memory_bytes: 4812
N,H = map(int,input().split())

battle = 0
cleared = False

zan_max = 0
nagelist = []
for i in range(N):
    a,b = map(int,input().split())
    if a>zan_max: zan_max = a
    nagelist.append(b)
    
nagelist = sorted(list(filter(lambda x:x>zan_max,nagelist)),reverse=True)

for b in nagelist:
    battle += 1
    H -= b
    if H<=0:
        cleared = True
        break
        
if not cleared:
    if H%zan_max!=0: battle += 1
    battle += H//zan_max
    
print(battle)

Measured memory_bytes: 9052
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

S = v()
T = v()
len_s = len(S)
len_t = len(T)
check = False
ans = []

if len_s<len_t:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len_s):
    if S[i] == "?":
        cnt += 1
        if cnt >= len_t:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-len_t+1]+T+aaa[i+1:])
    elif S[i] in T:
        cnt = 0
        place = T.index(S[i])
        if len_s<len_t+i-place:
            break
        for j in range(i-place,len_t+i-place):
            if T[j-(i-place)] == S[j] or S[j] == "?":
                check = True
            else:
                check = False
                break
        if check:
            aaa = S.replace("?","a")
            ans.append(aaa[:i-place]+T+aaa[len_t+i-place:])
    else:
        cnt = 0

if len(ans)>0:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")
        


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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define floot10 cout<<fixed<<setprecision(10);
int a[4010][4010];


signed main(){
  int n;
  cin>>n;
  vector<int> xp,yp;
  vector<vector<int> > inp;
  lp(i,n){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    xp.push_back(x1);
    xp.push_back(x2);
    yp.push_back(y1);
    yp.push_back(y2);
    vector<int> hoge;
    hoge.push_back(x1);
    hoge.push_back(y1);
    hoge.push_back(x2);
    hoge.push_back(y2);
    inp.push_back(hoge);
    hoge.clear();
  }
  sort(xp.begin(),xp.end());
  sort(yp.begin(),yp.end());
  map<int,int> xm,ym;
  vector<int> xdis,ydis;
  int bef=-INF,cnt=0;
  lp(i,xp.size()){
    if(i!=0){
      if(xp[i]==xp[i-1]) continue;
    }
    xm.insert(make_pair(xp[i],cnt));
    if(bef!=-INF){
      xdis.push_back(xp[i]-bef);
    }
    bef=xp[i];
    cnt++;
  }
  bef=-INF,cnt=0;
  lp(i,yp.size()){
    if(i!=0){
      if(yp[i]==yp[i-1]) continue;
    }
    ym.insert(make_pair(yp[i],cnt));
    if(bef!=-INF){
      ydis.push_back(yp[i]-bef);
    }
    bef=yp[i];
    cnt++;
  }
  lp(i,n){
    int x1,x2,y1,y2;
    x1=xm[inp[i][0]];
    y1=ym[inp[i][1]];
    x2=xm[inp[i][2]];
    y2=ym[inp[i][3]];
    //cout<<x1<<y1<<" "<<x2<<" "<<y2<<endl;
    x2--;
    y2--;
    a[x1][y1]+=1;
    a[x2+1][y1]-=1;
    a[x1][y2+1]-=1;
    a[x2+1][y2+1]+=1;
  }
  lp(i,4002){
    lp(j,4002){
      if(j==0) continue;
      a[j][i]+=a[j-1][i];
    }
  }
  int ans=0;
  lp(i,4002){
    lp(j,4002){
      if(j==0) {
	continue;
      }
      a[i][j]+=a[i][j-1];
    }
  }/*
  lp(i,10){
    lp(j,10){
      cout<<a[i][j];
    }
    cout<<endl;
    }*/
  lp(i,4002){
    lp(j,4002){
      if(a[i][j]>0){
	ans+=xdis[i]*ydis[j];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 128948
#include<bits/stdc++.h>
using namespace std;
class matching{
  public:
  vector< vector<int> > g;
  vector<int> pa;
  vector<int> pb;
  vector<int> was;
  int n, m;
  int res;
  int iter;
  matching(int _n, int _m) : n(_n), m(_m) {
    assert(0 <= n && 0 <= m);
    pa = vector<int>(n, -1);
    pb = vector<int>(m, -1);
    was = vector<int>(n, 0);
    g.resize(n);
    res = 0;
    iter = 0;
  }
  void add(int from, int to) {
    assert(0 <= from && from < n && 0 <= to && to < m);
    g[from].push_back(to);
  }
  bool dfs(int v) {
    was[v] = iter;
    for (int u : g[v]) {
      if (pb[u] == -1) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    for (int u : g[v]) {
      if (was[pb[u]] != iter && dfs(pb[u])) {
        pa[v] = u;
        pb[u] = v;
        return true;
      }
    }
    return false;
  }
  int solve() {
    while (true) {
      iter++;
      int add = 0;
      for (int i = 0; i < n; i++) {
        if (pa[i] == -1 && dfs(i)) {
          add++;
        }
      }
      if (add == 0) {
        break;
      }
      res += add;
    }
    return res;
  }
  int run_one(int v) {
    if (pa[v] != -1) {
      return 0;
    }
    iter++;
    return (int) dfs(v);
  }
};
int n,m;
int a[101][101];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=m ;j++){
			cin >> a[i][j];
		}
	}
	for(int i=1; i<=m ;i++){
		matching g(n+1,n+1);
		for(int j=i; j<=m ;j++){
			for(int k=1; k<=n ;k++){
				g.add(k,(a[k][j]-1)/m+1);
			}
		}
		if(g.solve()!=n) return 49;
		for(int k=1; k<=n ;k++){
			for(int j=i; j<=m ;j++){
				if(g.pa[k]==(a[k][j]-1)/m+1){
					swap(a[k][i],a[k][j]);
					break;
				}
			}
		}
	}
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=m ;j++){
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}
	int t[101];
	for(int i=1; i<=m ;i++){
		for(int j=1; j<=n ;j++){
			t[j]=a[j][i];
		}
		sort(t+1,t+n+1);
		for(int j=1; j<=n ;j++){
			a[j][i]=t[j];
		}
	}
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=m ;j++){
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
#define MAX 3000
int d[MAX][MAX];
string a,b;
int dp(int l,int r){
    if(r<0||l<0)return 0;
    if(d[l][r]==-1){
       d[l][r]=(a[l]==b[r])?dp(l-1,r-1)+1:max(dp(l-1,r),dp(l,r-1));
    }
    return d[l][r];
}
string dp2(int l,int r){
    string str;
    if(l==0){
        string s="";
        str=(d[l][r])?s+a[l]:"";
    }
    else if(r==0){
        string s="";
        str=(d[l][r])?s+b[r]:"";
    }
    else str=(a[l]==b[r])?dp2(l-1,r-1)+a[l]:(d[l-1][r]>d[l][r-1])?dp2(l-1,r):dp2(l,r-1);
    return str;
}
int main(){
    cin>>a>>b; 
    memset(d,-1,sizeof(d));
    dp(a.length()-1,b.length()-1);
    cout<<dp2(a.length()-1,b.length()-1)<<endl;
    
    return 0;
}

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

typedef long long ll;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define all(obj) (obj).begin(), (obj).end()
const ll INF = 1e10;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

ll aN[3000];
// メモ[手番][左端位置][右端位置] = この局面からの結果
ll memo[2][3010][3010];
bool visited[2][3010][3010];

ll rec(int turn, int l, int r) {
	// 全部取り切ったので終了
	if (l > r) return 0;
	// 既に見た局面ならメモの内容を返す
	if (visited[turn][l][r]) return memo[turn][l][r];
	// 先手番
	if (turn == 0) {
		ll mx = -INF;
		mx = max(rec(1, l+1, r) + aN[l], rec(1, l, r-1) + aN[r]);
		// 訪問済にする
		visited[turn][l][r] = 1;
		// ここより深い所を探し終わったので結果をメモする
		return memo[turn][l][r] = mx;
	// 後手番
	} else {
		ll mn = INF;
		mn = min(rec(0, l+1, r) - aN[l], rec(0, l, r-1) - aN[r]);
		visited[turn][l][r] = 1;
		return memo[turn][l][r] = mn;
	}
}

int main() {
	int N;
	cin >> N;
	rep(i, 0, N) cin >> aN[i];
	cout << rec(0, 0, N-1) << endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
    int N, judge=1, max=0;
    cin >> N;
    vector<int> height(N);

    for (int i=0; i<N; i++) {
        cin >> height.at(i);
    }

    for(int i=0; i<N-1; i++) {
        if (max < height.at(i)) {
            max = height.at(i);
        }

        if (height.at(i) >= height.at(i+1)+2) {
            judge=0;
            break;
        } else if(height.at(i) >= height.at(i+1)+1 && max >= height.at(i+1)+2) {
            judge=0;
            break;
        }

    }

    if(judge == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
    return 0;
}


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

class Main{
    public static void main(String[] args){
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	
    	Integer[] height = new Integer[10];
    	
    	for(int i = 0; i < height.length; i++){
    		try {
				height[i] = Integer.parseInt(br.readLine());
			} catch (NumberFormatException e) {
				System.out.println("数字を入力してください");
			} catch (IOException e) {
				e.printStackTrace();
			}
    	}
    	Arrays.sort(height, Collections.reverseOrder());
    	for(int i = 0; i < 3; i++){
    		System.out.println(height[i]);
    	}
    }
}

Measured memory_bytes: 16872
// #pragma GCC optimize ("O2")
// #pragma GCC target("avx2")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793L
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// Use for file I/O;
#define FIN string _fname = "convention2"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define gsize(x) (int)((x).size())

using namespace std;

const char nl = '\n';

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
 
const ll inf = 1e9;
const ll inf2 = 1e18 + 99LL;
const ld inf3 = 1e14;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
 
const int logn = 19, maxn = 2e3+5, maxm = 1e5 + 5;

int main() {
	FAST;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({b * d, a * c, a * d, c * b});
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int inf = 0x3F3F3F3F;
const ll mod = 1e9 + 7;
const int N = 200005;

vector <ll> v;

ll calc(ll b, int n){
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ans += abs(v[i] -b);
	}
	return ans;
}

void solve(){
	ll sum = 0;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		v.pb(x - i);
	}
	sort(all(v));
	if((n)&1)cout << calc(v[n/2], n) << endl;
	else cout << calc((v[n/2-1] + v[n/2])/2, n) << endl;
}

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

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	string ans = "Left";
	if (a + b == c + d)ans = "Balanced";
	if (a + b < c + d)ans = "Right";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

ll N;

int main(){
  cin >> N;
  int x = to_string(N).length();
  for(ll i = 1; i * i <= N; i++){
    if(N % i == 0){
      ll j = N / i;
      int y = max(to_string(j).length(), to_string(i).length());
      x = min(x, y);
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	vector<int> E[610] = {}; // 出ていく辺
	int In[610] = {}; 
	for(int i = 0; i < M; i++){
		int s, t; cin >> s >> t; 
 		s--; t--; 
		E[s].push_back(t);
	}
	double dp[610] = {}; 
	for(int i = N - 2; i >= 0; i--){
		for(int j = 0; j < E[i].size(); j++){
			dp[i] += dp[E[i].at(j)]; 
		}
		dp[i] /= (double) E[i].size(); 
		dp[i] += 1.0; 
	}
	vector<pair<int, int>> kouho; 
	for(int i = 0; i < N-1; i++){
		double mx = -1; int index = -1; 
		for(int j = 0; j < E[i].size(); j++){
			if(dp[E[i].at(j)] > mx){
			index = E[i].at(j); mx = max(mx, dp[E[i].at(j)]); 
			}
		}
		kouho.push_back(make_pair(i, index)); 
	}
	double ans = dp[0]; 
	for(int i = 0; i < N-1; i++){
		fill(dp, dp + 605, 0.0); 
		for(int k = N-2; k >= 0; k--){
			int num = 0; 
			for(int j = 0; j < E[k].size(); j++){
				if(k == i && E[k].at(j) == kouho[i].second) continue; 
				dp[k] += 1.0 + dp[E[k].at(j)]; num ++; 
			}
			if(dp[k] == 0) break; 
			dp[k] /= (double) num; 
		}
		if(dp[0] == 0) continue; 
		ans = min(ans, dp[0]);
	}
	cout.precision(12); 
	cout << ans << endl; 
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second
#define PI 3.14159265359

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  double a,b,x;
  cin>>a>>b>>x;
  double num;
  double ans=90;
  x/=a;
  num=a*b;
  if(x*2 > num){
    x=num-x;
    b=(x*2)/a;
    //cout<<a<<" "<<b<<endl;
    cout<<90-atan(a/b)*(180/PI)<<endl;
  }
  else{
    a=(x*2)/b;
    // cout<<a<<" "<<b<<endl;
    cout<<90-atan(a/b)*(180/PI)<<endl;
    
  }
  

  return 0;
}


Measured memory_bytes: 256