akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

S = list(input().rstrip())
K = int(input())

L = len(S)

def main():
    if K >= L//2:
        ans = L
    else:
        dp = [[[0]*(K+1) for _ in range(L+1)] for _ in range(L+1)]

        ans = 0
        for ind in reversed(range(L)):
            # [0, ind), [ind, L-1]
            s = S[ind]
            for i in range(ind):
                for k in reversed(range(K+1)):
                    if S[i] == s:
                        dp[i+1][L-ind][k] = dp[i][L-ind-1][k] + 1
                    else:
                        dp[i+1][L-ind][k] = max(dp[i][L-ind][k], dp[i+1][L-ind-1][k])
                        dp[i+1][L-ind][k] = min(dp[i+1][L-ind][k], min(i+1, L-ind))
                        if k < K and dp[i+1][L-ind][k] == dp[i][L-ind-1][k]:
                            dp[i+1][L-ind][k+1] = max(dp[i+1][L-ind][k+1], dp[i+1][L-ind][k]+1)
                            dp[i+1][L-ind][k+1] = min(dp[i+1][L-ind][k+1], min(i+1, L-ind))
            for k in range(K+1):
                ans = max(ans, 2*dp[ind][L-ind][k])
                ans = max(ans, 2*dp[ind][L-ind-1][k] + 1)
            dp.pop()
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 174604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

char maze[1002][1002];
int visited[1002][1002];

bool is_in_field(int h, int w, pll now){
    if(now.first < 0 || now.first >= h){return false;}
    if(now.second < 0 || now.second >= w){return false;}
    return true;
}

void bfs(int h, int w){
    queue<pll> q;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(maze[i][j]=='#'){
                q.push({i,j});
                visited[i][j] = 0;
            }
        }
    }

    pll d[4] = {{1,0},{-1,0},{0,1},{0,-1}};
    while(!q.empty()){
        pll now = q.front();
        q.pop();

        for(int i = 0; i < 4; i++){
            pll next = {now.first + d[i].first, now.second + d[i].second};
            if(is_in_field(h, w, next)){
                char state = maze[next.first][next.second];
                if(state == '.'){
                    if(visited[next.first][next.second] == -1){
                        q.push(next);
                        visited[next.first][next.second] = visited[now.first][now.second] + 1;
                    }
                }
            }
        }
    }

    return;
}

int main(){
    int h, w, cnt = 0;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> maze[i][j];
            visited[i][j] = -1;
        }
    }
    bfs(h, w);
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, visited[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21556
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	x := 0
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			x += v[i] - c[i]
		}
	}
	fmt.Println(x)
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long long K;
    cin >> K;
    vector<long long> A;
    rep(i,9){
        A.push_back(i+1);
    }

    long long sz=9;
    for(int i=0; sz<K; ++i){
        long long tmp = A[i]*10 + A[i]%10;
        if(A[i]%10!=0){
            A.push_back(tmp-1);
            sz+=1;
        }
        A.push_back(tmp);
        sz+=1;
        if(A[i]%10!=9){
            A.push_back(tmp+1);
            sz+=1;
        }
    }
    cout << A[K-1] << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int n, m;
vector<pair<int, int>> seg(300000);
int l = 0;

void kousin(int i, int k){
    // i番目の値をkに更新
    int pointer = (1<<l)-1+i;
    seg.at(pointer) = make_pair(k, i);
    rp(salkj, 0, l){
        pointer = (pointer+1) / 2 - 1;
        seg.at(pointer) = max(seg.at(pointer*2+1), seg.at(pointer*2+2));
    }

}



int main(){
    cin >> n >> m;
    
    //セグ木の大きさを決める
    while(1<<l < n) l++;
    
    //入力を受けてセグ木を構成
    rp(i, 0, n){
        int a;
        scanf("%d", &a);
        kousin(i, a); 
    }

    //m回、クエリを実行
    //今回の場合クエリは、全範囲の中で最大のものの値を半分にする

    rp(i, 0, m){
        kousin(seg.at(0).second, seg.at(0).first/2);
    }
    
    
    ll ans = 0;

    rp(i, 0, n){
        ans += seg.at((1<<l)-1+i).first;
    }
    printf("%lld", ans);
    return 0;

}



Measured memory_bytes: 2560
import sys

n, m, *x = map(int, sys.stdin.read().split())

def main():
    x.sort()
    s = x[-1] - x[0]
    d = [0] + sorted([x[i+1] - x[i] for i in range(m-1)], reverse=True)
    for i in range(m-1):
        d[i+1] += d[i]
    
    return s - d[min(n, m)-1]

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  
  s.at(5) = ' ';
  s.at(13) = ' ';
  cout << s;
}

Measured memory_bytes: 3576
import java.util.Scanner;

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

	int n = scan.nextInt();
	int[] p = new int[n];
	int max = 0;
	int max_num = 0;
	for(int i = 0; i < n; i++){
	    p[i] = scan.nextInt();
	    if(max < p[i]){
		max = p[i];
		max_num = i;
	    }
	}

	p[max_num] = p[max_num] / 2;

	int sum = 0; 
	for(int i = 0; i < n; i++){
	    sum += p[i];
	}
	System.out.println(sum);
    }
}
		


Measured memory_bytes: 21588
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.ReadLine;

            // aabb
            var aa = Convert.ToInt32(s.Substring(0, 2));
            var bb = Convert.ToInt32(s.Substring(2, 2));

            var yymm = 0 < bb && bb <= 12;
            var mmyy = 0 < aa && aa <= 12;

            var ans = string.Empty;

            if (yymm && mmyy)
            {
                ans = "AMBIGUOUS";
            }
            else if (yymm)
            {
                ans = "YYMM";
            }
            else if (mmyy)
            {
                ans = "MMYY";
            }
            else
            {
                ans = "NA";
            }

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11348
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main(){
  int A,B,i,ans=0;
  scanf("%d%d",&A,&B);
  ans=MAX(A+B,A-B);
  ans=MAX(ans,A*B);

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


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

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		PriorityQueue<Integer> pqueue 
			= new PriorityQueue<Integer> (Collections.reverseOrder ());
		int N, M;
		long sum = 0;
		N = sc.nextInt ();
		M = sc.nextInt ();
		for (int i=0; i<N; i++) {
			int tmp = sc.nextInt ();
			pqueue.add ((Integer)tmp);
		}
		for (int i=0; i<M; i++) {
			int a = pqueue.poll ();
			pqueue.add ((Integer)(a/2));
		}
		for (Integer i: pqueue)
			sum += (int)i;
		System.out.println (sum);
	}
}

Measured memory_bytes: 60428
import Control.Applicative
import Data.Char (intToDigit)

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve [a, b]
  | a > b = replicate a $ intToDigit b
  | otherwise = replicate b $ intToDigit a


Measured memory_bytes: 508
#include<stdio.h>

int main(){
  int n, a[100], i, j, cnt=0, t, flag;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(a[j]<a[j-1]){
	t=a[j];
	a[j]=a[j-1];
	a[j-1]=t;
	cnt++;
      }
    }
  }
  
  for(i=0; i<n; i++){
    if(i==n-1){
      printf("%d\n", a[i]);
    }else{
      printf("%d ", a[i]);
    }
  }

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

Measured memory_bytes: 600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <stdio.h>

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

int main() {
  int n;
  cin >> n;
  int ac =0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  string a;
  rep(i,n) {
    cin >> a;
    if(a == "AC") ac++;
    else if(a == "WA") wa++;
    else if(a == "TLE") tle++;
    else if(a == "RE") re++;

  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3620
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では？
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap


heap = []  # ヒープといっても順序を工夫したただのリスト

q = PriorityQueue(heap)
q.push((-(A[0] + B[0] + C[0]), 0, 0, 0))

ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = q.pop()
    # print(heap_max)
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i + di, j + dj, k + dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        tmp = (-(A[i_new] + B[j_new] + C[k_new]), i_new, j_new, k_new)
        if tmp in q():  # ここが計算量がおおい
            continue
        q.push(tmp)


print(*ans, sep='\n')


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,i,n,s;
    cin>>a>>b;
    n=a*500;
    if(n>=b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0]*n
ac =0
wa = 0

for i in range(m):
    p,s =  map(str,input().split())
    p = int(p)
    if s == "AC" and a[p-1] !=-1:
        ac +=1
        wa += a[p-1]
        a[p-1] = -1
    elif s =="WA" and a[p-1] != -1:
        a[p-1] += 1
print(ac,wa)

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

using namespace std;

int main() {
    long long N;
    cin >> N;
    long long hp = 0;
    hp += 1000 * (N / 500);
    N -= (500 * (N / 500));
    hp += 5 * (N / 5);
    cout << hp << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    repf(i,0,n) cout<<s[i]<<t[i];
    cout<<endl;
}  

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

int main() {
  int s;
  cin >> s;
  
  //int count[1000000] = {};
  vector<int> count(1000000, 0);
  int prev, n = 0;
  
  while(true) {
    n++;
    if(n == 1) {
      prev = s;
      // cout << prev << " ";
      count[s]++;
    }else {
      if(prev % 2 == 0) {
        prev = prev/2;
        // cout << prev << " ";
        if(count[prev] == 1) break;
        else count[prev]++;
      }else {
        prev = 3*prev + 1;
        // cout << prev << " ";
        if(count[prev] == 1) break;
        else count[prev]++;
      }
    }
  }
  // cout << endl;
  cout << n << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find{
  vector<int> par,r;

  union_find(int n){
  	par.resize(n);
  	r.resize(n);
  	for(int i = 0; i < n; i++) par[i] = i,r[i] = 0;
  }

  int find(int x){
    if(par[x] == x) return x;
    else return find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(r[x] < r[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(r[x] == r[y]) r[x]++;
    }
  }

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

int main()
{
	int n,k,l;
	cin >> n >> k >> l;

	union_find road(n),train(n);
	for(int i = 0; i < k; i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		if(!road.same(a,b)) road.unite(a,b);
	}
	for(int i = 0; i < l; i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		if(!train.same(a,b)) train.unite(a,b);
	}

	vector<pair<int,int> > com(n);
	map<pair<int,int> ,int> s;
	for(int i = 0; i < n; i++){
		com[i].first = road.find(i);
		com[i].second =  train.find(i);
		s[com[i]]++;
	}

	for(int i = 0; i < n; i++){
		cout << s[com[i]];
		if(i!=n-1) cout << " ";
		else cout << endl;
	}

	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

vector<vector<int>> to;

int main() {
	int n, q;
	cin >> n >> q;
	to.resize(n);
	vector<ll> p(n, 0);
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,q) {
		int x, y;
		cin >> x >> y;
		x--;
		p[x] += y;
	}
 	queue<pii> que;
	auto push = [&](int prev, int a, int b) {
		if (prev == b) return;
		p[b] += p[a];
		que.push(pii(a, b));
	};
	que.push(pii(-1, 0));
	while (!que.empty()) {
		auto pr = que.front(); que.pop();
		int prev = pr.first;
		int cur = pr.second;
		for (int i = 0; i < to[cur].size(); i++) {
			push(prev, cur, to[cur][i]);
		}
	}

	rep(i,n) {
		if (i != 0) cout << " ";
		cout << p[i];
	}
	cout << endl;
}

Measured memory_bytes: 18136
#include <stdio.h>
#include <math.h>

main(){
  int n, i;
  double x1, y1, x2, y2, x3, y3, xp, yp, r;
  double a1, a2, b1, b2, c1, c2;

  scanf("%d", &n);
  
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
    a1=2*(x2-x1);
    a2=2*(x3-x1);
    b1=2*(y2-y1);
    b2=2*(y3-y1);
    c1=x1*x1-x2*x2+y1*y1-y2*y2;
    c2=x1*x1-x3*x3+y1*y1-y3*y3;
    xp=(b1*c2-b2*c1)/(a1*b2-a2*b1);
    yp=(c1*a2-c2*a1)/(a1*b2-a2*b1);
    printf("%.3f %.3f ", xp, yp);
    r=sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
    printf("%.3f\n", r);
  }
  return 0;
}

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

using namespace std;

const int MAXN = 17;

long long dp[(1<<MAXN)];

int main() {
    #ifdef BLAT
        freopen("input", "r", stdin);
    #endif

   	int n;
   	cin >> n;

   	vector< vector< int > > v(n + 1, vector< int > (n + 1));

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

   	for(int i = 0; i < n; ++i) {
   		for(int j = i + 1; j < n; ++j) {
   			for(int mask = 0; mask < (1<<n); ++mask) {
   				if((mask&(1<<i)) && (mask&(1<<j))) dp[mask] += v[i][j];
   			}
   		}
   	}

   	for(int mask = 0; mask < (1<<n); ++mask) {
   		for(int m = mask; m; --m &= mask) {
   			dp[mask] = max(dp[mask], dp[m] + dp[mask - m]);
   		}
   	} 

   	cout << dp[(1<<n) - 1] << '\n';
}   	

Measured memory_bytes: 768
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main(void){
 string  s;
 cin>> s;
 if(s=="ABC"){
   cout<< "ARC" <<endl;
}
  
  if(s=="ARC"){
  cout<<"ABC" <<endl;
  }
  return 0;
}

Measured memory_bytes: 3576
// 2121
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int t[100005];
 
int32_t main()
{
    fast;
    int n; cin >> n;
    For(i, 0, n) {
        cin >> t[i];
        //x[i] = t[i];
    }
    int m; cin >> m;
    For(i, 0, m) {
        int p, val, sum = 0; cin >> p >> val;
        For(i, 0, n) {
            sum += t[i];
            if(i == p-1) sum += (val - t[i]);
        }
        cout << sum << "\n";
        

    }

    
    
    
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 0) {
        int half = N / 2;
        string s1 = S.substr(0, half);
        string s2 = S.substr(half);
        if (s1 == s2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)
typedef pair<ll, int> PLI;

int main(void){
	int n,a[123],i,bob=0,alice=0;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
		bob += a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(i=0; i<n; i+=2){
		alice += a[i];
	}
	bob -= alice;
	cout << (alice-bob) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{


long long int a,b,ans;
cin>>a>>b;
if(b==1)
cout<<0<<endl;

else if((b-a)<=0)
cout<<1<<endl;

else
{

 ans=(b-a)/(a-1);

 if((b-a)%(a-1)!=0)
  ans++;

  cout<<1+ans<<endl;

}

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    ll N, D;
    cin >> N >> D;

    ll X[N];
    ll Y[N];
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        double dist = pow(pow(X[i],2) + pow(Y[i],2), 0.5);
        if(dist <= D){
            ans++;
        }
    }

    cout << ans << endl;
}

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

def proc():
    count = 0
    m = 0

    data = [M*n for n in range(N)]
    for i in range(M):
        if K in data:
            return True
        data = [x + N - 2 * idx for idx, x in enumerate(data)]
    if K in data:
        return True
    return False

print('Yes' if proc() else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 998244353
int red[MAX],green[MAX],normal[MAX];
int main()
{
    FILE *input=stdin;
    //input=fopen("in.txt","r");
    int t,T=1;
    //fscanf(input,"%d",&T);
    for(t=1; t<=T; t++)
    {
        int A,B,C,i,j,X,Y,k;
        fscanf(input,"%d %d %d %d %d",&X,&Y,&A,&B,&C);
        for(i=0;i<A;i++)
        {
            fscanf(input,"%d",&red[i]);
        }
        for(i=0;i<B;i++)
        {
            fscanf(input,"%d",&green[i]);
        }
        for(i=0;i<C;i++)
        {
            fscanf(input,"%d",&normal[i]);
        }
        sort(red,red+A);
        sort(green,green+B);
        sort(normal,normal+C);
        priority_queue<int> pq;
        long long int sum=0;
        for(i=0;i<X&&i<A;i++)
        {
            sum=sum+red[A-1-i];
            pq.push(-red[A-1-i]);
        }
        for(i=0;i<Y&&i<B;i++)
        {
            sum=sum+green[B-1-i];
            pq.push(-green[B-1-i]);
        }
        for(i=0;i<C&&(!pq.empty());i++)
        {
            int mm=-pq.top();
            if(normal[C-1-i]>mm)
            {
                pq.pop();
                sum=sum+normal[C-1-i]-mm;
            }
            else
            {
                break;
            }
        }
        printf("%lld",sum);
        if(t!=T) printf("\n");
    }
    fclose(input);
    return 0;
}


Measured memory_bytes: 2552
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
/*[a]+1 ガウス+1*/
ll p_gauss(ld a){ll b=a;return a==b?b:p_gauss(b+1);}

int main(void){
    ll n,k,i,ans=0,one;
    scanf("%lld%lld",&n,&k);
    ll a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]==1) one=i+1;
    }
    ans=p_gauss((ld) (n-1)/(k-1)) ;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef long ELEM;

#define STACK_SIZE 200	//

ELEM stack[STACK_SIZE];
int n;
	
void init(){
	n=0;
}

void push(ELEM x){
	if(n >= STACK_SIZE) fprintf(stderr,"stack overflow\n");
	stack[n++]=x;
}

ELEM pop(){
	if(n <= 0) fprintf(stderr,"stack underflow\n");
	return stack[--n];
}

int empty(){
	return n==0;
}

int main(void){
	int c;
	long x,a,b;

	init();
	while((c=getchar())!=EOF){
		if(isdigit(c)){
			ungetc(c,stdin);
			scanf("%ld",&x);
			push(x);
		}else{
			switch(c){
				case '+':
					b=pop();
					a=pop();
					push(a+b);
					break;
				case '-':
					b=pop();
					a=pop();
					push(a-b);
					break;
				case '*':
					b=pop();
					a=pop();
					push(a*b);
					break;
				case '\n':
					if(!empty())
						printf("%ld\n",pop());
					init();
					break;
				case ' ':
				case '\t':
					break;
				default:
//					printf("Invalid input %c\n", c);
					break;

			}
		}
	}

//	printf("%ld",pop());

	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		
		if (r < 1200){
			System.out.println("ABC");
		}
		else if (r < 2800){
			System.out.println("ARC");
		}
		else {
			System.out.println("AGC");
		}
	}
}



Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
 
int n,i,j,k,a[401];
long long d[401][401],s[401];

 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		s[i] = s[i-1]+a[i];
	}
	
	memset(d,0x7f,sizeof d);
	
	for(j=1;j<=n;j++){
		d[j][j] = 0;
		for(i=j-1;i>0;i--){
			for(k=i+1;k<=j;k++){
				d[i][j] = min(d[i][j], d[i][k-1]+d[k][j]);
			}
			d[i][j] += s[j] - s[i-1];
		}
	}
	
	cout<<d[1][n];
	
	return 0;
}


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

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

    int a;
    // 引数の受け取り
    //
    cin >> a ;
    
    cout << "ABC" << a << endl;
    

    // 出力
    return 0;
}



Measured memory_bytes: 256
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end = '')
			else:
				print(".", end = '')
		print()
	print()


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

int W,H;
int map[51][51];

void fillmap(int i,int j,int s){
     if(map[i][j]!=0)return;
     map[i][j]=s;
     for(int x=i-1;x<i+2;x++){
	  for(int y=j-1;y<j+2;y++){
	       if(!(y>=W||y<0||x>=H||x<0)) fillmap(x,y,s);
	  }
     }
}
    
int main(){
     while(cin>>W>>H,W||H){
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W;j++){
		    int temp;
		    cin>>temp;
		    if(temp)map[i][j]=0;
		    else map[i][j]=-1;
	       }
	  }
	  int s=0;
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W;j++){
		    if(map[i][j]==0){
			 fillmap(i,j,++s);
		    }
	       }
	  }
	  cout<<s<<endl;
     }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

ll dp[20000000];
ll prime[20000350];

ll factorize(ll x) {
	ll res = 1;
	while (x > 1) {
		ll cou = 0;
		ll m = prime[x];
		while (x % m == 0) {
			cou ++;
			x /= m;
		}
		res *= (cou + 1);
	}/*
	for(auto it : ans) {
		res *= (it.s + 1);
	}*/
	return res;
}

void PRIME() {
	for (ll i = 0; i <= 10000000; i++) {
		prime[i] = i;
	}

	for (ll i = 4; i <= 10000000; i += 2) {
		prime[i] = 2;
	}

	for (ll i = 3; i <= 10000000; i += 2) {
		if (prime[i] == i) {
			for (ll j = i * i; j <= 10000000; j += i) {
				if (prime[j] == j) prime[j] = i;
			}
		}
	}
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	ll sum = 0;
	for(ll i=1;i<=n;i++) {
		sum += i * factorize(i);
	}
	cout<<sum;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	PRIME();
	while(T--) {		
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 81732
N = int(input())
c = 0
flag = False
for i in range(N):
  x,y = map(int, input().split())
  if x == y:
    c += 1
    if c == 3:
      flag = True
  else:
    c = 0

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    vector<ll> C(N+1);
    ll sum = 0;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        C[i+1] = C[i] + a;
        sum += a;
    }
    
    ll mn = 1LL << 60;
    for(int i=1; i<N; i++){
        mn = min(mn, abs(C[i]-(sum-C[i])));
    }
    
    cout << mn << endl;
    return 0;
}



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

int main()
{
	int N;
	cin >> N;
	vector <int> S;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int s;
		cin >> s;
		S.push_back(s);
		ans += s;
	}
	sort(S.begin(), S.end());

	if ((ans%10) == 0) {
		for (int i = 0; i < N; i++) {
			if (S[i]%10 > 0) {
				ans -= S[i];
				break;
			}
		}
	}
	if ((ans%10) > 0) {
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) {
			break;
		}

		vector<pair<int, int> > a(m);
		for (int i = 0; i < m; ++i) {
			a[i].first = i + 1;
		}
		for (int i = 0; i < n; ++i) {
			for (auto& temp : a) {
				int b;
				cin >> b;
				if (b != 0) {
					++temp.second;
				}
			}
		}
		struct func {
			bool operator()(pair<int, int> x, pair<int, int> y) {
				return x.second > y.second;
			}
		};

		stable_sort(a.begin(), a.end(), func());

		for (auto it = a.begin(); it != a.end(); ++it) {
			if (it != a.begin()) {
				cout << " ";
			}
			cout << it->first;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll T[N],A[N];
  cin>>T[0]>>A[0];
  
  ll t=T[0],a=A[0];
  RREP(i,N-1){
    cin>>T[i]>>A[i];
    ll mx=max((t-1)/T[i],(a-1)/A[i])+1;
    t=T[i]*mx,a=A[i]*mx;
  }
  
  cout<<t+a<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	string S;
	cin >> S;

	auto a = 0;
	auto b = 1;

	auto countA = 0;
	auto countB = 0;

	for (auto i = 0; i < S.length(); ++i)
	{
		auto s = S[i] - '0';
		if (a != s)
		{
			++countA;
		}
		if (b != s)
		{
			++countB;
		}
		
		a = a ^ 1;
		b = b ^ 1;
	}

	cout << min(countA, countB) << endl;

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
    char s[101], p[101];
    int i, j, k, m, n=0;
    int check = 0;
    for(i=0;;i++){
        scanf("%c", &s[i]);
        if(s[i] == '\n'){
            break;
        }
    }

    for(j=0;;j++){
        scanf("%c", &p[j]);
        if(p[j] == '\n'){
            break;
        }
    }
    
    for(k=0;k<i;k++){
        if(s[k] == p[0]){
            if(j == 1){
                check = 1;
                break;
            }
            n = k;
            for(m=1;m<j;m++){
                n++;
                if(n == i){
                    n = 0;
                }
                if(s[n] != p[m]){
                    check = 0;
                    break;
                }
                check = 1;
            }
            if(check == 1){
                break;
            }
        }
    }
    
    if(check == 0){
        printf("No\n");
    }
    else if (check == 1){
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;
const int INF = 1<<30;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,m;
vector<int> s,t;
mint dp[2100][2100];

int main(){
  cin >> n >> m;
  rep(i,n){
    int tmp; cin >> tmp;
    s.push_back(tmp);
  }
  rep(i,m){
    int tmp; cin >> tmp;
    t.push_back(tmp);
  }
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  rep(i,n+1)rep(j,m+1){
    if(i-1>= 0 && j-1 >= 0 && s[i-1] == t[j-1]) dp[i][j] += dp[i-1][j-1];
    if(i-1>= 0) dp[i][j] += dp[i-1][j];
    if(j-1>= 0) dp[i][j] += dp[i][j-1];
    if(i-1>= 0 && j-1 >= 0) dp[i][j] -= dp[i-1][j-1];
  }

  cout << dp[n][m] << endl;
  return 0;
}

Measured memory_bytes: 34816
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <string.h>
#include <math.h>
#define pi 3.1415926535

using namespace std;

int main(){
	double a, b, C;
	cin >> a >> b >> C;
	
	double S, L, h;
	double rad = (2.0*pi) / (360/C);
	S = 0.5 * a * b * sin(rad);
	double c = sqrt( (b*b) + (a*a) - (2*b*a*cos(rad)) );
	L = a+b+c;
	h = 2*S / a;
	
	printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);
	
}



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

int main() {
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H)cin>>S[i];
	rep(i,H){
		rep(j,W){
			if(S[i][j] == '.'){
				S[i][j]='0';
				for (int dx = -1; dx <= 1; ++dx){
					for (int dy = -1; dy <= 1; ++dy){
						int nx = i+dx,ny = j+dy;
						if(0<=nx&&nx<H&&0<=ny&&ny<W){
							if(S[nx][ny]=='#')S[i][j]++;
						}
						
					}
					
				}
			}
		}
	}
	rep(i,H)cout<<S[i]<<endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  beginner20200426
//
//  Created by zer0 on 2020/04/26.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    int s, w;
    std::string str;
    std::cin >> s >> w;
    
    if(w>=s){
        str="unsafe";
    }else{
        str="safe";
    }
    
    // insert code here...
    std::cout << str;
    return 0;
}


Measured memory_bytes: 3592
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <random>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int z=0,x=0;
	if (a == 7)x++;
	if (b == 7)x++;
	if (c == 7)x++;
	if (a == 5)z++;
	if (b == 5)z++;
	if (c == 5)z++;

	if (x == 1 && z == 2)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-12
#define M_PI 3.141592653589793
#define bs 1000000007

#define ldouble long double

using namespace std;

long long INF = 1e9;
const int N = 300031;

long long n,m,s,p[N],dir[N],ra[N],ans[N];

bool cmp(long long x, long long y)
{
	return p[x]<p[y];
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n>>m>>s;

	for (int i=0;i<n;i++)
	{
		cin>>p[i];
		ra[i]=i;
		cin>>dir[i];
//		dir[i]=2-dir[i];
		if (dir[i]==2)
			dir[i]=-1;
	}
	sort(ra,ra+n,cmp);

	int t=0;
	for (int i=0;i<n;i++)
	{
		if (dir[i]==1)
			t+=(p[i]+s)/m%n;
		else
			t+=(p[i]-s-m+1)/m%n;

		t=(t%n+n)%n;
		p[i]=p[i]+s%m*dir[i];
		p[i]=(p[i]%m+m)%m;
	}

//	cout<<t<<endl;

	sort(p,p+n);
	for (int i=0;i<n;i++)
	{
		ans[ra[(i+n-t)%n]]=p[i];
	}

	for (int i=0;i<n;i++)
	{
		cout<<ans[i]<<"\n";
	}
	cout<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 8192
# String Rotation

def main():
    s1 = input()
    s2 = input()

    _s = s2

    for i in range(len(s1)):
        if s1 == _s:
            print("Yes")
            return
        else:
            _s = rotate(_s)
    print("No")
    return

def rotate(arr):
    return arr[-1] + arr[:-1]


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int gcd();
int gcd2();

int main(){
    int K;
    scanf("%d",&K);
    long sum=0;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                sum +=gcd(a,b,c);
            }
        }
    }
    printf("%ld",sum);
}

int gcd(int a,int b,int c){
   return gcd2(gcd2(a,b),c);
}

int gcd2(int a,int b){
    if(a%b==0){
        return b;
    }else{
        return gcd2(b,a%b);
    }
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;

int main() {
  long long x,a,b;
  cin >> x >> a >> b;
  if(b-a <= 0) {
    cout << "delicious" << endl;
  }else if(b-a <= x) {
    cout << "safe" << endl;
  }else {
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 256