akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private int getMinCost(int n, int[] p) {
		int[][] m = new int[n+1][n+1];
		for (int s = 0; s < n; s++) {
			for (int i = 1, j = s + 2; j <= n; i++, j++) {
				m[i][j] = Integer.MAX_VALUE;
				for (int k = i; k < j; k++) {
					m[i][j] = Math.min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
				}
			}
		}
		return m[1][n];
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] p = new int[n+1];
		for (int i = 0, j = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int n1 = Integer.parseInt(st.nextToken());
			int n2 = Integer.parseInt(st.nextToken());
			if (i == 0) {
				p[j++] = n1;
			}
			p[j++] = n2;
		}
		reader.close();
		System.out.println(getMinCost(n, p));
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> vec(N, 0);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		++vec[a-1];
		++vec[b-1];
	}
	for (int i = 0; i < N; ++i)
	{
		cout << vec[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	string S[200];
	int N,M,i,c=0,ans=0;
	cin>>N;
	for(i=0;i<N;i++)
	{
		cin>>S[i];
	}
	cin>>M;
	for(;i<N+M;i++)
	{
		cin>>S[i];
	}
	for(i=0;i<N;i++)
	{
		c=0;
		for(int j=0;j<N;j++)
		{
			if(S[i]==S[j])c++;
		}
		for(int j=N;j<N+M;j++)
		{
			if(S[i]==S[j])c--;
		}
		ans=max(ans,c);
	}
	cout<<ans;
	}

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

int main (){
    int a,b,c,flg;
    cin >> a >> b >> c;
    flg = 0;
    if(a == b && b != c)
        flg = 1;
    else if(b == c && b != a)
        flg = 1;
    else if(c == a && a != b)
        flg = 1;
    if(flg)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	int k,n;
	cin >> k >> n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	int max = arr[1]-arr[0];
	for(int i=0;i<=n-3;i++)
	{
		int z = arr[i+2]-arr[i+1];
		if(z>max) max = z;
	}
	int z = arr[0]+k-arr[n-1];
	if(z>max) max = z;
	cout << k-max << endl;
	return 0;
}



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

int h[100000], dp[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> h[i];

    dp[0] = 0;
    for (int i=1; i<n; i++)
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), i > 1 ? dp[i-2] + abs(h[i] - h[i-2]) : INT_MAX);

    cout << dp[n-1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a > 9 || b > 9) {
            System.out.println("-1");
        } else {
            System.out.println(a * b);
        }
        
    }
}


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

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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int n; cin >> n;
    int ban = (n%2 ? n : n+1);

    vector<pair<int,int>> ans;
    for (int u = 1; u <= n; u++) {
        for (int v = u+1; v <= n; v++) {
            if (u+v != ban) ans.emplace_back(u,v);
        }
    }
    cout << ans.size() << '\n';
    for (auto uv : ans) {
        int u,v; tie(u,v) = uv;
        cout << u << ' ' << v << '\n';
    }
    
    return 0;
}


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

int main(){
  int N,X,sum=0,count=0;
  cin >> N >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int i=0;
  while(X>sum){
    if(i==N){
      break;
    }
    sum+=A.at(i);
    count++;
    i++;
  }
  if(sum<X){
    count--;
  }
  if(sum>X){
    count--;;
  }
  cout << max(0,count) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int a, b, ans = 0, cnt = 0;

    cin >> a >> b;

    while (1)
    {
        if (b == 1) {
            ans = 0;
            break;
        }

        ans += a;
        cnt++;
        if (b <= ans) {
            break;
        }

        ans--;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
X = int(input()) # 数字を変数に格納

X_2 = int(X / 100)
X_2_rest = X % 100

X_3 = int(X_2_rest / 5)
X_3_rest = X % 5

if X_3_rest > 0:
    X_4 = 1
else:
    X_4 = 0

if X_2 >= (X_3 + X_4):
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i < n ; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    map<string,int> str_freq;
    for(string x: s) str_freq[x]++;

    long long ans = 0;
    for(auto p: str_freq) {
        long long c = p.second;
        ans += c * (c-1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int brick[n];
	for(int i=0;i<n;i++)
		cin>>brick[i];
	int val=0;
//	while(true)
	for(int i=0;i<n;i++)
	{
		if(brick[i]==val+1)
		{	
			val++;
		}
	}
	if(val==0)
		cout<<-1<<endl;
	else	
		cout<<n-val<<endl;
}

Measured memory_bytes: 1024
#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() {
  int N, i; cin >> N;
  vector<int> a(N);
  rep (i, N) cin >> a.at(i);
  bool can = true;

  rep (i, N) if (a.at(i)%2 == 0){
    int tmp = a.at(i);
    if (tmp%3 != 0 && tmp%5 != 0) {
      can = false;
      break;
    }
  }
  if (can)
    puts("APPROVED\n");
  else
    puts("DENIED\n");
  return 0;
}


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

int main(){
    int w1, w2, s1, s2, sol, total;
    cin >> w1 >> w2 >> s1 >> s2 >> sol >> total;
    w1 *= 100; w2 *= 100;

    double max_conc = 0;
    int ans_w = 0, ans_s = 0;

    rep(i,total/w1){
        rep(j,(total-i*w1)/w2){
            int water = i*w1 + j*w2;
            int max_s = min(total - water, water/100 * sol);
            
            rep(k,max_s/s1){
                rep(l,(max_s-k*s1)/s2){
                    int sugar = k*s1 + l*s2;
                    double conc = (100.0*sugar)/(sugar+water);

                    //cout << water << " " << sugar << " " << conc << endl;

                    if(max_conc < conc){
                        max_conc = conc;
                        ans_w = water; ans_s = sugar;
                    }

                }
            }
        }
    }
    if(ans_w == 0) ans_w = w1;
    cout << ans_w+ans_s << " " << ans_s << endl;
}


Measured memory_bytes: 256
M, D = map(int,input().split())
ans = 0
if D < 10:
    print(0)
    exit()
for i in range(1,M+1):
    for j in range(10,D+1):
        j = str(j)
        d1 = int(j[1])
        d10 = int(j[0])
        if d1 >= 2:
            if d10 >= 2:
                if d1 * d10 == i:
                    ans += 1
print(ans)


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

int main(){
	int n,m;
  	cin >> n >> m;
  	char a[n][n],b[m][m];
  	for (int i=0;i<n;i++){
      	for (int j=0;j<n;j++){
    	cin >> a[i][j];
        }
    }
  	for (int i=0;i<m;i++){
      	for (int j=0;j<m;j++){
    	cin >> b[i][j];
        }
    }
  	bool x=false;
  	for (int i=0;i<=n-m;i++){
      	for (int l=0;l<=n-m;l++){
    		int df=0;
    		for (int j=0;j<m;j++){
        		for (int k=0;k<m;k++){
            		if (a[j+i][k+l]!=b[j][k]) df++;
           		}
        	}
    		if (df==0) x=true;
        }
    }
  	if (x==true) cout << "Yes" <<endl;
  	else cout << "No" <<endl;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
K,X = map(int,input().split())

Ans = []
for i in range(X-K+1,X+K):
    Ans.append(i)

print(*Ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;
int dp[305][305][305];
char S[305];
int main()
{
	int n, m, ans = 0;
	scanf("%s", S + 1);
	n = strlen(S + 1);
	scanf("%d", &m);
	dp[0][n + 1][0] = 0;
	for(int i = 0; i < n; i ++) for(int j = n + 1; j > i; j --) 
	for(int k = 0; k <= m; k ++){
		if(i > 0) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k]);
		if(j < n + 1) dp[i][j][k] = max(dp[i][j][k], dp[i][j + 1][k]);
		if(i > 0 && j < n + 1) {
			if(S[i] == S[j]) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j + 1][k] + 1);
			if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j + 1][k - 1] + 1);
		}
		ans = max(ans, dp[i][j][k] * 2 + (j - i > 1));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 110848
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> order(n);
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        order[i-1] = {x, i};
    }
    sort(order.begin(), order.end());
    for (int i = 0; i < n; i++) {
        cout << order[i].second << " ";
    }
}

Measured memory_bytes: 3952
# coding: utf-8
# Your code here!

W = []
K = []
for i in range(10):
   W.append(int(input()))
   W.sort()
   W.reverse()
for i in range(10):
   K.append(int(input()))
   K.sort()
   K.reverse()

print(sum(W[0:3]), sum(K[0:3]))



Measured memory_bytes: 5604
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	getLine
	s <- getLine
	print $ maximum $ map ( length . uncurry intersect ) $ map ( unique *** unique ) $ zip ( inits s ) ( tails s )

unique = map head . group . sort

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


int main() {
    std::ios_base::sync_with_stdio(false);
    std::string t, s;
    std::cin >> s >> t;
    bool ok = true;
    if (s.size() + 1 != t.size())
        ok = false;
    for (int i = 0; i < (int) t.size() - 1; ++i) {
        if (s[i] != t[i])
            ok = false;
    }
    if (ok)
        std::cout << "Yes";
    else
        std::cout << "No";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  Combination<ModInt> comb(H + W);

  auto move = [&](int r1, int c1, int r2, int c2) {
    return comb.C(r2 - r1 + c2 - c1, r2 - r1);
  };

  ModInt ans = move(0, 0, H - 1, W - 1);
  for (int i = 0; i < (int)B; ++i) ans -= move(0, 0, H - 1 - A, i) * move(H - A, i, H - 1, W - 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
from itertools import permutations
def main():
    n, m = map(int, input().split())

    edge = set()
    for _ in range(m):
        a, b = map(lambda x: int(x)-1, input().split())
        edge.add((a, b))  
        edge.add((b, a))

    #全ノード間に辺が張っていると仮定する
    #このとき全てのノードを廻る順番は順列の数だけある
    #ここから条件を絞って数えるべきものを数えていく 

    #ノードを廻る順を構成する 
    node_num = []
    for i in range(n):
        node_num.append(i)
    
    cnt = 0
    for p in permutations(node_num):
        #数える経路は始点が0である
        if p[0] == 0:
            #この順列pの通りに辿れるように辺が張っているならこの経路は数えるべき経路である
            flag = True
            for i in range(n-1):
                #この順列のあるノード間に辺が存在しないならこの経路は不可能
                if (p[i], p[i+1]) not in edge:
                    flag = False
            if flag:
                cnt += 1 
    print(cnt) 
main()

Measured memory_bytes: 39664
#include <iostream>
#include <cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;

int main(){
    ll n,q,temp,sum=0,temp2;
    ll nums[100005];
    memset(nums,0,sizeof(nums));
    scanf("%lld",&n);
    while(n--){
        scanf("%lld",&temp);
        nums[temp]++;
        sum += temp;
    }
    scanf("%lld",&q);
    while(q--){
        scanf("%lld %lld",&temp,&temp2);
        sum -= nums[temp]*temp;
        sum += nums[temp]*temp2;
        nums[temp2] += nums[temp];
        nums[temp] = 0;
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 4032
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i];

    map<long long, int> memo;
    long long sum = 0;
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(memo.find(sum) == memo.end())
            memo[sum] = i;
        sum += v[i];
        if(memo.find(sum) != memo.end())
            ans = max(ans, i - memo[sum] + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15944
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int n = NextInt();
        int[] a = LineInt();
        //凸凹の2パターンっぽい
        long costA = 0;
        long costB = 0;

        long now = a[0];
        if (now <= 0) { now = 1; costA = Math.Abs(a[0]) + 1; }
        for (int i = 1; i < n; i++)
        {
            if (now > 0)
            {
                //今0より大きいので小さくする.
                if (now + a[i] < 0)
                {
                    //ok
                    now += a[i];
                }
                else
                {
                    //ng
                    costA += Math.Abs(now + a[i]) + 1;
                    now = -1;
                }
            }
            else
            {
                //今0より小さいので大きくする
                if (now + a[i] > 0)
                {
                    //ok
                    now += a[i];
                }
                else
                {
                    //ng
                    costA += Math.Abs(now + a[i]) + 1;
                    now = 1;
                }
            }
        }

        now = a[0];
        if (now >= 0) { now = -1; costB = Math.Abs(a[0]) + 1; }
        for (int i = 1; i < n; i++)
        {
            if (now > 0)
            {
                //今0より大きいので小さくする.
                if (now + a[i] < 0)
                {
                    //ok
                    now += a[i];
                }
                else
                {
                    //ng
                    costB += Math.Abs(now + a[i]) + 1;
                    now = -1;
                }
            }
            else
            {
                //今0より小さいので大きくする
                if (now + a[i] > 0)
                {
                    //ok
                    now += a[i];
                }
                else
                {
                    //ng
                    costB += Math.Abs(now + a[i]) + 1;
                    now = 1;
                }
            }
        }

        Console.WriteLine(Math.Min(costA, costB));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 26076
#include <stdio.h>

int main(void) {
	int a[1000];
	int n, i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	
	for (i = n - 1; i >= 0; i--) printf("%s%d", i == n - 1 ? "" : " ", a[i]);
	puts("");
	
	return 0;
}

Measured memory_bytes: 612
<?php 
    fscanf(STDIN, "%d %d", $n, $k);
    $input_line = explode(' ', trim(fgets(STDIN)));

    $sort = sort($input_line);
    $ans = 0;
    for($i = 0; $i < $k; $i++){
        $ans = $ans + $input_line[$i];
    }
    echo $ans;

Measured memory_bytes: 16256
N = input()

dp = [[ [0] * 10 for i in range(len(N)) ] for j in range(2) ]

ans = 0

for i in range(len(N)): #kai

    for j in range(2): #flag

        for k in range(10): # num

            if i == 0:
                if k < int(N[i]):
                    dp[1][i][k] = k
                elif k == int(N[i]):
                    dp[0][i][k] = k

            else:

                if j == 0 and k == int(N[i]):
                    dp[0][i][k] = max(dp[0][i][k],max(dp[0][i-1]) + k)

                elif j == 0 and k < int(N[i]):
                    dp[1][i][k] = max(dp[1][i][k],max(dp[0][i-1]) + k)

                elif j == 1:
                    dp[1][i][k] = max(dp[1][i][k],max(dp[1][i-1]) + k)

print (max( max(dp[0][len(N)-1]) , max(dp[1][len(N)-1]) )  )

                


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

typedef pair<int, int> P;

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

    if(n == 3){
        cout << 2 << "\n" << 1 << " " << 3 << "\n" << 2 << " " << 3 << "\n";
        return 0;
    }

    set<P> s;
    // 部分グラフの頂点数
    int subgraph_vertex_cnt = (n % 2 == 0) ? n : n - 1;
    int subset_sum = (n % 2 == 0) ? n + 1 : n;
    for(int i = 1; i < subgraph_vertex_cnt; ++i){
        for(int j = 1; j <= subgraph_vertex_cnt; ++j){
            if(i == j || i + j == subset_sum)   continue;
            
            int u = i, v = j;
            if(u > v)   swap(u, v);
            s.insert(P(u, v));
        }
    }
    if(n % 2 != 0){
        for(int i = 1; i < n; ++i){     // n = subgraph_vertex_cnt
            s.insert(P(i, n));
        }
    }

    cout << s.size() << "\n";
    for(auto it : s){
        cout << it.first << " " << it.second << "\n";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int H,W,K; cin >> H >> W >> K;
    char c[10][10];
    char ch[10][10];
    ll ans = 0;
    rep(i,H)
        rep(j,W)
            cin >> c[i][j];

    //R個の全探索(2^R通り)
    for (int bit = 0; bit < (1 << (H+W)); bit++) {
        rep(ti,H)
            rep(tj,W)
                ch[ti][tj] = c[ti][tj];

        for (int i = 0; i < (H+W); i++) {
            //i番目のビットが立っていた時の処理
            if (bit & (1<<i)) {
                if(i < H){
                    rep(j,W)
                        ch[i][j] = 'r';
                }else{
                    rep(j,H)
                        ch[j][(i-H)] = 'r';
                }      
            }
        }

        int tmp = 0;
        rep(ti,H){
            rep(tj,W){
                if(ch[ti][tj] == '#') tmp++;
            }
        }
        if(tmp == K) ans++;
    }

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


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
 
#define pi(x) printf("%d\n", x)
#define pid(x, y) printf("%d %d\n", x, y)
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pll(x) printf("%lld\n", x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define plld(x, y) printf("%lld %lld\n", x, y)
#define pllt(x, y, z) printf("%lld %lld %lld\n", x, y, z)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#pragma GCC optimize(2)

int main(){
    long long a,b,c;
    std::cin >> a >> b >> c;
    if(a + b + c >= 22) std::cout << "bust" << std::endl;
    else std::cout << "win" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int inv[2000010];
void inel()
{
    inv[1] = 1;
    for(int i = 2;i <= 2000008;i++)
    {
        inv[i] = 1ll * (mod-mod/i) * inv[mod % i] % mod;
    }
}
int C(int n, int k)
{
	ll ans = 1;
	for (int i = 1;i <= n;++i)
	{
		ans = ans * i % mod;
	}
	for (int i = 1;i <= k;++i)
	{
		ans = ans * inv[i] % mod;
	}
	for (int i = 1;i <= n-k;++i)
	{
		ans = ans * inv[i] % mod;
	}
	return ans;
}
int main()
{
 	ios::sync_with_stdio(0);
 	inel();
 	int r1, c1, r2, c2;
 	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	ans = (ll)C(c2+r2+2,c2+1) + (ll)C(c1+r1,c1) + (ll)mod + (ll)mod - (ll)C(c2+r1+1,c2+1) - (ll)C(c1+r2+1,c1);
	ans %= mod;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8064
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)
	xs, ys, hs := make([]int, n), make([]int, n), make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i], &ys[i], &hs[i])
	}

	for i := 0; i <= 100; i++ {
		for j := 0; j <= 100; j++ {
			H := 0
			for k := range xs {
				if H == 0 && hs[k] > 0 {
					H = hs[k] + abs(i-xs[k]) + abs(j-ys[k])
					break
				}
			}
			for k := range xs {
				if newH := max(H-abs(i-xs[k])-abs(j-ys[k]), 0); hs[k] != newH {
					break
				} else if k == len(xs)-1 {
					fmt.Println(i, j, H)
					return
				}
			}
		}
	}
}


Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

template<typename T>
T powint (const T& x, const T& y) {
  T ret = 1;
  for(int i=0; i<y; ++i) ret *= x;
  return ret;
}

long long factorial(long long X) {
  long long ans = 1;
  for(int i=1; i<X+1 ; ++i) ans *= i;
  return ans;
}

std::map<long long, long long> prime_factor(long long n) {
  std::map<long long, long long> ret;
  for(long long i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1; // if n is prime number.
  return ret;
}

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

int main() {
  ll X, Y;
  cin >> X >> Y;

  if (2*X < Y || 2*Y < X) {
    cout << 0 << endl;
    return 0;
  }
  if ((X+Y)%3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll large, small;
  if (X > Y) {
    large = X;
    small = Y;
  }
  else {
    large = Y;
    small = X;
  }
  ll dist = (large + small)/3;
  ll numedge = small - (large + small)/3;
  ll ans = 1;
  ll tmp = dist;
  for (int i=0; i < numedge; ++i) {
    ans *= dist - i;
    ans %= MODA;
  }
  for (int i=2; i < numedge+1; ++i) {
    ans = ans * modinv(i, MODA) % MODA;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    int l;
  	cin>>n;
    l=n.size();
    for(int i=0;i<l;i++)
    {
        if(n[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(n[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <time.h>
#include <random>
using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    cout<<(A+B)%24<<endl;    

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 1; i <= n; i++) {
    ll t = n/i;
    ans += i * (t * (t+1)/2);
  }
  
  cout << ans << endl;
  return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S, T; cin >> S >> T;
    ll ans = 0;
    REP(i, S.length()) {
        if(S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3740
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def main():
    N=I()
    A=LI()
    def solve(is_minus):
        now = 0
        res = 0
        for a in A:
            now += a
            if is_minus:#累積和が負でないといけない
                if now >= 0:#負じゃない
                    res += abs(now-(-1))
                    now = -1
            else:#累積和が負でないといけない
                if now <= 0:#負じゃない
                    res += abs(now-1)
                    now = 1
            is_minus ^= 1 #true/falseを反転
        return res

    ans = min(solve(True), solve(False)) ##ポケットモンスター 奇数から始める/偶数から始める
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 59804
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
  cin >> n >> m >> 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 < m; j++){
      for(int k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << (j == 0 ? "": " ") << c[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=200005;
ll num[maxn],a[maxn],ans;
int n,r[maxn],f[maxn],k,ky;
inline int read(){
    int x=0; char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x;
}
inline void update(int x,int y){ for(;x<=ky;x+=x&-x) f[x]+=y;}
inline int query(int x){ int an=0; for(;x;x-=x&-x) an+=f[x]; return an;}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) a[i]=read()-k;
    for(int i=1;i<=n;i++){
        a[i]+=a[i-1],num[i]=a[i];
        if(a[i]>=0) ans++;
    }
    sort(num+1,num+n+1);
    ky=unique(num+1,num+n+1)-num-1;
    for(int i=1;i<=n;i++) r[i]=lower_bound(num+1,num+ky+1,a[i])-num;
    for(int i=1;i<=n;i++) ans+=(ll)query(r[i]),update(r[i],1);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=2e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,pos[maxn],w[maxn];
int gao(int x)
{
    int ret=x,i,j=2*t/m,k=2*t%m;
    ll cnt=0;
    rep(i,2,n)
    {
        if(w[i]!=w[1])
        {
            cnt+=j;
            if(w[1]==1)cnt+=(k>pos[i]-pos[1]);
            else cnt+=(k>m-pos[i]+pos[1]);
        }
    }
    cnt%=n;
    if(w[1]==1)ret+=cnt;
    else ret-=cnt;
    return ((ret-1)%n+n)%n+1;
}
int main()
{
    int i,j;
    scanf("%d%d%d",&n,&m,&t);
    rep(i,1,n)scanf("%d%d",&pos[i],&w[i]);
    int rt=gao(1);
    rep(i,1,n)pos[i]=(pos[i]+(w[i]==1?1:-1)*t%m+m)%m;
    int x=pos[1];
    sort(pos+1,pos+n+1);
    if(w[1]==1)
    {
        rep(i,1,n)if(pos[i]==x)break;
    }
    else
    {
        for(i=n;i>=1;i--)if(pos[i]==x)break;
    }
    j=(i+n-rt)%n+1;
    rep(i,j,n)printf("%d\n",pos[i]);
    rep(i,1,j-1)printf("%d\n",pos[i]);
    return 0;
}


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

using namespace std;

int main(){
    int n,m,x,cost1=0,cost2=0;
    scanf("%d%d%d",&n,&m,&x);
    int a[m];
    for(int i=0;i<m ; ++i){
        scanf("%d",&a[i]);
    }
    for(int i=x;i<=n;++i){
        for(int j=0;j<m ; j++){
            if(a[j]==i && i!=x){
                cost1++;
            }
        }
    }
    for(int i=x;i>=0;--i){
        for(int j=0;j<m ; j++){
            if(a[j]==i && i!=x){
                cost2++;
            }
        }
    }
    if(cost1<cost2){
        printf("%d",cost1);
    }else {
        printf("%d",cost2);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>l(m),r(m);
	for(int i=0;i<m;i++) { cin>>l[i]>>r[i]; }
	int min=1000000,max=0;
	for(int i=0;i<m;i++){
		if(r[i]<min) min=r[i];
		if(l[i]>max) max=l[i];
	}
	if(min-max+1>0) cout << min - max + 1<< endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr int MOD = 998244353;

void solve() {
    int n,s;
    cin >> n >> s;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    VI ru(n+1);
    REP(i,0,n) ru[i+1] = ru[i] + a[i];
    VVLL dp(n,VLL(3000+1));
    dp[0][a[0]] = 1;
    REP(i,1,n) {
        dp[i][a[i]] = i + 1;
        REP(j,0,3000+1) {
            dp[i][j] += dp[i-1][j];
            if (j >= a[i]) dp[i][j] = (dp[i][j] + dp[i-1][j - a[i]]) % MOD;
        }
    }
    LL ans = 0;
    REP(i,0,n) ans = (ans + dp[i][s]) % MOD;
    cout << ans << endl;

    return;

    REP(i,0,n) {
        REP(j,0,s+1) cout << dp[i][j] << " ";
        cout << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N = (int)S.size();
  char ch[N];
  
  for(int i = 0; i<N; i++)
    ch[i] = S[i];
  
  string answer = "Yes";
  
  int a = N/2;
  if(N%2==1)
    a = a+1;
  
  for(int i = 0;i<a-1; i++){
    if(ch[i]!=ch[N-i-1])
      answer = "No";
  }
  
  int b = a-1;
  char ch1[b];
  for(int i = 0; i<b; i++)
    ch1[i] = ch[i];
  
  
  
  int c = b/2;
  if(b%2==1)
    c = c+1;
  for(int i = 0;i<c-1; i++){
    if(ch1[i]!=ch1[b-i-1])
      answer = "No";
  }
  if(b==2)
    if((ch[0]!=ch[1]) || (ch[N-1]!=ch[N-2]))
      answer = "No";
  
  char ch2[b];
  for(int i = 0; i<b; i++)
    ch2[i] = ch[i+a];
 
  for(int i = 0;i<c-1; i++){
    if(ch2[i]!=ch2[b-i-1])
      answer = "No";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;

int a, b, h, m;
double hr, mr, dr;

int main() {
    scanf("%d%d%d%d", &a, &b, &h, &m);
    hr = M_PI / 180 * 360 * (60 * h + m) / (12 * 60);
    mr = M_PI / 180 * 360 * m / 60;
    dr = hr - mr;
    printf("%.13lf", sqrt(a * a + b * b - 2 * a * b * cos(dr)));
}


Measured memory_bytes: 2660
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int N=1e5+10;


int main(){
	jaldibazi;

	ll n ; cin >> n;
	string ans="";

	while(n>0){
		n--;
		ans += (char)( n%26 + 'a');
		n/=26;
	}
	reverse(all(ans));
	cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 3656
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

Measured memory_bytes: 8972
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

struct Trie {
  vector<pair<char, Trie *> > a;
  unsigned short ctr, ctr2;

  Trie() {
    ctr = 0;
    ctr2 = 0;
  }
  void insert(const char *s) {
    if (*s == '\0') {
      ctr++;
      ctr2++;
      return;
    }
    int k = *s - 'a';
    for (auto p : a) {
      if (k == p._1) {
        p._2->insert(s+1);
        ctr++;
        return;
      }
    }
    a.pb(make_pair(k, new Trie()));
    a.back()._2->insert(s+1);
    ctr++;
  }
  int find(const char *s) {
    if (*s == '\0') return ctr;
    int k = *s - 'a';
    for (auto p : a) {
      if (k == p._1) return p._2->find(s+1);
    }
    return 0;
  }

  int find2(const char *s) {
    if (*s == '\0') return ctr2;
    int k = *s - 'a';
    for (auto p : a) {
      if (k == p._1) return p._2->find2(s+1);
    }
    return 0;
  }
  void free() {
    for (auto p : a) {
      p._2->free();
      delete p._2;
    }
    a.clear();
  }
};

int N, Q;
Trie *fwd;
int A[50000];
string S[50000];

int f(string s) {
  return fwd->find(s.c_str());
}
int f2(string s) {
  return fwd->find2(s.c_str());
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  fwd = new Trie;
  rep(i, N) {
    cin >> S[i];
    fwd->insert(S[i].c_str());
  }
  vector< pair<int, string> > qs;
  rep(i, Q) {
    string s;
    cin >> s;
    if (s[0] != '*' && s[s.length()-1] != '*') {
      int pos = -1;
      rep(i, s.length()) {
        if (s[i] == '?') pos = i;
      }
      int sum = 0;
      if (pos != -1) {
        rep(ch, 26) {
          s[pos] = 'a'+ch;
          sum += f2(s);
        }
      }
      else {
        sum = f2(s);
      }
      A[i] = sum;
      continue;
    }
    bool flip = s[0] == '*';
    if (flip) {
      reverse(all(s));
      qs.pb(make_pair(i, s));
      continue;
    }
    assert(s.back()=='*');
    s.resize((int)s.size()-1);
    int pos = -1;
    rep(i, s.length()) {
      if (s[i] == '?') pos = i;
    }
    int sum = 0;
    if (pos != -1) {
      rep(ch, 26) {
        s[pos] = 'a'+ch;
        sum += f(s);
      }
    }
    else sum = f(s);
    A[i] = sum;
  }
  fwd->free();
  delete fwd;
  fwd = new Trie;
  rep(i, N) {
    reverse(all(S[i]));
    fwd->insert(S[i].c_str());
  }
  for (auto p : qs) {
    int i = p._1;
    string s = p._2;
    assert(s.back()=='*');
    s.resize((int)s.size()-1);
    int pos = -1;
    rep(i, s.length()) {
      if (s[i] == '?') pos = i;
    }
    int sum = 0;
    if (pos != -1) {
      rep(ch, 26) {
        s[pos] = 'a'+ch;
        sum += f(s);
      }
    }
    else sum = f(s);
    A[i] = sum;
  }
  rep(i, Q) cout << A[i] << "\n";
  return 0;
}

Measured memory_bytes: 228212
#include<stdio.h>
int m[1002][1002][3]={0};
int main(){
  int w,h,n,i,j,k,a,b,c,d;
  char s;
  scanf("%d %d %d\n",&h,&w,&n);
  for(i=1;i<=h;i++){
    for(j=1;j<=w+1;j++){
      scanf("%c",&s);
      if(s=='\n')continue;
      for(k=0;k<3;k++){
	m[i][j][k]+=m[i-1][j  ][k];
	m[i][j][k]+=m[i  ][j-1][k];
	m[i][j][k]-=m[i-1][j-1][k];
      }
      if(s=='J')m[i][j][0]++;
      if(s=='O')m[i][j][1]++;
      if(s=='I')m[i][j][2]++;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(j=0;j<3;j++){
     if(j)printf(" ");
     printf("%d",m[c][d][j]-m[c][b-1][j]-m[a-1][d][j]+m[a-1][b-1][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 12656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll m=1e9+7,n,k;
	ll dp[101][100001];
	ll arr[101];
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>arr[i];
	for(int i=0;i<101;i++)
	for(int j=0;j<100001;j++)
	dp[0][0]=1;
	for(int i=1;i<=k;i++)dp[0][i]=0;
	ll a[k+2];
	for(int i=1;i<=n;i++)
	{
		a[0]=0;
		for(int j=1;j<(k+2);j++)
		a[j]=(a[j-1]+dp[i-1][j-1])%m;
		for(int j=0;j<=k;j++)
		{
			dp[i][j]=0;
			dp[i][j]=(dp[i][j]+a[j+1])%m;
			dp[i][j]=(dp[i][j] - a[max((ll)0,j-arr[i])] + m)%m;
		}
	}
	cout<<dp[n][k];
}	

Measured memory_bytes: 79872
//sppsfver - 20.08.2020
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pll = pair <ll, ll>;
const int MAX = 1e5+5;
const ll MOD = 1e9+7;

ll n;
ll memo[2005];

ll dp (ll sisa){
	if (sisa < 0) return 0;
	if (sisa == 0) return 1;
	ll &ret = memo[sisa];
	if (ret != -1) return ret;
	ret = 0;
	for (ll i = sisa; i >= 3; i--){
		ret += dp (sisa-i);
		ret %= MOD;
	}
	return ret;
}

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

	cin >> n;
	memset (memo, -1, sizeof memo);
	cout << dp (n) << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, c, cnt=0, tmp=0;
    cin >> a >> b >> c;
    tmp=a;
    while(cnt<=100000){
        if(tmp%b==c){
            cout << "YES" <<endl;
            return 0;
        }
        cnt++;
        tmp=tmp+a;
    }
    cout << "NO" <<endl;
    return 0;
}

Measured memory_bytes: 256