akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int h,a;cin>>h>>a;
  cout << (h+-1)/a+1 << endl;
}

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

int main(){
    string str1, str2;
    cin >> str1 >> str2;
    if(str1 > str2){
        cout << ">" << endl;
    }
    else if(str1 < str2){
        cout << "<" << endl;
    }
    else{
        cout << "=" << endl;
    }

    return 0;
}

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

/*
4
<><
*/


int n;
string s;
vector<vector<int> >dp;

void solve(){

    cin>>n>>s;
    dp.resize(n,vector<int>(n,0));

    if(s[n-2]=='>'){
        dp[n-1][0]=1;
        dp[n-1][1]=0;
    }
    if(s[n-2]=='<'){
        dp[n-1][1]=1;
        dp[n-1][0]=0;
    }
    for(int i=n-2;i>=1;i--){
        int total = n-i;
        for(int g = 0;g<=total;g++){
            if(g==0){
                if(s[i-1]=='<'){
                    dp[i][g]=0;
                }else{

                    for(int j=1;j<=total;j++){
                        dp[i][g] += dp[i+1][total-j];
                        dp[i][g] %=mod;
                    }
                }

            }else{

                if(s[i-1]=='>'){
                    dp[i][g] = (mod+ dp[i][g-1] - dp[i+1][g-1])%mod;
                }else{
                    dp[i][g] = dp[i][g-1] + dp[i+1][g-1];
                    dp[i][g] %=mod;
                }
            }
        }
    }
    long long ans =0;
    for(int i=1;i<=n;i++){
        ans += dp[1][n-i];
        ans %= mod;
    }
    cout<<ans<<"\n";
}

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

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


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

using Lint=long long;
const int INF=1e9;

int main()
{
   int H,W,h,w; cin>>H>>W>>h>>w;
   if(H%h==0 and W%w==0){ cout<<"No"<<endl; return 0; }

   cout<<"Yes"<<endl;
   Lint sum=0;
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         int x=0;
         if(i%h==0 and j%w==0) x=INF-1;
         else if(i%h==h-1 and j%w==w-1) x=-INF;
         cout<<x<<(j==W-1? '\n':' ');
         sum+=x;
      }
   }
   // cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>

using namespace std;

int N, M;
vector<int> G[8];

int dfs(int v, bool visited_vertexes[8])
{
    bool flag = true;
    for (int i = 0; i < N; ++i)
    {
        if (!visited_vertexes[i])
            flag = false;
    }

    if (flag)
        return 1;

    int res = 0;
    for (int i = 0; i < G[v].size(); ++i)
    {
        if (visited_vertexes[G[v][i]])
            continue;
        visited_vertexes[G[v][i]] = true;
        res += dfs(G[v][i], visited_vertexes);
        visited_vertexes[G[v][i]] = false;
    }

    return res;
}

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

    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool visited_vertexes[8] = {false};
    visited_vertexes[0] = true;

    cout << dfs(0, visited_vertexes) << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline

N = int(readline())

SP = [readline().split() for i in range(N)]
iSP = [(i, s, int(p)) for i,(s,p) in enumerate(SP)]

iSP.sort(key=lambda x:-x[2])
iSP.sort(key=lambda x:x[1])

for i,s,p in iSP:
    print(i + 1)

Measured memory_bytes: 38384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++){
		    h[i] = sc.nextInt();
		}

		// 計算
	    int result = 0;
	    Arrays.sort(h);
	    int min = Integer.MAX_VALUE;
	    for(int i = k - 1; i < n; i++){
		    min = min(min, h[i] - h[i - k + 1]);
		}
		result = min;

		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 52260
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define reps(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define pb push_back

int n;

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

    cin >> n;
    int a[100000];

    rep(i, n) {
        cin >> a[i];
        --a[i];
    }

    int sum = 0;
    rep(i, n) {
        int j = a[i];
        if (a[j] == i) ++sum;
    }

    cout << (sum / 2) << endl;

    return 0;
}


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

struct Node {
	int key;
	Node *p, *l, *r;
};

Node *nil;
Node *root = nil;

void insert(int k) {
	Node *y = nil;
	Node *x = root;
	Node *z = new Node;
	z->key = k;
	z->l = nil;
	z->r = nil;
	while (x != nil) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;
	if (y == nil) root = z;
	else {
		if (z->key < y->key) y->l = z;
		else y->r = z; 
	}
}

void inorder(Node *root) {
	if (root == nil) return;
	inorder(root->l);
	cout << ' ' << root->key;
	inorder(root->r);
}

void preorder(Node *root) {
	if (root == nil) return;
	cout << ' ' << root->key;
	preorder(root->l);
	preorder(root->r);
}

void print() {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

int main() {
	int n, key;
	char cmd[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd[0] == 'i') {
			cin >> key;
			insert(key);
		}
		else print();
	}

	return 0;
}

Measured memory_bytes: 24628
var
	S:String;
	cnt:Array[0..2018]of Longint;
	a,p,i:Longint;
	ans:int64;
begin
	readln(S);
	cnt[0]:=1;
	p:=1;
	for i:=length(S)downto 1 do begin
		a:=(a+p*(ord(S[i])-48))mod 2019;
		p:=p*10 mod 2019;
		inc(ans,cnt[a]);
		inc(cnt[a]);
	end;
	writeln(ans);
end.


Measured memory_bytes: 1328
#include <iostream>
#include <vector>

using namespace std;

int ans = 0;

void search(vector<vector<int>>& graph, vector<int> visit, int p)
{
    visit[p] = 1;
    int visit_all = true;
    for (int i = 0; i < visit.size(); ++i) {
        if (visit[i] == 0) {
            visit_all = false;
            break;
        }
    }
    if (visit_all) {
        ++ans;
        return;
    }

    for (int i = 0; i < graph[p].size(); ++i) {
        if (graph[p][i] && visit[i] == 0) {
            search(graph, visit, i);
        }
    }
    visit[p] = 0;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>(n));
    for (int i = 0; i < m; ++i) {
        int p, q;
        cin >> p >> q;
        graph[p-1][q-1] = 1;
        graph[q-1][p-1] = 1;
    }

    vector<int> visit(n);
    search(graph, visit, 0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 3013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

string s, t;
int dp[MAXN][MAXN];
pii parent[MAXN][MAXN];
bitset<MAXN> take[MAXN];
string ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s >> t;
	FOR(i, 1, SZ(s) + 1)
	{
		FOR(j, 1, SZ(t) + 1)
		{
			if (dp[i - 1][j] > dp[i][j])
			{
				dp[i][j] = dp[i - 1][j];
				parent[i][j] = {i - 1, j};
			}
			if (dp[i][j - 1] > dp[i][j])
			{
				dp[i][j] = dp[i][j - 1];
				parent[i][j] = {i, j - 1};
			}
			if (dp[i - 1][j - 1] + 1 > dp[i][j] && s[i - 1] == t[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
				take[i][j] = true;
				parent[i][j] = {i - 1, j - 1};
			}
		}
	}
	pii p = {SZ(s), SZ(t)};
	while(p != MP(0, 0))
	{
		if (take[p.fi][p.se]) ans += s[p.fi - 1];
		p = parent[p.fi][p.se];
	}
	reverse(ALL(ans));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 107648
import java.util.Scanner;

public class Main {
    //C - Half and Half
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int X = scanner.nextInt();
        int Y = scanner.nextInt();

        int cost = 0;
        if ( X > Y ) {
            int dx = Math.abs(X - Y);
            cost = (X - dx) * Math.min(A+B, C*2) + dx * Math.min(A, C*2);
        }
        else {
            int dy = Math.abs(X - Y);
            cost = (Y - dy) * Math.min(A+B, C*2) + dy * Math.min(B, C*2);
        }
        System.out.println(cost);
    }
}


Measured memory_bytes: 23764
from collections import deque
a = deque()
q = int(input())
for i in range(q):
  lst = list(map(int, input().split()))
  if lst[0] == 0:
    d = lst[1]
    x = lst[2]
    if d == 0:
      a.appendleft(x)
    else :
      a.append(x)
  elif lst[0] == 1:
    p = lst[1]
    print(a[p])
  elif lst[0] == 2:
    d = lst[1]
    if d == 0:
      a.popleft()
    else:
      a.pop()
  else:
    pass
  


Measured memory_bytes: 21980
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll M , K ;
    
    cin >> M >> K ;
    vector<ll> a ;// 0 <= x < 2**M
    
    if(M < 2){
        if(M == 1 && K == 0) {
            cout << "0 0 1 1 " << endl;
        }else if(M == 0 && K == 0){
            cout << "0 0" << endl;
        }else{
            cout << -1 << endl;
        }
        return 0 ;
    }
    
    rep(i, 1<<M){
        if(i == K) continue;
        a.pb(i);
    }

    ll ans = a[0];
    rep(i, a.size()){
        if(i == 0) continue;
        ans ^= a[i];
    }
    
    cerr << "ans: " << ans << endl;
    cerr << "K: " << K << endl;
    if(ans == K) {
        rep(i, a.size()){
            cout << a[i] << " ";
        }
        cout << K << " ";
        rep(i, a.size()){
            cout << a[a.size()-1-i] << " ";
        }
        cout << K << endl;
    }else{
        cout << -1 << endl;
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 2932
using System;
using System.Linq;

namespace testing
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            if (N % 2 == 1 || a[(N / 2) - 1] == a[N / 2]) { Console.WriteLine("0"); }
            if (N % 2 == 0)
            {
                if (a[(N/2)-1] != a[N / 2] )
                {
                    Console.WriteLine(a[N / 2] - a[(N / 2) - 1]);
                }
            }
        }
    }
}


Measured memory_bytes: 36264
n = int(input())
C, S, F = [], [], []
for _ in range(n-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    t = S[i]
    while i != (n-1):
        if t < S[i]:  # 最初の列車の発車時刻前に到着
            wait = (S[i] - t)
        else:
            r = (t - S[i])%F[i]
            if r == 0:
                wait = 0 
            else:
                wait = F[i] - r
        t += wait
        t += C[i]  # 移動時間
        i += 1
    print(t)
print(0)  # すでに駅Nにいる

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll n;cin>>n;
    vector<string> s(n);
    For(i,n){
        string si;cin>>si;
        sort(si.begin(),si.end());
        s.at(i)=si;
    }
    sort(s.begin(),s.end());
    string renzoku="AtCoder";
    ll ans=0,num=1;
    For(i,n){
        if(s.at(i)==renzoku){
            num++;
        }
        else{
            ans+=(num*(num-1))/2;
            renzoku=s.at(i);
            num=1;
        }
    }
    ans+=(num*(num-1))/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

#define MAX_N (100)
#define MAX_M (1000)
#define INF (1 << 29)

using namespace std;

// copy ans
int main(int argc, char *argv[]) {
  // read inputs
  int N, M, as[MAX_M], bs[MAX_M], cs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d %d", &as[i], &bs[i], &cs[i]);
    as[i]--;  // NOTE : rewrite input
    bs[i]--;  // NOTE : rewrite input
  }

  // initialize distance matrix
  int distances[MAX_N][MAX_N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      distances[i][j] = (i == j ? 0 : INF);
    }
  }
  for (int i = 0; i < M; i++) {
    const int a = as[i], b = bs[i], c = cs[i];
    distances[a][b] = c;
    distances[b][a] = c;
  }
  // warshall floyd
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        distances[i][j] =
            min(distances[i][j], distances[i][k] + distances[k][j]);
      }
    }
  }
  // for (int i = 0; i < N; i++) {
  //   for (int j = 0; j < N; j++) {
  //     printf("%d ", distances[i][j]);
  //   }
  //   printf("\n");
  // }
  // count paths on shortest path
  int ans = 0;
  for (int i = 0; i < M; i++) {
    const int a = as[i], b = bs[i], c = cs[i];
    // (a, b) is used in a shortest path if and only if 
    // (a, b) is the shortest path between a and b
    ans += (distances[a][b] != c);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    char a[100];
    char a1[100];
   
    if(x>=y)
    {
        for(int i=0;i<x;i++)
        {
            cout<<y;
        }
    }
    else
    {
      for(int i=0;i<y;i++)
        {
            cout<<x;
        }   
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

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

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) {
    printf("%lld %lld %lld\n", n/2, n, n);
    return 0;
  }
  ll bunbo = n;
  ll bunsi;
  bunsi = 4;
  vector<ll> ans(3, 0);
  double seiki_bunbo = (double)bunbo / bunsi;
  ans[0] = (seiki_bunbo + 1);


  ll nbunbo, nbunsi;
  nbunbo = bunbo * ans[0];
  nbunsi = bunsi * ans[0] - bunbo;
  bunbo = nbunbo;
  bunsi = nbunsi;
  if (bunsi == 1) {
    ans[1] = bunbo * 2;
    ans[2] = bunbo * 2;
    printf("%lld %lld %lld\n", ans[0], ans[1], ans[2]);
    debug("P 4n+3");
    return 0;
  }

  if (ans[0] % 2 == 0) {
    ans[1] = bunbo / 2;
    ans[2] = bunbo;
    printf("%lld %lld %lld\n", ans[0], ans[1], ans[2]);
    debug("P n+1 : even");
    return 0;
  }
  if (bunbo % 3 == 0) {
    ans[1] = bunbo/3*2;
    ans[2] = ans[1];
    printf("%lld %lld %lld\n", ans[0], ans[1], ans[2]);
    debug("P n+1 : 3m");
    return 0;
  }

  if (n == 17) {
    printf("6 17 102\n");
    return 0;
  }
  if (n == 25) {
    printf("8 40 100\n");
    return 0;
  }

  for (int j = 1; j <= 3500; ++j) {
    ll fbunbo = n;
    ll fbunsi = 4;
    ll fnbunbo = fbunbo * j;
    ll fnbunsi = fbunsi * j - fbunbo;
    if (fnbunsi <= 0) {
      continue;
    }
    fbunbo = fnbunbo;
    fbunsi = fnbunsi;
    for (int k = 1; k <= 3500; ++k) {
      ll ffbunbo = fnbunbo;
      ll ffbunsi = fnbunsi;
      ll ffnbunbo = ffbunbo * k;
      ll ffnbunsi = ffbunsi * k - ffbunbo;
      if (ffnbunsi <= 0) {
        continue;
      }
      ffbunbo = ffnbunbo;
      ffbunsi = ffnbunsi;
      if (ffbunbo % ffbunsi == 0) {
        printf("%d %d %lld\n", j, k, ffbunbo / ffbunsi);
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import sys
fin = sys.stdin.readline
N = int(fin())
T, A = [int(elem) for elem in fin().split()]
H_list = [int(elem) for elem in fin().split()]
assert len(H_list) == N

temperatures = [T - H * 0.006 for H in H_list]

idx_closest = 1
temp_closest = float('inf')
for i, temperature in enumerate(temperatures, start=1):
    if abs(A - temperature) < abs(A - temp_closest):
        temp_closest = temperature
        idx_closest = i

print(idx_closest)


Measured memory_bytes: 3064
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    a,b = readInts()
    if a % n == 0 or a//n + 1 <= a//n + 1 <= b//n:
        print('OK')
    else:
        print('NG')
if __name__ == '__main__':
  main()


Measured memory_bytes: 10884
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H, W;
	cin >> H >> W;
	cout << (H - 1) * (W - 1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
    char a[4];
    scanf("%s",a);
    if((a[0]-'0')*10+a[1]-'0'>=1&&(a[0]-'0')*10+a[1]-'0'<=12&&(a[2]-'0')*10+a[3]-'0'>=1&&(a[2]-'0')*10+a[3]-'0'<=12)
        printf("AMBIGUOUS");
    else
        if((a[0]-'0')*10+a[1]-'0'>=1&&(a[0]-'0')*10+a[1]-'0'<=12)
        printf("MMYY");
    else
        if((a[2]-'0')*10+a[3]-'0'>=1&&(a[2]-'0')*10+a[3]-'0'<=12)
        printf("YYMM");
    else
        printf("NA");
    return 0;
}


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

constexpr int Inf = 1000000;

int h, w;
int board[1000][1000] = {};
constexpr int delta[] = { -1, 0, 1, 0, -1 };

struct Data {
	int y, x;
};

int main() {
	std::cin >> h >> w;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			std::cin >> c;

			if (c == '.')
				board[i][j] = Inf;
		}
	}

	std::queue<Data> que;
	for (int y = 0; y < h; ++y) {
		for (int x = 0; x < w; ++x) {
			if (board[y][x] != 0)
				continue;

			for (int i = 0; i < 4; ++i) {
				const int ny = y + delta[i], nx = x + delta[i + 1];

				if (ny < 0 || ny >= h || nx < 0 || nx >= w)
					continue;
				if (board[ny][nx] <= 1)
					continue;

				board[ny][nx] = 1;
				que.push({ ny, nx });
			}
		}
	}
	while (!que.empty()) {
		const auto top = que.front();
		que.pop();

		const int depth = board[top.y][top.x];

		for (int i = 0; i < 4; ++i) {
			const int ny = top.y + delta[i], nx = top.x + delta[i + 1];

			if (ny < 0 || ny >= h || nx < 0 || nx >= w)
				continue;
			if (board[ny][nx] <= depth + 1)
				continue;

			board[ny][nx] = depth + 1;
			que.push({ ny, nx });
		}
	}
	

	int ans = 0;
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			if (board[y][x] > ans)
				ans = board[y][x];

	std::cout << ans << std::endl;
}


Measured memory_bytes: 8192
from collections import Counter

N = int(input())
A = [int(s) for s in input().split()]
C = Counter(A)

max_value = 0
for c, cnt in C.items():
    max_value += cnt * (cnt - 1) // 2 if cnt >= 2 else 0

for a in A:
    n = C[a]
    if n >= 2:
        print(max_value - (n * (n - 1) // 2 - (n - 1) * (n - 2) // 2))
    else:
        print(max_value)


Measured memory_bytes: 26024
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    double ans = 0;
    rep(i, N){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else{
            ans += x * 380000.0;
        }    
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
return 0;
}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long num[30];
const long long MOD = 1000000007;

int N;
string S;

int main() {
    while (cin >> N >> S) {
        memset(num, 0, sizeof(num));
        for (auto c : S) {
            num[c - 'a']++;
        }

        long long res = 1;
        for (int i = 0; i < 26; ++i) {
            res = (res * (num[i] + 1)) % MOD;
        }
        cout << (res + MOD - 1) % MOD << endl;
    }
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s; cin >> s;
    int ans = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[i-1]) ans++;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3760
package main

import (
	"fmt"
	"strconv"
)

func ct(s []string, i int, j int) int {
	if i < 0 || i >= len(s) || j < 0 || j >= len(s[i]) {
		return 0
	}

	if s[i][j] == '#' {
		return 1
	} else {
		return 0
	}
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}
	// fmt.Println(s)

	a := ""
	for i, v := range s {
		for j, vv := range v {
			if vv == '#' {
				a += "#"
				continue
			}
			ctBomb := ct(s, i-1, j-1) + ct(s, i-1, j) + ct(s, i-1, j+1) + ct(s, i, j-1) + ct(s, i, j+1) + ct(s, i+1, j-1) + ct(s, i+1, j) + ct(s, i+1, j+1)
			a += strconv.Itoa(ctBomb)
		}

		fmt.Println(a)
		a = ""
	}
}


Measured memory_bytes: 640
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 100005;
struct Node {
	ll a,b,d;
	bool operator<(const Node rhs)const {
		return d>rhs.d;
	}
}nd[maxn];

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	int n;
	scanf("%d",&n);
	ll x,y;
	for(int i=0;i<n;i++) {
		scanf("%lld%lld",&nd[i].a,&nd[i].b);
		nd[i].d=nd[i].a+nd[i].b;
	}
	sort(nd,nd+n);
	ll ans=0;
	for(int i=0;i<n;i++) {
		if(i%2==0) ans += nd[i].a;
		else ans-=nd[i].b;
	}
	cout<<ans<<endl;
	return 0;
}














Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(((x-r) >= 0 && (x+r) <= W) && ((y-r) >= 0 && (y+r) <= H))
		printf("Yes\n");
	else 
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
const int INF{numeric_limits<int>::max()/3};
int K,dp[100000];
int main(){
    cin>>K;
    fill_n(dp,100000,INF);
    deque<P> q;
    dp[1]=1;
    q.emplace_back(1,1);
    while(q.size()){
        int w{q.front().first},i{q.front().second};
        q.pop_front();
        if(dp[i]<w)continue;
        if(w<dp[(i*10)%K]){
            dp[(i*10)%K]=w;
            q.emplace_front(w,(i*10)%K);
        }
        if(w+1<dp[(i+1)%K]){
            dp[(i+1)%K]=w+1;
            q.emplace_back(w+1,(i+1)%K);
        }
    }
    cout<<dp[0]<<endl;
}


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/


int main()
{
    ll n;
    cin >> n;
    vector<ll> vv,v;
    for(ll i=0;i<n;i++)
    {

        ll x;
        cin >> x;
        vv.pb(x);
    }
    for(ll i=0;i<n;i++)
    {

        ll y;
        cin >> y;
        v.pb(vv[i]-y);
    }
    ll ans=0;
    sort(all(v));
    reverse(all(v));
    for(ll i=0;i<v.size();i++)
    {

        if(v[i] < 0) break;
        ans+=v[i];
    }
    cout << ans;
}


Measured memory_bytes: 3620
import java.util.Scanner;

//Sequence
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double a = sc.nextDouble();
			int k = 1;
			double s = a;
			while(++k<=10){
				if(k%2==0)a*=2;
				else a/=3;
				s+=a;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int P[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            P[i][j]=0;
        }
    }
    int head,tail;
    string num;
    for(int i=1; i<=N; i++){
        num=to_string(i);
        head=num.at(0)-'0';
        tail=num.at(num.size()-1)-'0';
        if(head==tail){
            P[head][head]++;
        }else{
            P[head][tail]++;
        }
    }
    long long ans=0;
    for(int i=1; i<10; i++){
        for(int j=1; j<=i; j++){
            if(i==j){
                ans+=(long long)P[i][j]*P[i][j];
            }else{
                ans+=(long long)P[i][j]*P[j][i]*2;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H{}, W{};
  int A{}, B{};
  scanf("%d %d %d %d\n", &H, &W, &A, &B);

  int res{};
  for (int row = 0; row < H; ++row){
    res = !res;
    if(row == B) res = !res;
    for (int column = 0; column < W; ++column){
      if(column == A) res = !res;
      printf("%d", res);
    }
    printf("\n");
  }

  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

int Edges[100];

int main() {
	int len;

	memset(Edges, 0, sizeof(Edges));
	for (int i = 0; i < 12; ++i) {
		cin >> len;
		++Edges[len - 1];
	}

	for (int i = 0; i < 100; ++i) {
		if (Edges[i] == 0) {
			continue;
		}
		if (Edges[i] % 4 != 0) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;

	return 0;
}



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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if( A+B > C+D ){
        cout << "Left" << endl;
    }else if ( A+B < C+D ){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Collections.Specialized;
using System.IO.Pipes;

namespace ConsoleC____
{
    class Program
    {
        static int ans = 0;
        static void Main()
        {
            int N, K;
            string[] s = Console.ReadLine().Split(' ');
            N = int.Parse(s[0]);
            K = int.Parse(s[1]);

            int[] p = new int[N];
            string[] s2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                p[i] = int.Parse(s2[i]);
            }
            
            Array.Sort(p);

            //Console.WriteLine("{0} {1}", N, K);
            //for (int i = 0; i < N; i++) Console.Write("{0} ", p[i]);
            for (int i = 0; i < K; i++)
            {
                ans += p[i];
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18516
t = int(input())

c1, c2, c3, c4 = 0, 0, 0, 0
for i in range(t):
	s = input()
	if s == 'AC':
		c1 += 1
	elif s == 'TLE':
		c2 += 1
	elif s == 'WA':
		c3 += 1
	else:
		c4 += 1
print('AC x', c1)
print('WA x', c3)
print('TLE x', c2)
print('RE x', c4)


Measured memory_bytes: 9200
x,y = map(str,input().split())

X = 0
Y = 0
for i,l in enumerate("ABCDEF"):
    if x == l:
        X = i
    if y == l:
        Y = i
if X < Y:
    print("<")
elif X == Y:
    print("=")
else:
    print(">")

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

int my_gcd(int n, int m){
    if(n < m) swap(n, m);
    if(m == 0) return n;
    return my_gcd(m, n%m);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;
    // ここまでの WA はどこで時間がかかっているかの実験です
    // cin が悪そうだという結論が出ました
    cin.tie(0); ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        maxa = (maxa < a[i])? a[i] : maxa;
    }

    vector<int> primes;
    vector<int> min_prime_factor(maxa+1, 0);
    
    primes.push_back(2);
    for(int j=2; j<=maxa; j+=2){
        min_prime_factor[j] = 2;
    }
    
    int i;
    for(i=3; i*i<=maxa; i+=2){
        if(min_prime_factor[i] != 0) continue;
        primes.push_back(i);
        for(int j=i; j<=maxa; j+=i){
            if(min_prime_factor[j] == 0){
                min_prime_factor[j] = i;
            }
        }
    }
    
    for(; i<=maxa; i+=2){
        if(min_prime_factor[i] == 0){
            primes.push_back(i);
            min_prime_factor[i] = i;
        }
    }

    int ggcd = a[0];
    for(int i=1; i<n; i++){
        ggcd = my_gcd(a[i], ggcd);
        if(ggcd == 1) break;
    }

    if(ggcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }

    map<int, int> mp_prime;
    for(int j=0; j<primes.size(); j++){
        mp_prime[primes[j]] = j;
    }

    vector<bool> c(primes.size(), false);
    for(int i=0; i<n; i++){
        while(a[i] != 1){
            int p = min_prime_factor[a[i]];
            if(c[mp_prime[p]] != false){
                cout << "setwise coprime" << endl;
                return 0;
            }
            c[mp_prime[p]] = true;
            a[i] /= p;
            while(a[i] % p == 0) a[i] /= p;
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 24384
#include <stdio.h>
 
int main(){
    long long int n;
    scanf("%lld",&n);
 
    char nama[100];
    int i = 0;
    
    while(n != 0) {
        n--;
        int huruf = n % 26;
        nama[i] ='a' + huruf;
        n /= 26;
        i++;
    }
    for(int j = i - 1; j >= 0; j--) {
        printf("%c", nama[j]);
    }   
    return 0;
}

Measured memory_bytes: 1644
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ss = new int[n].Select(_ => Console.ReadLine()).OrderBy(s => s.Length).ToArray();

		var r = 0L;
		var root = new Node('/');

		foreach (var s in ss)
		{
			var node = root;
			for (int i = s.Length - 1; i >= 0; i--)
			{
				if (i == 0)
					node.Ends[s[i] - 'a']++;
				else
					for (int j = 0; j < 26; j++)
					{
						if (node.Ends[j] == 0) continue;
						var c = (char)('a' + j);
						if (s.IndexOf(c, 0, i + 1) >= 0)
							r += node.Ends[j];
					}

				if (!node.Nexts.ContainsKey(s[i]))
					node.Nexts[s[i]] = new Node(s[i]);
				node = node.Nexts[s[i]];
			}
		}

		Console.WriteLine(r);
	}
}

class Node
{
	public char C;
	public int[] Ends = new int[26];
	public Dictionary<char, Node> Nexts = new Dictionary<char, Node>();
	public Node(char c) => C = c;
}


Measured memory_bytes: 400904
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
int n,p,x;
cin>>n;
vector<int>v;
while(n--)
{
    cin>>p;
    v.pb(p);
    sort(v.begin(),v.end());
}
x=v[v.size()-1]/2;
for(int i=0;i<v.size()-1;i++)
{
    x+=v[i];
}
cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
import math


class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def print(self):
        print(self.x, self.y)

    def __add__(self, o):
        return Vector(self.x + o.x, self.y + o.y)

    def __sub__(self, o):
        return Vector(self.x - o.x, self.y - o.y)

    def __mul__(self, o):
        return Vector(self.x * o, self.y * o)

    def __truediv__(self, o):
        return Vector(self.x / o, self.y / o)

    def rot(self, deg):
        rad = math.radians(deg)
        x = self.x * math.cos(rad) - self.y * math.sin(rad)
        y = self.x * math.sin(rad) + self.y * math.cos(rad)
        return Vector(x, y)


def koch(d, a, b):
    if d == 0:
        return

    s = a + (b-a)/3
    u = s + (s-a).rot(60)
    t = a + (b-a)*2/3

    koch(d-1, a, s)
    s.print()
    koch(d-1, s, u)
    u.print()
    koch(d-1, u, t)
    t.print()
    koch(d-1, t, b)


N = int(input())

a = Vector(0, 0)
b = Vector(100, 0)


a.print()
koch(N, a, b)
b.print()



Measured memory_bytes: 5784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int a,p;
	cin>>a>>p;
	cout<<(a*3+p)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 0..n {
        let mut a = av[i];
        let mut j = 0;
        while a % 2 == 0 {
            j += 1;
            a /= 2;
        }
        ans += j;
    }
    println!("{}", ans);
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

#define MAX 100005
#define INF INT_MAX

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

void maxHeapify(vector<ll>& a, int i)
{
    int l = 2*i;
    int r = 2*i+1;
    int h = a.size()-1;

    int largest = i;
    if (l <= h && a[l] > a[largest]) largest = l;
    if (r <= h && a[r] > a[largest]) largest = r;
    if (largest != i) {
        swap(a[largest], a[i]);
        maxHeapify(a, largest);
    }
}

void buildMaxHeap(vector<ll>& a)
{
    int h = a.size()-1;
    for (int i = h/2; i >= 1; i--) {
        maxHeapify(a, i);
    }

}

void push(vector<ll>&a, ll key)
{
    a.push_back(key);

    ll h = a.size()-1;
    ll x = h;
    while (x/2 > 0 && a[x/2] < a[x]) {
        swap(a[x/2], a[x]);
        x /= 2;
    }
}

ll pop(vector<ll>& a)
{
    ll res = a[1];
    a[1] = a.back();
    a.pop_back();
    maxHeapify(a, 1);
    return res;
}

int main(int, char**)
{
    string s;
    ll k;
    vector<ll> a;

    a.push_back(0); // 1originにするためのダミー

    while (true) {
        cin >> s;
        if (s == "end") break;
        if (s == "insert") {
            cin >> k;
            push(a, k);
        } else if (s == "extract") {
            cout << pop(a) << endl;
        }
    }
    return 0;
}



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

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

int main() {
    int n;
    cin >> n;
    set<string> a;
    rep(i,n){
        string s;
        cin >> s;
        a.insert(s);
    }

    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 19184
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
//const ll M=1000000007;
int aa,bb,cc;
int u[100][100][100];
struct e{
	int x;
	int y;
	int z;
	e(int aa,int bb,int cc){
		x=aa;
		y=bb;
		z=cc;
	}

};
int main(){
	cin>>aa>>bb>>cc;
	queue<pair<e,int> >bfs;
	e tmp(aa,bb,cc);
	bfs.push(mp(tmp,0));

	rep(i,100)rep(j,100)rep(k,100)u[i][j][k]=-1;
	while(!bfs.empty()){
		int a,b,c,now;
		e nex=bfs.front().first;
		now=bfs.front().second;
		bfs.pop();
		a=nex.x,b=nex.y,c=nex.z;
		if(a==b&&b==c){
			cout<<now<<endl;
			return 0;
		}
		if(u[a][b][c]!=-1)continue;
		u[a][b][c]=now;
		bfs.push(mp(e(a+2,b,c),now+1));
		bfs.push(mp(e(a,b+2,c),now+1));
		bfs.push(mp(e(a,b,c+2),now+1));
		bfs.push(mp(e(a+1,b+1,c),now+1));
		bfs.push(mp(e(a+1,b,c+1),now+1));
		bfs.push(mp(e(a,b+1,c+1),now+1));

	}		
	return 0;
}


Measured memory_bytes: 4608
N = int(input())

ans = []
for i in range(N):
    s = "".join(sorted(list(input())))
    ans.append(s)

ans = sorted(ans)

voc = "a"
A = 0
c = 0
for i in range(N):
    if voc == ans[i]:
        c += 1
    else:
        A += c * (c + 1) // 2
        c = 0
    voc = ans[i]

A += c * (c + 1) // 2

print(A)

Measured memory_bytes: 58328
a,b,c=map(int,input().split())
A=[a,b,c]
A.sort()
k=A[0]+(A[2]-A[1])
if (A[2]-k)%2==0:
    print(A[2]-A[1]+(A[2]-k)//2)
else:
    print(A[2]-A[1]+(A[2]-k)//2+2)

Measured memory_bytes: 3060
#何も思い浮かばない
#完全に負けた死にたいわかんない
#やっぱりDPだけど式が全く立てれない
#頭悪すぎしね
mod=10**9+7
s=input()
l=len(s)
dp=[[0]*4 for i in range(l)]
for i in range(l):
    if i==0:
        dp[i][3]=1
        if s[i]=="A":
            dp[i][0]=1
        elif s[i]=="?":
            dp[i][0]=1
            dp[i][3]=3
    else:
        if s[i]=="A":
            dp[i]=[(dp[i-1][0]+dp[i-1][3])%mod,dp[i-1][1],dp[i-1][2],dp[i-1][3]]
        elif s[i]=="B":
            dp[i]=[dp[i-1][0],(dp[i-1][0]+dp[i-1][1])%mod,dp[i-1][2],dp[i-1][3]]
        elif s[i]=="C":
            dp[i]=[dp[i-1][0],dp[i-1][1],(dp[i-1][1]+dp[i-1][2])%mod,dp[i-1][3]]
        else:
            dp[i]=[(3*dp[i-1][0]+dp[i-1][3])%mod,(3*dp[i-1][1]+dp[i-1][0])%mod,(3*dp[i-1][2]+dp[i-1][1])%mod,(3*dp[i-1][3])%mod]
print(dp[-1][2])

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

int main(){
    int n;
    cin >> n;

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

    int all = 0;
    for (int i = 1; i <= n + 1; i++){
        all += abs(a[i] - a[i - 1]);
    }

    for (int i = 1; i <= n; i++){
        int ans = all - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
def kaibun(n):
	s=str(n)
	sz=len(s)
	for i in range(int(sz//2)):
		if s[i]!=s[sz-i-1]:
			return False
	return True

def main():
	a,b=map(int,input().split())
	ans=0
	for i in range(a,b+1):
		if kaibun(i):
			ans+=1
	print(ans)

if __name__=="__main__":
	main()


Measured memory_bytes: 2940