akhauriyash/Code-Regression huggingface dataset:
// AOJ 0581: Gifts
// 2018.1.3 bal4u@uu

#include <stdio.h>
#include <ctype.h>
#include <string.h>

int H, W, K;
char map[52][52];
int memo[1<<12][4][50][50];
int mask;
int mv[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};

int calc(int b, int lu, int r, int c)
{
	int i, k, pr, pc, nr, nc, f, ans;
	
	if (memo[b][lu][r][c] != -1) return memo[b][lu][r][c];
	if (lu == 0 && r == H-1 && c == W-1) return 0;

	k = K<<1, pr = r, pc = c, f = 0;
	for (i = 0; i < k; i++) {
		pr += -mv[(b>>(i<<1)) & 3][0];
		pc += -mv[(b>>(i<<1)) & 3][1];
		if (pr == r && pc == c) { f = 1; break; }
	}
	if (!f && isdigit(map[r][c])) k = map[r][c] & 0xf; else k = 0;

	ans = -1000;
	for (i = 0; i < 4; i++) {
		if (lu == 0 && i >= 2) break;
		nr = r + mv[i][0], nc = c + mv[i][1];
		if (nr >= 0 && nr < H && nc >= 0 && nc < W && map[nr][nc] != '#') {
			int x = calc(((b << 2) | i) & mask, lu - (i >= 2), nr, nc) + k;
			if (ans < x) ans = x;
		}
	}
	return memo[b][lu][r][c] = ans;
}

int main()
{
	int r, ans;
	
	scanf("%d%d%d", &H, &W, &K);
	mask = (1<<(K<<2)) - 1;
	memset(memo, -1, sizeof(memo));
	for (r = 0; r < H; r++) scanf("%s", map[r]);
	ans = calc(0, K, 0, 0);	if (ans < 0) ans = 0;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 161744
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a > b)
                Console.WriteLine(a + a - 1);
            if (b > a)
                Console.WriteLine(b + b - 1);
            if (a == b)
                Console.WriteLine(a + b);
        }
    }
}

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

int main(){
  int N; cin >> N;
  vector<int> A(N+2);
  for(int i=1;i<=N;++i) cin >> A.at(i);
  int sum=0;
  for(int i=0;i<N+1;++i){
    sum+=abs(A.at(i)-A.at(i+1));
  }
  for(int i=1;i<=N;++i){
    int mi=abs(A.at(i-1)-A.at(i)) + abs(A.at(i) - A.at(i+1));
    int pl=abs(A.at(i-1)-A.at(i+1));
    cout << sum - mi + pl<< endl;
  }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
ull dp[100][21];
int main(){
      int n;
      int a[100];
      cin>>n;
      REP(i,n)cin>>a[i];
      REP(i,n){
            if(i==0)dp[0][a[i]]=1;
            else{
                  REP(j,21){
                        if(dp[i-1][j]==0)continue;
                        if(j+a[i]<=20)dp[i][j+a[i]]+=dp[i-1][j];
                        if(j-a[i]>=0)dp[i][j-a[i]]+=dp[i-1][j];
                  }
            }
      }
//      REP(i,n)REP(j,21)printf("%llu%c",dp[i][j],j==20?'\n':' ');
      cout<<dp[n-1][0]<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

using P = pair<ll, ll>;

int main(void){
  ll H, W, M;
  cin >> H >> W >> M;
  vector<ll> h(M), w(M);
  map<P, ll> mp;
  REP(i, M){
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    mp[P(h[i], w[i])]++;
  }
  vector<ll> a(H, 0), b(W, 0);
  REP(i, M) a[h[i]]++, b[w[i]]++;

  ll c = *max_element(ALL(a));
  ll d = *max_element(ALL(b));
  vector<ll> p, q;
  REP(i, H) if(a[i] == c) p.emplace_back(i);
  REP(i, W) if(b[i] == d) q.emplace_back(i);
  
  ll n = p.size(), m = q.size();
  ll ans = c+d-1;
  REP(i, n) REP(j, m){
    if(mp[P(p[i], q[j])] == 0){
      ans = c+d;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 54728
n, k = map(int, input().split())
d = list(input().split())
dis = False
while True:
  a = str(n)
  hate = False
  for x in a:
    for y in d:
      if x == y:
        hate = True
        break
    if hate == True:
      break
  if hate == True:
    n += 1
  else:
    break
  if n > 100000:
    break
print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
    int A[5]; rep(i,5) cin >> A[i];
    int B[5];
    int maxWait=0;
    int num=0;
    int res=0;
    rep(i,5){
        int wait=10-A[i]%10;
        if(wait!=10)B[i] = A[i]+wait;
        else B[i]=A[i];
        if(wait!=10 && wait>maxWait){
            maxWait=wait;
            num=i;
        }
    }
    rep(i,5){
        if(i==num)continue;
        res+=B[i];
    }
    cout << res + A[num] <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#define ll long long

using namespace std;

int MOD = 998244353;
ll int n, a, b, k;
ll int fak[500010];

ll int put (ll int x, ll int y) {
	x*=y;
	return x%MOD;
}

ll int pot (ll int x, int p) {
	if (p == 0) {
		return 1;
	}
	if (p == 1) {
		return x;
	}
	if (p%2 == 0) {
		ll int y = pot(x, p/2);
		return put(y, y);
	}
	return put(pot(x, p-1), x);
}

ll int divajd (ll int x, ll int y) {
	y = pot(y, MOD-2);
	x*=y;
	return x%MOD;
}

ll int povrh (int x) {
	return divajd(fak[n], put(fak[n - x], fak[x]));
}

int main() {
	
	cin >>n >>a >>b >>k;
	
	fak[0] = 1;
	for (int i=1; i<n+1; i++) {
		fak[i] = put(fak[i-1], i);
	}
	
	ll int br = 0;
	for (int i=0; i<n+1; i++) {
		if ((k-i*a)%b == 0 && (k-i*a)/b <= n) {
            int B = (k-i*a)/b;
            if (B >= 0) {
                int A = i;
                br+=put(povrh(A), povrh(B));	
            }
		}
	}
	cout <<br%MOD;
				
	return 0;
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        int c = Integer.parseInt(scanner.next());
        scanner.close();

        int[] arr = {a, b, c};

        Arrays.sort(arr);

        System.out.println(arr[0] + arr[1]);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  if(a+b*5+c*10+d*50+e*100+f*500>=1000)cout<<"1"<<endl;
  else cout<<"0"<<endl;
  return 0;
}

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

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

Measured memory_bytes: 4840
fun main(args: Array<String>) {
    val S = readLine()!!.toMutableList()
    val size = S.size
    var i = 0
    while (true) {
        if (S.size <= i + 1) {
            break
        }
        if (S[i] != S[i + 1]) {
            S.removeAt(i)
            S.removeAt(i)
            if (i != 0) {
                i -= 1
            }
        } else {
            i++
        }
    }
    println(size - S.size)
}

Measured memory_bytes: 34412
#include <stdio.h>
#include <string.h>
 
long long int miin(long long int a,long long int b,long long int n){
  long long int i,x,s=-1;
  if(a%n==0){
    return a;
  }else{
    x=a + n - a%n;
    if(x <= b){
      return x;
    }else{
      return s;
    }
  }
}
 
long long int maax(long long int a,long long int b,long long int n){
  long long int i,x,s=-1;
  if(b%n==0){
    return b;
  }else{
    x=b - b%n;
    if(x >= a){
      return x;
    }else{
      return s;
    }
  }
}
 
long long int main(){
  long long int k,i,j;
  scanf("%ld",&k);
  long long int a[k];
  for(i=0;i<k;i++){
    scanf("%ld",&a[i]);
  }
  long long int min,max;
  if(a[k-1]!=2){
    printf("-1\n");
  }else{
    min = 2;
    max = 3;
    for(j=k;j>=2;j--){
      min = miin(min,max,a[j-2]);
      max = maax(min,max,a[j-2]) + a[j-2] - 1;
      if(min == -1){
        j = -1;
      }
    }
    if(min==-1 || max == -1){
      printf("%ld\n",min);
    }else{
      printf("%ld %ld\n",min,max);
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

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

  string year = S.substr(0, 4);
  string month = S.substr(5, 2);
  string day = S.substr(8, 2);

  auto F = [] (string year, string month, string day) {
      if (year < "2019") {
          return false;
      }
      if (year == "2019" && month < "04") {
          return false;
      }
      if (year == "2019" && month == "04" && day <= "30") {
          return false;
      }
      return true;
  };

  if (F(year, month, day)) {
      cout << "TBD" << endl;
  } else {
      cout << "Heisei" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	ll n,cnt=0;
	cin >> n;
	cnt = sqrt(n);
	while (n % cnt != 0)cnt--;
	cout << abs(1 - (n / cnt)) + abs(1 - cnt) << endl;
}


Measured memory_bytes: 256
#if 0
以前の反省を踏まえて、idの扱いを早いうちに決めてよかった
#endif

#include <iostream>
#include <vector>
using namespace std;

int curtime = 0, INF = 10000 * 100000 + 100;
struct result
{
    int reach_time;
    int back_time;
};
result res[110];
struct nodeData
{
    int id;
    vector<int> nodes;
};
vector<nodeData> dataSet;

// idはは1から
// for文は1から回す
vector<int> getNodes(int id)
{
    return dataSet[id - 1].nodes;
}

void dfs(int cur)
{
    // curの訪問時刻を記録
    curtime += 1;
    res[cur].reach_time = curtime;
    vector<int> nodes = getNodes(cur);
    for (int i = 0; i < nodes.size(); i++)
    {
        int node = nodes[i];
        if (res[node].reach_time == INF)
        {
            // 未訪問の場合
            dfs(node);
        }
    }
    curtime += 1;
    res[cur].back_time = curtime;
}

int main()
{
    // 初期化
    int /* 頂点数 */ n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        nodeData temp;
        temp.id = i;
        int id, /* 出次数 */ appear;
        cin >> id >> appear;
        for (int j = 1; j <= appear; j++)
        {
            int node;
            cin >> node;
            temp.nodes.push_back(node);
        }
        dataSet.push_back(temp);
        res[i].reach_time = INF;
    }

    // 処理
    for (int i = 1; i <= n; i++)
    {
        if (res[i].reach_time == INF)
        {
            dfs(i);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << i << " " << res[i].reach_time << " " << res[i].back_time << endl;
    }
}



Measured memory_bytes: 3152
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt();
		}
		int total = 0;
		for (int i = 0; i < arr.length; i++) {
			for (int j = i+1; j < arr.length; j++) {
				total += arr[i]*arr[j];
			}
		}
		System.out.println(total);
		bw.close();
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  int n, q;
  cin >> n >> q;
  string a;
  cin >> a;
  vector<int> ll(q);
  vector<int> rr(q);
  r(i, q)
  {
    cin >> ll[i] >> rr[i];
  }
  int offset = 0;
  int count = 0;
  vector<int> startP;
  vector<int> foo(n,0);
  // while (a.find("AC", offset) != string::npos)
  // {
  //   count++;
  //   startP.push_back(a.find("AC", offset));
  //   offset += 2;
  // }

  r(i,n){
    if (i>0 && a[i]=='C' && a[i-1]=='A') {
      foo[i] = foo[i-1] + 1;
    }else{
      if (i==0) {
        foo[i] = 0;
      }else{
        foo[i] = foo[i-1];
      }
    }
  }
  r(i,q){
    cout << foo[rr[i]-1] - foo[ll[i]-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 2256
$N, $A, $B, $C = gets.split.map(&:to_i)

$l=[]
$N.times do |i|
  $l[i] = gets.to_i
end

def dfs(depth,a,b,c)
  if depth == $N
    if a !=0 && b!=0 && c!=0
      ($A-a).abs + ($B-b).abs + ($C-c).abs - 30
    else
      Float::INFINITY
    end
  else
    return [
      dfs(depth+1,a,b,c),
      dfs(depth+1,a+$l[depth],b,c) + 10,
      dfs(depth+1,a, b+$l[depth],c) + 10,
      dfs(depth+1,a,b,c+$l[depth]) + 10
    ].min
  end
end

puts dfs(0,0,0,0)


Measured memory_bytes: 3836
N = int(input())
A = list(map(int, input().split(' ')))

sum_left, sum_right = 0, sum(A)
min_diff = sum_right

for i in range(N):
    sum_left += A[i]
    sum_right -= A[i]
    #print(sum_left, sum_right)
    if min_diff < abs(sum_right - sum_left):
        break
    min_diff = abs(sum_right - sum_left)
print(min_diff)

Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	set<int> s;
	rep(i,0,3){
		int a; cin>>a;
		s.insert(a);
	}
	cout<<s.size();
	
	
	return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  str <- BS.unpack <$> BS.getLine
  print $ solve str (reverse str) `div` 2

solve :: String -> String -> Int
solve [] [] = 0
solve (a:xa) (b:xb)
  | a /= b = 1 + solve xa xb
  | otherwise = solve xa xb


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

int N, X;
vector<int> arr;

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

    if(X == 1 || X == 2*N - 1) {
        printf("No");
        return 0;
    }
    printf("Yes\n");

    arr.resize(2*N - 1);

    arr[N - 1] = X;

    int pos = 1;
    for(int i = N - 2; i >= 0; i--) {
        arr[i] = pos++;
        if(pos == X) pos++;
    }
    for(int i = 2*N - 2; i >= N; i--) {
        arr[i] = pos++;
        if(pos == X) pos++;
    }

    for(int i = 0; i < 2*N - 1; i++) {
        printf("%d\n", arr[i]);
    }
}


Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int n=sc.nextInt();
		int[] wArr=new int[w];
		for(int i=0;i<w;i++){
			wArr[i]=i+1;
		}
		for(int i=0;i<n;i++){
			String[] ab=sc.next().split(",");
			int a=Integer.parseInt(ab[0])-1;
			int b=Integer.parseInt(ab[1])-1;
			int box=wArr[a];
			wArr[a]=wArr[b];
			wArr[b]=box;
		}
		for(int i=0;i<w;i++){
			System.out.println(wArr[i]);
		}
	}
}

Measured memory_bytes: 17196
#include <iostream>
#include <stdlib.h>

using namespace std;

int k, x;

int main(void)
{
	cin >> k >> x;
	for(int i = -1000000; i <= 1000000; i++){
		if(abs(i-x) <= k-1) cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	s := sc.nextInt()
	set := make(map[int]bool)
	ans := 1
	set[s] = true
	for {
		ans++
		s = f(s)
		if set[s] {
			fmt.Println(ans)
			return
		}
		set[s] = true
	}
	return
}

func f(n int) int {
	if n%2 == 0 {
		return n / 2
	} else {
		return 3*n + 1
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <map>
#include <vector>
using namespace std;


int n;
vector<long long> A;

map<pair<long long,long long>, long long> M;

const long long INF=1000000000000000000ll;

long long rec(int i,int j,long long a,long long b)
{
  if(i+1==j){
    return A[i]*a;
  }
  auto it=M.find(make_pair(i+n*a,j+n*b));
  if(it!=M.end()){
    return it->second;
  }
  long long ret=INF;
  for(int k=i+1;k<j;k++){
    ret=min(ret,rec(i,k,a,a+b)+rec(k,j,a+b,b));
  }
  M[make_pair(i+n*a,j+n*b)]=ret;
  return ret;
}

int main()
{
  scanf("%d",&n);
  A=vector<long long>(n);
  for(int i=0;i<n;i++){
    scanf("%lld",&A[i]);
  }
  printf("%lld\n",rec(0,n-1,1,1)+A[n-1]);
  return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void) {

	ll d, n;
	cin >> d >> n;

	cout << (ll)pow(100, d) * n + (n == 100 ? (ll)pow(100, d) : 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  int sum = 0;
  int i;
  for (i = 1; sum < N; i++) {
    sum += i;
  }
  for(int j = i - 1; j >= 1; j--) {
    if (N >= j) {
      N -= j;
      cout << j << endl;
    }
  }

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


std::vector<ull> prime;

void initprime(ull MAX) {
    std::vector<bool> is_prime(MAX + 1);
    for (int i = 0; i <= MAX; ++i) is_prime[i] = true;
    for (int i = 2; i <= MAX; ++i) {
        if (is_prime[i]) {
            int loop = (MAX / i);
            for (int j = 2; j <= loop; ++j) {
                is_prime[i * j] = false;
            }
            prime.emplace_back(i);
        }
    }
}

//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == (T)0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
ll gcd2(ll x, ll y) { return y ? gcd2(y, x % y) : x; }
//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

ull p_cnt(ull g) {
    if (g == 1) return 1;
    ull rootg = floor(sqrt((double)g));
    ull p_cnt = 1;
    for (int i = 0; i < prime.size(); ++i) {
        if (g % prime[i] == 0) {
            ++p_cnt;
        }
    }
    if (p_cnt == 1) ++p_cnt;
    return p_cnt;
}

int main() {
    initprime(1000000);
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;

    ll C = 100000000;
    for (ll i = 1; i <= C; ++i) {
        for (ll j = i; j <= C; ++j) {
            ull a = gcd(i,j);
            ull b = gcd2(i,j);
            if (a != b)
            {
                cout << i << "::" << a << "::" << b << endl;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
 
int main(){
  int n,m,i;
  int sum=0;
  int count=0;
  scanf("%d %d",&n,&m);
  int a[n];
  
  for(i=0;i<n;i++){
    scanf("%d ",&a[i]);
    sum += a[i];
  }
  
  for(i=0;i<n;i++){
    if(a[i]*4*m>= sum)
      count++;
  }
  
  if(count>=m)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int k;

int main(void){
	scanf("%d%d",&n,&k);
	string s;
	cin >> s;
	s[k-1]+=('a'-'A');
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str;
    while(true){
    try{
      String line = reader.readLine();
      str = line;
      if (str == "-") {
        break;
      }
      line = reader.readLine();
      a = Integer.parseInt(line);
    }catch(Exception e){
      str = "";
      break;
    }


    for(j = 0;j < a; j++){
      try{
      String line2 = reader.readLine();
      c = Integer.parseInt(line2);
      }catch(Exception e){
        c = 0;
        break;
      }
      String str1 = str.substring(0,c);
      String str2 = str.substring(c);
      str = str2 + str1;

    }

    System.out.println(str);

  }
}
}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
<?php
$n=trim(fgets(STDIN));
$c=0;
for($i=0;$i<$n;$i++){
  if(isPn(trim(fgets(STDIN)))) ++$c;
}
print $c;

function isPn($n){
  if($n<2) return 0;
  if($n==2) return 1;
  if($n%2==0) return 0;
  $max=floor(sqrt($n));
  for($i=3;$i<=$max;$i+=2) if($n%$i==0) return 0;
  return 1;
}
?>

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

using ll = long long;
using P = pair<int, int>;

const ll INF = 1e18;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll L, R;
  cin >> L >> R;

  if (R - L >= 2019) {
    cout << 0 << endl;
  } else {
    ll ans = INF;
    for (ll i = L; i <= R; i++) {
      for (ll j = i + 1; j <= R; j++) {
        ans = min(ans, i * j % 2019);
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    while (cin >> a >> b, a != 0 || b != 0)
    {
        for (int i = 0; i < a; ++i)
        {
            for (int j = 0; j < b; ++j)
            {
                cout << ((i + j) % 2 == 0 ? '#' : '.');
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    int n;
    scanf("%d", &n);

    vector<int> seq;
    for (int i = 0; i < n; i++)
        seq.push_back(i);

    vector<ii> pt;
    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);

        pt.push_back({x, y});
    }

    int total = 0;
    double sum = 0;
    do {
        total++;
        double tmp = 0;
        for (int i = 1; i < n; i++) {
            int dx = pt[seq[i]].first - pt[seq[i - 1]].first;
            int dy = pt[seq[i]].second - pt[seq[i - 1]].second;
            tmp += sqrt(1.0 * dx * dx + 1.0 * dy * dy);
        }
        sum += tmp;
    } while (next_permutation(seq.begin(), seq.end()));

    printf("%.15f\n", 1.0 * sum / total);

    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    repl(i, a, a + k)if (i < b + 1) v.pb(i);
    repl(i, b - k + 1, b + 1) if (i > a - 1) v.pb(i);
    sort(all(v));
    uni(v);
    rep(i, v.size()) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 2000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}

int main() {
    
    char a; cin>>a;
    string s = "abcdefghijklmnopqrstuvwxyz";
    cout<<s[a-'a'+1]<<endl;
    return 0;  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

struct edge {
  ll from;
  ll to;
  ll cost;
};

ll n, E;
vector<vector<edge>> g;
// dp[i][j] .. i is state bit, j is last element. Total number when start from (i,j).
vector<vector<ll>> dp;

// state .. bit representation, v .. last reached
ll rec(ll state, ll v) {
  if (dp[state][v] < INF) { return dp[state][v]; }
  if ((state == (1ll<<n)-1) && v == 0) { // returned to 0.
    return dp[state][v] = 0;
  }

  bool found = false;
  for (edge& e : g[v]) {
    if ((state&(1ll<<e.to)) == 0) { // e.to is not reached yet
      ll now = rec(state|(1ll<<e.to), e.to);
      if (now >= 0) {
        found = true;
        chmin(dp[state][v], now + e.cost);
      }
    }
  }
  if (!found) { return dp[state][v] = -1; }
  return dp[state][v];
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  cin >> n >> E;
  g.resize(n);
  dp.assign(1ll<<n, vector<ll>(n, INF));

  rep(i, E) {
    ll s, t, d;
    cin >> s >> t >> d;
    g[s].push_back({ s, t, d });
  }

  ll ans = rec(0, 0); // start from 0.
  if (ans >= 0) {
    cout << ans << endl;
  } else { // invalid
    cout << -1 << endl;
  }
}



Measured memory_bytes: 7860
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        if (str.Length == 2) WriteLine(str);
        else
        {
            var result = "";
            for (var i = 0; i < 3; i++) result += str[2 - i];
            WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        n, m = map(int, input().split())
        students = []
        for i in range(n):
            a, b = map(int, input().split())
            students.append((a, b))
        checkpoints = []
        for j in range(m):
            c, d = map(int, input().split())
            checkpoints.append((c, d))
        for a, b in students:
            ans = -1
            minimum = float('inf')
            for index, (c, d) in enumerate(checkpoints):
                if minimum > abs(a - c) + abs(b - d):
                    minimum = abs(a - c) + abs(b - d)
                    ans = index + 1
            print(ans)
                
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()


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

int main() {
  ll n;
  cin >> n;
  string ans;
  while (n) {
    n--;
    ans += 'a'+n%26;
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
def exchange(str, bef, aft)
	if str == bef
		return aft
	else
		return str
	end
end
while n=gets.to_i do
	exit if n==0
	$results=[]
	ctn=0
	a,b=Array.new(n), Array.new(n)
	n.times do |i|
		a[i],b[i]=gets.chomp.split
	end

	gets.to_i.times do
		str=gets.chomp
		result=str
		while !(ctn==n||result!=str)
			result = exchange(str, a[ctn], b[ctn])
			ctn+=1
		end
		$results<<result
		ctn=0
	end
	puts $results.join
end

Measured memory_bytes: 10588
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	int a,b,c,d,k,f;
        	cin>>a>>b>>c>>d>>k;
        	f=(c-a)*60 +(d-b) -k;
        	cout<<f;  
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool a = 1;
    rep(i, s.size()) {
        if(i % 2 == 1 && s[i] == 'R') {
            a = 0;
            break;
        } else if(i % 2 == 0 && s[i] == 'L') {
            a = 0;
            break;
        }
    }
    if(a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  long long x;
  std::cin >> x;
  if (x % 11 <= 6 && x % 11 != 0) std::cout << (long)((x-0.1)/11)*2 + 1 << std::endl;
  else std::cout << (long)((x-0.1)/11)*2 + 2 << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    long long n,h,w,ans=0;
    cin >> n >> h >> w;
    vector<long long> a(n),b(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        if(a[i]>=h&&b[i]>=w)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int x, h, m, s;

  scanf("%d", &x);
h=x/3600;
m=(x-h*3600)/60;
s=x-h*3600-m*60;
 
  printf("%d:%d:%d\n",h,m,s);
 
  return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1,_2,_3,name,...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i=(a); i<(n); ++i)
#define rep(...) _overload3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T> inline void print(const T& x) {cout << x << "\n";}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll h, w; cin >> h >> w;
    vs maze(h); rep(i, h) cin >> maze[i];
    ll ma = 0;
    rep(sx, h) {
        rep(sy, w) {
            if (maze[sx][sy] == '#') continue;
            vvi d(h, vi(w, -1));
            queue<pii> q;
            d[sx][sy] = 0;
            q.push(pii(sx, sy));
            while (not q.empty()) {
                pii r = q.front(); q.pop();
                ll x = r.fi, y = r.se;
                rep(i, 4) {
                    ll nx = x + dx[i];
                    ll ny = y + dy[i];
                    if (0 <= nx and nx < h and 0 <= ny and ny < w and maze[nx][ny] == '.' and d[nx][ny] == -1) {
                        q.push(pii(nx, ny));
                        d[nx][ny] = d[x][y] + 1;
                        chmax(ma, d[nx][ny]);
                    }
                }
            }
        }
    }
    print(ma);
}

Measured memory_bytes: 3668
cicle = gets.to_i


cicle.times do
	siz = gets
	lines = siz.split(" ")
	max = 0
	sum = 0

	aa = lines[0].to_i**2
	bb = lines[1].to_i**2
	cc = lines[2].to_i**2

	if ((aa-bb-cc) == 0)
			puts "YES" 
	elsif ((bb-cc-aa) == 0)
			puts "YES" 
	elsif ((cc-aa-bb) == 0)
			puts "YES" 
	else 
		puts "NO"
	end

end

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string A, B; cin >> A >> B;
    string ans = "EQUAL";
    if(A.size() > B.size()) ans = "GREATER";
    else if(A.size() < B.size()) ans = "LESS";
    else {
        for(int i = 0; i < A.size(); i++) {
            if(A[i] > B[i]) {
                ans = "GREATER";
                break;
            }
            else if(A[i] < B[i]) {
                ans = "LESS";
                break;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    loop {
        int N = next<int>(), K = next<int>();
        unless(N || K) break;

        auto C = next<vector<int>>(K);
        sort(all(C));

        bool white = !C[0];

        vector<bool> c(N, false);
        times(K, i) if(C[i]) c[C[i] - 1] = true;

        int ren = 0, wren = 0, mren = 0, mwren = 0;
        times(N, i) {
            if(c[i]) {
                ren++;
                wren++;
            } else {
                wren = ren + 1;
                ren = 0;
            }
            mren = max(mren, ren);
            mwren = max(mwren, wren);
            #ifdef debug
                cout << ren << ":" << mren << ", " << wren << ":" << mwren ln;
            #endif
        }
        cout << (white ? mwren : mren) ln;
    }

    return 0;
}

Measured memory_bytes: 1524
# Task Scheduling Problem

def main():
    a = input()
    tasks_char = a.split(" ")
    tasks = [int(c) for c in tasks_char]

    indiced_tasks = list(zip(list(range(len(tasks))), tasks))
    sorted_tasks = sorted(indiced_tasks, key=lambda t: t[1])

    x = 0
    for (i1, t1), (i2, t2) in zip(sorted_tasks[:-1], sorted_tasks[1:]):
        x += abs(t1 - t2)
    print(x)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  ll t = 0;
  rep(i,m) t += b[i];
  int j = m, ans = 0;
  rep(i,n+1) {
    while (j > 0 && t > k) {
      --j;
      t -= b[j];
    }
    if (t > k) break;
    ans = max(ans, i+j);
    if (i == n) break;
    t += a[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 4800
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>x(n), l(n);
	vector<pair<ll, ll>>robo(n);
	rep(i, n) {
		cin >> x[i] >> l[i];
		robo[i].second = x[i] - l[i];
		robo[i].first = x[i] + l[i];
	}
	sort(robo.begin(), robo.end());
	ll time = -1 * INF;
	ll ans = 0;
	rep(i, n) {
		if (time <= robo[i].second) {
			ans++;
			time = robo[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6412