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

int Partition(int *,int,int);

main(){
  int n,i,x;
  scanf("%d",&n);
  int A[n];
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  x = Partition(A,0,n-1);

  for(i=0 ; i<n ; i++){
    if(i!=0) printf(" ");
    if(x==i) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");

  return 0;
}

int Partition(int *A,int p,int r){
  int i,j,temp,x;
  x = A[r];
  i = p-1;
  for(j=p ; j<r ; j++){
    if(A[j] <= x){
      i = i+1;
      temp = A[j];
      A[j] = A[i];
      A[i] = temp;
    }
  }
  temp = A[r];
  A[r] = A[i+1];
  A[i+1] = temp;

  return i+1;
}

Measured memory_bytes: 992
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////




int main() {
	string s[2];
	repi(i, 0, 2) rd(s[i]);
	ll AL = s[0].length(), BL = s[1].length();
	if (AL > BL) wrln("GREATER");
	else if (AL < BL) wrln("LESS");
	else {
		repi(i, 0, AL) {
			if (s[0][i] > s[1][i]) {
				wrln("GREATER");
				break;
			}
			else if (s[0][i] < s[1][i]) {
				wrln("LESS");
				break;
			}
			else if (i == AL - 1) wrln("EQUAL");
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

    static int n;
    static int m;
    static int ans;
    static int[] w;
    static int[] ww;
    static boolean[] visit;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        m = sc.nextInt();
        w = new int[m];
        ww = new int[m];
        
        for (int i = 0; i < m; i++) {
            int tmp = sc.nextInt();
            int tmpp = sc.nextInt();
            w[i] = tmp-1;
            ww[i] = tmpp-1;
        }

        visit  = new boolean[n];
        Arrays.fill(visit, false);
        dfs(0);
        System.out.println(ans);
        sc.close();
    }

    public static void dfs(int placenow) {
        visit[placenow] = true;
        boolean success = true;
        for (int i = 0; i < n; i++) {
            if (visit[i] == false) { // not go all place
                success = false;
                break;
            }
        }
        if (success) {
            ans++;
            visit[placenow] = false;
            return;
        }

        for (int i = 0; i < m; i++) {
            if (w[i] == placenow && visit[ww[i]] == false ) {
                dfs(ww[i]);
            }else if(ww[i] == placenow && visit[w[i]] == false){
                dfs(w[i]);
            }else{
                continue;
            }
        }
        visit[placenow] = false;
        return;
    }

}



Measured memory_bytes: 22540
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    cnt = 0
    digit = 1 << i
    for j in a:
        if digit & j:
            cnt += 1
    ans += digit*cnt*(n - cnt)%mod

print(ans%mod)


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

int main() {
    int64_t n, num;
    cin >> n;

    num = pow(10, 13);
    for (int64_t i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            int64_t m = n / i;

            if (num > (i - 1) + (m - 1)){
                num = (i - 1) + (m - 1);
            }

        }
    }

   
    cout << num << endl;
}

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

void solve(long long A, long long B)
{
    cout << A * B << endl;
}

signed main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    ll W,H,x,y;
    cin >> W >>H >>x >>y;
    double area = double(W)*H / 2;
    cout  << fixed << setprecision(10) << area << endl;
    if(2*x == W && 2*y == H) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int D, G;
int p[11];
int c[11];
int sum = 0, cnt = 0, dp[11][1200], ans = 1 << 30;


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

    for(int i = 1; i <= D; i++){
        cin >> p[i] >> c[i];
        sum += p[i];
    }

    for(int i = 1; i <= D; i++){
        for(int j = 0; j <= sum; j++){
            if(dp[i][j] >= G) ans = min(ans, j);
            if(j != 0 && dp[i - 1][j] == 0) continue;
            for(int k = 0; k <= p[i]; k++){
                int pls = (100 * i * k) + (k == p[i] ? c[i] : 0);
                dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + pls);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;

int main() {

	int a, b, h, m;
	cin >> a >> b >> h >> m;

	double h_deg, m_deg;
	h_deg = (double)(h * 60.0 + m) / 2.0;
	m_deg = (double)m * 6.0;
	
	double deg = abs(h_deg - m_deg);
	deg = deg > 180 ? 360 - deg : deg;

	double rad = deg * (3.14159265358979323846 / 180.0);

	cout<<fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(rad)) << endl;

	return 0;
}

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

using namespace std;

const int H = 1000 + 7;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  string s;
  int n, k;
  cin >> n >> k;
  cin >> s;
  if('A' <= s[k - 1] && s[k - 1] <= 'Z') s[k - 1] += 'a' - 'A';
  cout << s << endl;
  return 0;
}
/*
 && ((i > 0 && s[i - 1][j] == '#') || (i < h - 1 && s[i + 1][j] == '#') || (j > 0 && s[i][j - 1] == '#') || (j < w - 1 && s[i][j + 1] == '#'))
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main(){
    int n,k;
    cin >> n >> k;
    int d[k];
    int A;
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> A;
            a[A]++;
        } 
    }
    int ans=0;
    for(int i=1;i<n+1;i++)if(a[i]==0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int x = tx - sx, y = ty - sy;

  for (int i = 0; i < x; i++)
  {
    cout << 'R';
  }
  for (int i = 0; i < y; i++)
  {
    cout << 'U';
  }
  for (int i = 0; i < x; i++)
  {
    cout << 'L';
  }
  for (int i = 0; i < y; i++)
  {
    cout << 'D';
  }
  
  x++; y++;
  cout << 'D';
  for (int i = 0; i < x; i++)
  {
    cout << 'R';
  }
  for (int i = 0; i < y; i++)
  {
    cout << 'U';
  }
  cout << 'L';
  cout << 'U';
  for (int i = 0; i < x; i++)
  {
    cout << 'L';
  }
  for (int i = 0; i < y; i++)
  {
    cout << 'D';
  }
  cout << 'R';

  cout << endl;
}

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , a[ N ] , b[ N ] , c[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
  for( int i = 0 ; i < n ; i ++ )
    b[ i ] = getint();
  for( int i = 0 ; i < n ; i ++ )
    c[ i ] = getint();
  sort( a , a + n );
  sort( b , b + n );
  sort( c , c + n );
}
LL d[ N ];
void solve(){
  int iter = 0;
  for( int i = 0 ; i < n ; i ++ ){
    while( iter < n and a[ iter ] < b[ i ] ) iter ++;
    d[ i ] = iter;
    if( i ) d[ i ] += d[ i - 1 ];
  }
  LL ans = 0; iter = 0;
  for( int i = 0 ; i < n ; i ++ ){
    while( iter < n and b[ iter ] < c[ i ] ) iter ++;
    if( iter )
      ans += d[ iter - 1 ];
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
map<string, int> points;
map<int, vector<string> > out;
char str[10000];

int main() {
  while (scanf("%d", &n), n) {
    points.clear();
    out.clear();
    REP(i, n) {
      int m;
      scanf("%s %d", str, &m);
      points[str] = 0;
      REP(i, m) {
        int t;
        scanf("%d", &t);
        if (!out.count(t)) { out[t] = vector<string>(); }
        out[t].push_back(str);
      }
    }
    FORIT(it1, out) {
      FORIT(it2, it1->second) {
        points[*it2] += n - (it1->second.size() - 1);
      }
    }
    pair<int, string> ans = make_pair(1 << 30, "zzzzzzzzzzzzzzzz");
    FORIT(it, points) {
      ans = min(ans, make_pair(it->second, it->first));
    }
    cout << ans.first << " " << ans.second << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int p[N]; for (int i=0; i<N; ++i) cin >> p[i];

    int max = 0;
    int sum = 0;
    for (int i=0; i<N; ++i) {
        if (max < p[i]) max = p[i];
        sum += p[i];
    }
    cout << sum-max/2 << '\n';

    return 0;
}



Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int left;
            public int right;

            public Point(int left, int right)
            {

                this.left = left;
                this.right = right;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var ans = 0L;
            var max = 0L;
            var num = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            foreach (var data in array)
                if (data < max)
                    ans += max - data;
                else
                    max = data;

            Console.WriteLine(ans);

        }

    }

}

Measured memory_bytes: 47444
a,b,c,x,y=[int(i) for i in input().split()]

#双対問題の最大化

gyou=4 #目的関数＋スラック変数λ1～λ3
retsu=6 #x, y＋スラック変数λ1～λ3＋定数項

matrix=[[0 for i in range(retsu)] for j in range(gyou)]

#評価関数
matrix[0][0], matrix[0][1]= -x, -y 
#ピッツァ
matrix[1][0], matrix[1][1]= 1, 0
matrix[2][0], matrix[2][1]= 0, 1
matrix[3][0], matrix[3][1]= 1, 1
#定数項
matrix[1][5], matrix[2][5], matrix[3][5]=a, b, 2*c

#スラック変数
matrix[1][2]=1
matrix[2][3]=1
matrix[3][4]=1

for i in range(10):
    if min(matrix[0])>=0:
        break
    else:
        p_column=min(enumerate(matrix[0]), key=lambda x: x[1])[0]
        const_per_p=[10**6 for i in range(gyou)]

    for j in range(gyou):
        if matrix[j][p_column]>0:
            const_per_p[j]=matrix[j][5]/matrix[j][p_column]

            k_row=min(enumerate(const_per_p), key=lambda x: x[1])[0]
            pivot=matrix[k_row][p_column]

            new_matrix=[[0 for i in range(retsu)] for j in range(gyou)]
            for l in range(gyou):
                for j in range(retsu):
                    if l==k_row:
                       new_matrix[l][j]/=pivot
                    else:
                       new_matrix[l][j]=matrix[l][j]-matrix[l][p_column]*matrix[k_row][j]/pivot

    matrix=new_matrix[:][:]

print(int(matrix[0][5]))





Measured memory_bytes: 3188
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;

	long N; cin >> N;
	long a[100000]; for (int i = 1; i <= N; i++) cin >> a[i];

	for (int i = 1; i <= N; i++) {

		while (a[i] % 2 == 0) {
			a[i] /= 2;
			res++;
		}

	}

	cout << res << endl;
}

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

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x4 = (-1) * (y2 - y1) + x1;
    y4 = (x2 - x1) + y1;
    x3 = (y1 - y2) + x2;
    y3 = (-1) * (x1 - x2) + y2;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
def gcd(x,y):
    a = max(x,y)
    b = min(x,y)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b
N,M=map(int,input().split())
S = input()
T = input()
g = gcd(M,N)
n = N//g
m = M//g
l = N*M // g
f = True
for i in range(g):
    a = n*i
    b = m*i
    if S[a] != T[b]:
        f = False
print(l if f else -1)

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

int N,M;

signed main() {
  cin >> N >> M;

  if(N%2==1) {
    for(int l=1, r=N-1, count=0; l<r && count<M; l++,r--,count++) {
      cout << l << " " << r << endl;
    }
  }
  else {
    int dame = 1 + N/2;
    int count = 0;
    for(int l=1, r=dame-1; l<r; l++,r--) {
      cout << l << " " << r << endl;
      if(++count==M) return 0;
    }
    for(int l=dame+1, r=N; l<r; l++,r--) {
      cout << l << " " << r << endl;
      if(++count==M) return 0;
    }
  }
}



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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define right HIASUHDUIA
#define R32 ({i32 x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

const int N = 1e6;
int left[N], a[N], right[N];

int32_t main(){
  int n = RI;
  for(int i = 0; i < n; i++)
    a[i] = RI;

  left[0] = -1;
  for(int i = 1; i < n; i++){
    left[i] = i-1;
    while(left[i] != -1 && a[left[i]] > a[i])
      left[i] = left[left[i]];
  }

  right[n-1] = n;
  for(int i = n-2; i >= 0; i--){
    right[i] = i+1;
    while(right[i] != n && a[right[i]] > a[i])
      right[i] = right[right[i]];
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    int L = i-left[i];
    int R = right[i]-i;
    ans += a[i] * (L*R);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	map<ll, bool> vis;
	ll cnt = 0;
	vis[n] = 1;
	while(true){
		if(n&1)
			n = 3*n + 1;
		else
			n = (n>>1);
		if(vis[n]){
			cout << cnt+2;
			return 0;
		}
		cnt++;
		vis[n] = 1;
	}
	return 0;
}

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

lli x;

int main(void){
	cin >> x;
	lli i = 0;
	while(i*(i+1)/2 < x) i++;
	cout << i << endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N, M, V, P;
map<ll, ll> mp1, mp2;

bool judge(ll pos, vector<ll> &A){
	if(N-pos<=P){
		return true;
	}else{
		ll X = A[pos];
		ll shita_kazu = mp2[X];
		ll Y = X + M;
		ll nokori = max(V - shita_kazu, 0ll);
		nokori = max(nokori - (P-1), 0ll);

		if(Y<A[N-P]){
			return false;
		}else{
			ll cum = 0;
			for(int i=pos+1;i<=N-P;i++){
				cum += min(Y-A[i], M);
			}
			if(nokori*M <= cum) return true;
			else return false;
		}
	}
}

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

    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    REP(i, N) mp1[A[i]]++;
    ll cum = 0;
    for(auto x: mp1){
    	cum += x.second;
    	mp2[x.first] = cum;
    }

    ll lb = -1;
    ll ub = N;
    while(ub-lb>1){
    	ll mid = (ub+lb)/2;
    	if(judge(mid, A)) ub = mid;
    	else lb = mid;
    }
    cout << N - ub << endl;
    return 0;
}

Measured memory_bytes: 13824
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<ctime>
#include<cstring>
using namespace std;
int n,a[1010];
int flag[1000000];
int k=0;
int b;
int main()
{
    memset(flag,0,sizeof(flag));
    scanf("%d",&n);
    b=n*(n-1)/2;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        k=0;
        for(int j=i;j<=n;j++)
        {
			k+=a[j];
			flag[k]=1;
			k*=10;
			if(k>b)
				break;
		}		
    }
    for(int i=0;i<=b+1;i++)
        if(flag[i]==0)
		{
			cout<<i<<endl;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 7128
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

using namespace std;

#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

const int MOD = 1e9+7;
using ll = long long;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;

  ll x[N], y[M];
  mp::cpp_int sum_x = 0, sum_y = 0;
  rep(i, N) {
    cin >> x[i];
    sum_x += x[i];
  }
  rep(i, M) {
    cin >> y[i];
    sum_y += y[i];
  }

  mp::cpp_int X = 0, Y = 0;
  rep(i, N) {
    sum_x -= x[i];
    X += sum_x - (N - 1 - i) * x[i];
    X %= MOD;
  }
  rep(i, M) {
    sum_y -= y[i];
    Y += sum_y - (M - 1 - i) * y[i];
    Y %= MOD;
  }
  cout << (X * Y) % MOD << "\n";

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int r,c,a[111][111]={};
  cin >> r >> c;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin >> a[i][j];
      a[r][j]+=a[i][j];
      a[i][c]+=a[i][j];
      a[r][c]+=a[i][j];
    }
  }
  
  for(int k=0;k<=r;k++){
    for(int l=0;l<=c;l++){
      cout << a[k][l];
      if(l!=c)cout <<  ' ';
    }
    cout << endl;
  }
  return 0;
}




Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}
vi A;
int n;
int memo[2][100'050];
int dp(int turn, int stones) {
    if(memo[turn][stones] != -1) return memo[turn][stones];
    int winner = 0;
    if(turn == 0) {
        winner = 1;
        rep(i,0,n) if(A[i] <= stones) {
            winner = min(winner, dp(1-turn, stones - A[i]));
        }
    } else {
        winner = 0;
        rep(i,0,n) if(A[i] <= stones) {
            winner = max(winner, dp(1-turn, stones - A[i]));
        }

    }
    return memo[turn][stones] = winner;
}

int main() {
    cin.sync_with_stdio(false);
    int k;
    cin >> n >> k;
    A = vi(n);
    rep(i,0,n) cin >> A[i];
    memset(memo,-1,sizeof(memo));
    if(dp(0,k) == 0) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

ll g (ll n) {
  if ((n+1)/2%2) return 1;
  else return 0;
}

ll f(ll n) {
  if (n%2) return g(n);
  else {
    // ll m = n-1;
    return n^g(n-1);
  }
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = f(a-1) ^ f(b);
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#define ll long long

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  ll n,m,i,a[100005];
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++){
    scanf("%lld", &a[i]);
    a[i] /= 2;
  }
  ll l=a[0];
  for(i=0;i<n;i++) l *= a[i]/gcd(l,a[i]); // l = (lとa[i]の最小公倍数) => (最終的な l) = (全ての最小公倍数)
  for(i=0; i<n; i++){
    if(l/a[i]%2==0){
      printf("0\n");
      return 0;
    }
  }
  printf("%lld\n",(m/l+1)/2);//奇数である公倍数の数 *テクニック: (x+1)/2は繰り上がり
  return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
	double height;
	double max_height = 0.0, min_height = 1.0e+6;
	
	while ( cin >> height ) {
		if ( max_height < height ) max_height = height;
		if ( min_height > height ) min_height = height;
	}
	
	cout << max_height - min_height << endl;
	
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  vector<int> A(N);
  
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  
  cout << A.at(N-1)-A.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> G[100010];
template<class T> void chmax(T& x, T y) {if(x < y) x = y;}
int rnk(int n){
    int mx = 0;
    vector<int> vs;
    for(auto& u : G[n]){
        vs.push_back(rnk(u));
    }
    sort(vs.rbegin(), vs.rend());
    for(int i = 0; i < vs.size(); i++){
        chmax(mx, vs[i] + i);
    }
    return mx + 1;
}

int main(){
    cin >> N;
    for(int i = 2; i <= N; i++){
        int a;
        cin >> a;
        G[a].push_back(i);
    }
    cout << rnk(1) - 1 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	ans = (n * (n - 1)) / 2;
	ans += (m * (m - 1)) / 2;

	cout << ans << "\n";
}

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

	solve_abc();

	return 0;
}


Measured memory_bytes: 256
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)  
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;  
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n;
    cin >> n ;
    vector<pair<int,int>>v(n);
    fn{
      cin >> v[i].fi >> v[i].se ;
    }
    sort(all(v));
    int ans = 0 ;
    vector<int>mx,mi;
    fn{
      mx.pb(v[i].fi+v[i].se);
      mi.pb(v[i].fi-v[i].se);
    }
    sort(all(mx));
    sort(all(mi));
    ans = max(mx.back()-mx[0],mi.back()-mi[0]);
    cout << ans ;    
    
  
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  int b = 0;
  for(int i=0; i<n; i++) {
    if(a.at(b) == 2) {
      cout << i+1 << endl;
      return 0;
    } else {
      b = a.at(b) - 1;
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 640
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

void abort_with_re() {
    std::abort();
}

void abort_with_wa() {
    std::exit(0);
}

void abort_with_tle() {
    int x = 3;
    for (long long i = 0; i < 1024 * 1024 * 1024; ++i) {
        for (long long j = 0; j < 1024 * 1024 * 1024; ++j) {
            x *= x;
        }
    }
}

void abort_with_ole() {
    char s[1024 * 1024];
    while (true) {
        std::fwrite(s, sizeof(char), 1024 * 1024, stdout);
    }
}

void abort_with_mle() {
    char *buf = (char *)std::malloc(1024 * 32 * 256);
    for (long long i = 0; i < 256; ++i) {
        for (long long j = 0; j < 1024 * 32; ++j) {
            buf[i * 1024 * 1024 + j] = (char)i;
        }
    }
    long long n0 = buf[1024 * 1024 * 128 - 1];

    long long a, b;
    std::cin >> a >> b;
    if (a == b) {
        std::cout << 2 * a + n0 << std::endl;
    } else {
        long long x = std::max(a, b);
        std::cout << x + (x-1) + n0 << std::endl;
    }
}

int main() {
    abort_with_mle();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 998244353;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[200100];

ll b[200100];
ll c[200100];

ll solve() {
    for (int i = 0; i < n; i++) {
        if (i+a[i] < n) b[i+a[i]]++;
        if (i-a[i] >= 0) c[i-a[i]]++;
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += b[i] * c[i];
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 7048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionL
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

           bool[] Append = new bool[9];  //初期値はfalse

            // 整数配列の入力
            int[] A1 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] A2 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] A3 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            List<int> BC = new List<int>();

            BC.AddRange(A1);
            BC.AddRange(A2);
            BC.AddRange(A3);

            var N = int.Parse(Console.ReadLine());

            for(int inumC = 0; inumC < N; inumC++)
            {
                var b =int.Parse(Console.ReadLine());

                for (int inumA = 0; inumA < 9; inumA++)
                {
                   if(BC[inumA] == b)
                   {
                        Append[inumA] = true;
                   }
                }
            }

            string result = "No"; 

            for(int inumD = 0; inumD < 7; inumD +=3)
            {
                if(Append[inumD]==true && Append[inumD + 1] == true && Append[inumD + 2] == true) result = "Yes";
            }

            for (int inumD = 0; inumD < 3; inumD++)
            {
                if (Append[inumD] == true & Append[inumD + 3] == true & Append[inumD + 6] == true) result = "Yes";
            }

            if (Append[0] == true && Append[4] == true && Append[8] == true) result = "Yes";
            if (Append[2] == true && Append[4] == true && Append[6] == true) result = "Yes";

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
  int r, D;

  vector<int>x(11,0);

  cin >> r >> D >> x[0];

  for( int i=0; i<=10; i++){
    x[i+1] = r*x[i] - D;
  }

  for( int i=1; i<=10; i++){
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 3568
#include<iostream>
using namespace std;
// https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_a

bool checkHousePass(int firstHouse,int lastHouse,int checkHouse){
    int minHouse,maxHouse;
    if(firstHouse < lastHouse){
        minHouse=firstHouse;
        maxHouse=lastHouse;
    }
    else{
        minHouse = lastHouse;
        maxHouse = firstHouse;
    }
    if(minHouse <= checkHouse && checkHouse <= maxHouse){
        return true;
    }
    else{
        return false;
    }
    return true;
}

int main(void){
    int a,b,c;
    bool result;
    cin >> a >> b >> c;
    result = checkHousePass(a,b,c);
    if(result){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout << "No" << endl;
        return 0;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX=1e4;
static const int HMAX=100;
static const int WMAX=100;
int H,W,N,a[MAX+2],x,cuntx,cunty;
int c[HMAX+2][WMAX+2];

void solve(){
    cuntx=1;cunty=1;
    for(int i=1;i<=N;i++){ //色iについて
        while(a[i]){
            c[cuntx][cunty]=i;
            if(cunty % 2){ //偶数列は下へ
                if(cuntx==H) cunty++;
                else cuntx++;
            }else{ //奇数列は上へ
                if(cuntx==1) cunty++;
                else cuntx--;
            }
            a[i]--;
        }
    }
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>H>>W>>N;
    for(int i=1;i<=N;i++) {
        cin>>a[i];
    }
    solve();
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++) cout<<c[i][j]<<" ";
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
int main()
{
  //FAST IO       
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll x;
cin>>x;
ll init=100;
ll year=0;
while(init<x)
{
init+=(0.01*init);
year++;
}
cout<<year<<"\n";
return 0;
}

Measured memory_bytes: 3652
nums = list(map(int,input().split()))
N = nums[0]
D = nums[1]
res = 0
for z in range(N):
  coords = list(map(int,input().split()))
  x = coords[0]
  y = coords[1]
  if D >= ((x**2+y**2)**(1/2)):
    res += 1
print(res)

Measured memory_bytes: 9572
#include <iostream>

using namespace std;

int main(void){
  int n,m,l;
  cin >> n;
  cin >> m;
  cin >> l;

  long int a[n][m];
  long int b[m][l];
  long int c[n][l];

  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++){
    for(int j = 0 ; j < l ; j++){
      cin >> b[i][j];
    }
  }

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < l ; j++){
      c[i][j] = 0;
      for(int k = 0 ; k < m ; k++){
        c[i][j] += a[i][k] * b[k][j];
      }
      cout << c[i][j];
      if(j == l-1) cout << endl; else cout << " ";
    }
  }

  return 0;

}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
bool v[1001];
int main(int argc, char *argv[])
{
	memset(v,0,sizeof(v));
	v[1] = 1;
	for (int i = 2; i < 32; i++)
		for (int ret = i*i; ret <= 1000; ret *= i)
		v[ret] = 1;
	int x; cin >> x;
	for (;x>=1;x--) if(v[x]){printf("%d\n",x); break;}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;cin>>s;
    int n=s.size();
    vector<ll> l(n+1,0),r(n+1,0);
    rep(i,n){
        if(s[i]=='<'){
            l[i+1]=l[i]+1;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){
            r[i]=r[i+1]+1;
        }
    }
    ll ans=0;
    rep(i,n+1){
        ans+=max(r[i],l[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8732
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N)]


dp = [[0 for _ in range(N)] for _ in range(3)]
dp[0][0] = ABC[0][0]
dp[1][0] = ABC[0][1]
dp[2][0] = ABC[0][2]

for i in range(1, N):
    dp[0][i] = max(dp[1][i-1]+ABC[i][0], dp[2][i-1]+ABC[i][0])
    dp[1][i] = max(dp[0][i - 1] + ABC[i][1], dp[2][i - 1] + ABC[i][1])
    dp[2][i] = max(dp[1][i - 1] + ABC[i][2], dp[0][i - 1] + ABC[i][2])


print(max(dp[0][-1], dp[1][-1], dp[2][-1]))

Measured memory_bytes: 42608
h,w=map(int,input().split())
s=[list(input().split()) for _ in range(h)]
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(h):
    for j in range(w):
        if s[i][j]=='snuke':
            print(a[j]+str(i+1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<P> tasks(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        tasks[i] = P(b, a);
    }
    sort(tasks.begin(), tasks.end());
    
    int now = 0;
    bool ans = true;
    rep(i, n) {
        P task = tasks[i];
        now += task.second;
        if (now <= task.first) continue;
        ans = false;
        break;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1792
#coding:utf-8
n = int(input())
n_max = 100
cake = 4
donut = 7
s = set()
for i in range(int(n_max/cake)+1):
    for j in range(int(n_max/donut)+1):
        s.add(4*i+7*j)
if n in s:
    print ('Yes')
else:
    print ('No')


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

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


class cordinate
{

public:
	int x;
	int y;

};

int main()
{
	while(1)
	{


		int w;
		int h;
		cin >> w >> h; 
		if(w == 0 && h == 0)
		{
			break;
		}
		w = 110;
		h = 110;
		
		int xs;
		int ys;
		cin >> xs >> ys;
		int xg;
		int yg;
		cin >> xg >> yg;
		int n;
		cin >> n;

		vector<vector<int >> vobj;

		for(int i = 0; i < h; i++)
		{
			vector<int> lineobj;
			for(int j = 0; j < w; j++)
			{

				lineobj.push_back(0);

			}
			vobj.push_back(lineobj);

		}
		for(int i = 0; i < n; i++)
		{
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			x--;
			y--;

			if(d == 0)
			{
				vobj[x][y] = c;
				vobj[x + 1][y] = c;
				vobj[x + 2][y] = c;
				vobj[x + 3][y] = c;
				vobj[x][y + 1] = c;
				vobj[x + 1][y + 1] = c;
				vobj[x + 2][y + 1] = c;
				vobj[x + 3][y + 1] = c;
			}
			else if(d == 1)
			{
				vobj[x][y] = c;
				vobj[x][y + 1] = c;
				vobj[x][y + 2] = c;
				vobj[x][y + 3] = c;
				vobj[x + 1][y] = c;
				vobj[x + 1][y + 1] = c;
				vobj[x + 1][y + 2] = c;
				vobj[x + 1][y + 3] = c;
			}
		}

		int startColor;
		startColor = vobj[xs - 1][ys - 1];
		queue<cordinate> que;

		cordinate obj;
		obj.x = xs - 1;
		obj.y = ys - 1;
		que.push(obj);
		bool flag = false;
		while(1)
		{
			if(startColor == 0)
			{
				break;
			}
			cordinate buf;
			buf = que.front();
			que.pop();

			int bx;
			int by;
			bx = buf.x;
			by = buf.y;
			if(bx == xg - 1 && by == yg - 1)
			{
				flag = true;
				break;
			}
			for(int i = 0; i < 4; i++)
			{
				if(bx + dx[i] >= 0 && bx + dx[i] <= h - 1)
				{
					if(by + dy[i] >= 0 && by + dy[i] <= w - 1)
					{
						if(vobj[bx + dx[i]][by + dy[i]] == startColor)
						{
							cordinate newObject;
							newObject.x = bx + dx[i];
							newObject.y = by + dy[i];
							que.push(newObject);

						}
					}
				}
			}
			vobj[bx][by] = -1;

			if(que.size() == 0)
			{
				break;
			}
		}


		if(flag == true)
		{
			cout << "OK" << endl;
		}
		else{
			cout << "NG" << endl;
		}
		/*for(int i = 0; i < w - 1; i++)
		{
			for(int j = 0; j < h - 1; j++)
			{
				cout << vobj[i][j] << " ";
			}
			cout << endl;
		}  */

	}



}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll zero=0;
if(a<=0&&b>=0)
    zero++;
if(c<=0&&d>=0)
    zero++;
ll x=a*c;
ll y=b*d;
ll z=max(x,y);
x=a*d;
y=b*c;
z=max(z,x);
z=max(z,y);
if(zero)
    z=max(z,(ll)0);
cout<<z<<endl;
}


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

int main(void) {

  char s[1001];
  int w;
  scanf("%s %d", s, &w);
  for (int i = 0; i < strlen(s); i++) {
    if (i%w == 0) {
      printf("%c", s[i]);
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>

using namespace std;
int cnt;
unsigned long long int n;
void rec(unsigned long long int v){
  cnt++;
  if(v <= 3)return;
  if(v%3 == 0)rec(v/3);
  else rec(v/3+1);
}

int main(){
  while(cin >> n){ //cout << (int)log(n) << endl;
    cnt = 0; 
    rec(n);
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
  int K;
  string S;
  cin >>K;
  cin >>S;
  int A=S.size();
  if(A>K){
    for(int i=0;i<K;i++){
      cout<<S[i];
    }
    cout<<"...";
  }
  else {
    cout<<S<<endl;
  }
}


Measured memory_bytes: 3628