akhauriyash/Code-Regression huggingface dataset:
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;

int H,W;
bool is_inside(int h,int w){
    return (0<=h && h<H && 0<=w && w<W);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    vector<string> Vs(H);
    REP(i,H) cin >> Vs[i];
    
    queue<pair<int,int>> q;
    q.push(mp(0,0));
    int h,w;
    int dh,dw,ch,cw;
    set<pair<int,int>> visited;
    int cnt=0;
    REP(i,H*W){
        queue<pair<int,int>> tmp;
        while(!q.empty()){

            tie(h,w) = q.front();q.pop();
            for(auto dhw:dxdy){
                tie(dh,dw) = dhw;
                ch=h+dh,cw=w+dw;

                if(is_inside(ch,cw)){
                    if(visited.find(mp(ch,cw)) == visited.end() && Vs[ch][cw]=='.') {
                        tmp.push(mp(ch,cw));
                        visited.insert(mp(ch,cw));
                    }
                }
                if (mp(ch,cw) == mp(H-1,W-1)){
                    cnt = i+2;
                }
            }   
        }   
        if(cnt!=0) break;
        q = tmp;
    }

    if (cnt==0){
        cout << -1 << endl;
        return 0;
    }
    int ans=H*W;
    REP(i,H){
        REP(j,W){
            ans-=(Vs[i][j]=='#');
        }
    }
    cout << ans-cnt << endl;
    
}

Measured memory_bytes: 384
object Main {

    def main(args: Array[String]): Unit = {
        val sc = new java.util.Scanner(System.in)
        val n, m, l = sc.nextInt

        val a = Array.fill(n, m)(sc.nextLong)
        val b = Array.fill(m, l)(sc.nextLong)
        val c = Array.ofDim[Long](n, l)

        for( i <- 0 until n ) {
            for( j <- 0 until l ) {
                for( k <- 0 until m ) c(i)(j) += a(i)(k)*b(k)(j)
            }
        }

        c.foreach(x => println(x.mkString(" ")))
    }
}



Measured memory_bytes: 72164
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int a, h, n, w;
    cin >> a;
    for (h = 1; h <= 4500; ++h)
        for (n = 1; n <= 4500; ++n)
            if (4 * h * n - a * (n + h) && a * h * n % (4 * h * n - a * (n + h)) == 0)
            {
                w = a * h * n / (4 * h * n - a * (n + h));
                if (w > 0)
                {
                    cout << h << " " << n << " " << w << endl;
                    return 0;
                }
            }
    return 0;
}

Measured memory_bytes: 3632
class SegmentTree:
    
    def __init__(self, n):
        self.n = n
        self.T = T = [2**31 - 1 for _ in range(2*n-1)]
        
    def update(self, i, x):
        i += self.n - 1
        self.T[i] = x
        while(i > 0):
            i = (i - 1) // 2
            self.T[i] = min(self.T[i*2+1], self.T[i*2+2])
            
    def find(self, a, b, k, l, r):
        if r<= a or b<= l:
            return 2**31 - 1
        if a <= l and r <= b:
            return self.T[k]
        vl = self.find(a, b, k*2+1, l,(l+r)//2)
        vr = self.find(a, b, k*2+2, (l+r)//2,r)
        return min(vl, vr)
    

n_, q = [int(i) for i in input().split()]
n = 1
while(n < n_):
    n *= 2
T = SegmentTree(n)
for _ in range(q):
    c, x, y = [int(i) for i in input().split()]
    if c == 0:
        T.update(x, y)
    else:
        print(T.find(x, y+1, 0, 0, n))


Measured memory_bytes: 9016
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int n, c;
	cin >> n >> c;
	int a[3][34];
	int d[34][34];
	for (int i = 0; i < 34;i++){
		a[0][i] = 0; a[1][i] = 0; a[2][i] = 0;
	}
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> d[i][j];
		}
	}
	int tmp;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> tmp;
			for (int k = 1; k <= c; k++) {
				a[(i + j) % 3][k] += d[tmp][k];
			}
		}
	}
	int mini = INT_MAX;
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			if (i == j)continue;
			for (int k = 1; k <= c; k++) {
				if (i == k || j == k)continue;
				mini = min(mini, a[0][i] + a[1][j] + a[2][k]);
			}
		}
	}
	cout << mini;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n;

int main(){
    cin >> n;
    string s = to_string(n);
    int n=s.length();
    int ans = s[n-1]-'0';
    if(ans==2||ans==4||ans==5||ans==7||ans==9)cout << "hon" << endl;
    else if(ans==0||ans==1||ans==6||ans==8)cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N, K, Q;
	cin >> N >> K >> Q;
	lls A;
	cinv(A, Q);

	lls seikaisu(N, 0);  //iさんの正解数seikaisu[i-1]

	for (ll i = 0; i < Q; i++) {
		seikaisu[A[i]-1]++;
	}

	for (auto e : seikaisu) {
		ll point = K - (Q - e);
		if (point > 0) { cout << "Yes" << '\n';; }
		else           { cout << "No" << '\n'; }
	}
	
	return 0;
}



Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    int a[2];
    int i;
    
    cin >> a[0] >> a[1];
    
    for(i = 0; i < 2; i++) {
        if((a[i]==1)||(a[i]==3)||(a[i]==5)||(a[i]==7)||(a[i]==8)||(a[i]==10)||(a[i]==12)) {
            a[i] = 100;
        } else if((a[i]==4)||(a[i]==6)||(a[i]==9)||(a[i]==11)) {
            a[i] = 200;
        }
    }
    
    if(a[0] != a[1]) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().strip()

def main():

    """
    <UnionFindを使わない別解>

    x方向とy方向に分けて頂点を辺だと思うのは定石？？？（確かに長方形がメインなら直積分解したくなる？）
    このとき問題文は「長さ３のパスがあればパスを１本追加する操作を繰り返して、各連結成分を完全二部グラフにせよ」

    完全二部グラフになるのは背理法からすぐわかる。なので解法は(¥Sum_{i:component}X_i Y_i) - N
    """

    N = int(input())
    V = 10 ** 5 + 1 # padding for y
    repn = [[] for _ in range(V * 2)]
    for _ in range(N):
        x, y = map(int, input().split())
        repn[x].append(V + y)
        repn[V + y].append(x)

    visited = [0] * (V * 2)
    count = [0, 0]

    # dfsでその都度連結成分を求める
    def dfs(v):
        if visited[v]:
            return
        visited[v] = 1
        count[v // V] += 1
        for u in repn[v]:
            dfs(u)

    ans = 0
    for i in range(V * 2):
        if visited[i]:
            continue
        count[:] = [0, 0]
        dfs(i)
        ans += count[0] * count[1]
    print(ans - N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 96768
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

string s;

int main() {
  init_ios();
  cin >> s;
  while (s.size() > 1) {
    int n = s.size();
    if (s[n-2] == 'h' && s[n-1] == 'i') {
      s.pop_back();
      s.pop_back();
      continue;
    }
    cout<<"No\n";
    return 0;
  }
  if (s.size())
    cout<<"No\n";
  else
    cout<<"Yes\n";
}

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

int main(){
  int n,sum=0;
  cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
    sum+=num[i];
  }
  int log,minnum=200;
  for(int i=0;i<n;i++){
    int a=abs(n*num[i]-sum);
    if(a==0){
      cout<<i<<endl;
      return 0;
    }else if(a<minnum){
      minnum=a;
      log=i;
    }
  }
  cout<<log<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int,int> 
#define int long long 


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int dp[n+1][3]={0};
		int arr[n][3];
		//arr[0]=0;
		rep(i,n){
			rep(j,3){
			cin>>arr[i][j];
			}
		}
		rep(i,n){
			rep(j,3){
				dp[i][j]=0;
			}
		}
		for(int i=1;i<=n;i++){
			rep(j,3){
				dp[i][j]=arr[i-1][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
			}
		}
		cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	}
	return 0;
}


Measured memory_bytes: 4992
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci V(N);
    veci C(N);
    REP(i,N) cin >> V[i];
    REP(i,N) cin >> C[i];
    int ans = 0;
    REP(i,N) {
        if(V[i] - C[i] >= 0) ans += V[i] - C[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      StringBuilder buf = new StringBuilder();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          buf.append(tree.getRoundPath());
        }
      }

      System.out.print(buf);

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  String getRoundPath() {
    buf.setLength(0);

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    return buf.toString();
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
#define int long long
#define double long double

const int N=705;

int n, m, check=1, ans2=1e9;
int ct0=0, ct1=0;
int col[N], vis[N], vis2[N][N], g[N][N];
vector<pair<int, int> > v;

void dfs(int k, int c)
{
	if(vis[k])
	{
		if(col[k]!=c)
		{
			check=0;
		}
		return;
	}
	vis[k]=1;
	ct0+=(c==0);
	ct1+=(c==1);
	col[k]=c;
	for(int i=1;i<=n;i++)
	{
		if(i!=k && g[k][i])
			dfs(i, c^1);
	}
}

void dfs2(int i, int taken)
{
	if(i==v.size())
	{
		ans2=min(ans2, (taken*(taken-1)/2) + ((n-taken)*(n-taken-1)/2));
		return;
	}
	if(vis2[i][taken])
		return;
	vis2[i][taken]=1;
	dfs2(i+1, taken+v[i].first);
	dfs2(i+1, taken+v[i].second);
}

int32_t main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u, v;
		cin>>u>>v;
		g[u][v]=1;
		g[v][u]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			g[i][j]=!g[i][j];
		}
	}
	int call=0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i])
			continue;
		call++;
		ct0=0;
		ct1=0;
		dfs(i, 0);
		v.push_back({ct0, ct1});
	}
	if(check==0)
	{
		cout<<"-1";
		return 0;
	}
	dfs2(0, 0);
	cout<<ans2;
}

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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0 ; i < n ; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for (int i = 0 ; i < k ; i++) {
            sum += l[n - 1 - i];
        }
        System.out.println(sum);
    }

}


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


int main(){
    string S; cin >> S;
    
    int ans = 0;
    string now = "", last = "";
    rep(i,S.size()){
        now += S[i];
        if(now != last){
            ans++;
            last = now; now ="";
        }
    }

    cout << ans << endl;
}


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

using namespace std;

int n,res;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    res = 1e9;
    for (int i=1;i<n;i++) {
        int a = i, b = n-i,sum=0;
        while (a>0) {
            sum += a%10;
            a /= 10;
        };
        while (b>0) {
            sum += b%10;
            b /= 10;
        };
        res = min(res,sum);
      //  cout<<a<<" "<<b<<" "<<sum<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

const int INF=1234567890;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

const int dx9[]={-1,-1,-1,0,1,1,1,0,0},dy9[]={-1,0,1,1,1,0,-1,-1,0};

#define MAX_HW 1000000

int d[MAX_HW];
vector <pii> g[MAX_HW];
void dijk(int V,int s){

  priority_queue <pii,vector<pii>,greater<pii> > que;
  fill(d,d+V,INF);

  d[s]=0;

  que.push(pii(0,s));

  for(;!que.empty();){

    pii p=que.top(); que.pop();
    int v=p.se;

    if (d[v]<p.fi) continue;

    for(int i=0;i<(int)g[v].size();i++){

      pii e=g[v][i]; //fiが場所、seがコスト

      if(d[e.fi]>d[v]+e.se){

	       d[e.fi]=d[v]+e.se;
	       que.push(pii(d[e.fi],e.fi));

      }
    }
  }
}

signed main(){

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

  vs s(h);

  cin>>s;

  int st=-1,go=-1;

  REP(i,h) REP(j,w){

    bool isbom=false;

    if(s[i][j] == 's') st=i*w+j;
    if(s[i][j] == 'g') go=i*w+j;

    REP(dir,9){

      int y=i+dy9[dir],x=j+dx9[dir];

      if(outG(y,h) || outG(x,w)) continue;

      if(s[y][x] == '*') isbom=true;

    }

    REP(dir,4){

      int y=i+dy[dir],x=j+dx[dir];

      if(outG(y,h) || outG(x,w)) continue;

      if(s[y][x] != '#') g[i*w+j].pb(mp(y*w+x,a));
      if(!isbom){

        g[i*w+j].pb(mp(y*w+x,a+b));

        int y_=y,x_=x;

        if(dy[dir]) x_+=dy[dir];
        else y_-=dx[dir];

        if(inG(y_,h) && inG(x_,w)) g[i*w+j].pb(mp(y_*w+x_,a*2+b));


        // y_=y,x_=x;
        //
        // if(dy[dir]) x_-=dy[dir];
        // else y_-=dx[dir];
        //
        // if(!(outG(y_,h) || outG(x_,w))) g[i*w+j].pb(mp(y_*w+x_,a*2+b));

      }

    }

  }

  dijk(h*w,st);

  if(d[go] == INF) cout<<"INF"<<endl;
  else cout<<d[go]<<endl;

  return 0;

}



Measured memory_bytes: 109772
import sys

s = input()

for i in range(2**3):
    sum = 0
    localsum = s[0]
    for j in range(3):
        if (i >> j) & 1:
            localsum += "+"
        else:
            localsum += "-"
        localsum += s[j+1]
    sum += eval(localsum)
    if sum == 7:
        localsum += "=7"
        print(localsum)
        sys.exit()

Measured memory_bytes: 9060
#include <stdio.h>

int main() {
	long long int n = 0, ac = 0, wa = 0, tle = 0, re = 0;
	char ver[5];
	
	scanf("%lld", &n);
	for(int i = 0; i < n; i++) {
		scanf("%s", ver);
		switch(ver[0]) {
			case 'A' :
				ac++;
				break;
			case 'W' :
				wa++;
				break;
			case 'T' :
				tle++;
				break;
			case 'R' :
				re++;
				break;
		}
	}
	printf("AC x %lld\nWA x %lld\nTLE x %lld\nRE x %lld", ac, wa, tle, re);
	
	return 0;
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double ans = 0;
  double x;
  string key;

  cin >> n;

  for(int i = 0;i < n;i++){
	cin >> x >> key;
	if(key == "JPY"){
	  ans += x;
	}else{
	  ans += (380000 * x);
	}
  }

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


Measured memory_bytes: 256
a, b = list(map(int, input().split()))
def division2(n):
    if(n % 2 == 0):
        return True
    else:
        return False
k = b - a + 1
if division2(k):##戸数が偶数
    if division2(a):
        if division2(k / 2):##個数の半分が偶数
            print(0)
        else:
            print(1)
    else:
        if division2((k - 2)/2):
            print(a ^ b)
        else:
            print(1 ^ a ^ b)
else:
    if division2(a):##最初がguu数
        if division2((k - 1) / 2):
            print(b)
        else:
            print(b ^ 1)
    else:
        if division2((k - 1) / 2):
            print(a)
        else:
            print(a ^ 1)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main(){
    int n;
    int length=1;
    cin >> n;
    int A[n+1];
    int L[n+1];
    for(int i = 1;i < n + 1;++i){
        cin >> A[i];
    }
    L[1] = A[1];

    for(int i = 1;i < n + 1;++i){
        if(L[length] < A[i]){
            L[++length] = A[i];
        }
        if(L[1] > A[i] ){
            L[1] = A[i];
        }
        else{
            int l = 1;
            int r = length;
            while(l <= r){
                int mid = (l + r)/2;
                if(A[i] == L[mid] || A[i] == L[mid + 1]){
                    break;
                }
                else if(A[i] < L[mid + 1] && L[mid] < A[i]){
                    L[mid + 1] = A[i];
                    break;
                }
                else if(A[i] < L[mid]){
                    r=mid;
                }
                else if(A[i] > L[mid]){
                    l=mid;
                }
            }
        }
    }
    cout << length << endl;
}

Measured memory_bytes: 1940
X,Y = map(int,input().split())
if X==Y==1:
    print(1000000)
elif X<=3 and Y<=3:
    print(((4-X)+(4-Y))*10**5)
else:
    print((4-min(X,Y))*10**5if 4-(min(X,Y))>=0else 0)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    set<char> a;
    for (auto x: s) a.insert(x);
    if (a.size() == s.size()) {
        puts("yes");
    }
    else {
        puts("no");
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()

	uf := newUnionFind(n)
	for i := 0; i < m; i++ {
		a := nextInt() - 1
		b := nextInt() - 1
		uf.unite(a, b)
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans = max(ans, uf.size(i))
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// UnionFind .
type UnionFind struct {
	par   []int
	rank  []int
	sizes []int
}

func newUnionFind(n int) UnionFind {
	u := UnionFind{}
	u.par = make([]int, n)
	u.rank = make([]int, n)
	u.sizes = make([]int, n)
	for i := 0; i < n; i++ {
		u.par[i] = i
		u.rank[i] = 0
		u.sizes[i] = 1
	}
	return u
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}

	if u.rank[x] < u.rank[y] {
		u.par[x] = y
		u.sizes[y] += u.sizes[x]
	} else {
		u.par[y] = x
		u.sizes[x] += u.sizes[y]
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) size(x int) int {
	return u.sizes[u.root(x)]
}


Measured memory_bytes: 9440
DMG = 0
MP = 1

H,N = gets.split(/ /).map(&:to_i)
KIND = readline('').split(/\r?\n/).map{|l| l.split(/ /).map(&:to_i)}.sort_by{|dmg,mp| dmg.to_f / mp}

dp = Array.new(H + 1, (H.to_f / KIND.last[DMG]).ceil * KIND.last[MP])
dp[0] = 0

1.upto(H) do |hp|
  KIND.each do |m|
    cost = (m[DMG] > hp ? 0 : dp[hp - m[DMG]]) + m[MP]
    dp[hp] = cost if dp[hp] > cost
  end
end

puts dp[H]

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

int main() {
	int a,b,c;
    cin >>a;
    vector<int> vec(a);
    for (int i = 0; i < a; i++) {
        cin >> vec.at(i);
	}
    vector<int> veca(a);
    for (int i = 0; i < a; i++) {
    cin >> veca.at(i);
	}
    int sum=0;
    for(int i=0;i<a;i++){
        if(vec.at(i)>=veca.at(i))
            sum+=vec.at(i)-veca.at(i);
    }
    cout<<sum<<endl;
}


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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int mx=100000+5 ;
int a[mx] ;
int b[mx] ;
int c[mx] ;
int f[mx][4] ;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n ;
	cin >> n ;
	for(int i =1 ; i<= n ; i++){
		cin >> a[i] >> b[i] >> c[i] ;
	}
	f[1][1] = a[1] ;
	f[1][2] = b[1] ;
	f[1][3] = c[1] ;
	for(int i =2 ; i<= n ;i++){
		f[i][1] = a[i]+max(f[i-1][2] , f[i-1][3]) ;
		f[i][2] = b[i]+max(f[i-1][1] , f[i-1][3]) ;
		f[i][3] = c[i]+max(f[i-1][1] , f[i-1][2]) ;
	}
	cout << max(f[n][1] , max(f[n][2],f[n][3])) ;
	return 0 ;
}


Measured memory_bytes: 6344
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: u64 = read_as_vec()[0];

    let nf = n as f64;

    if (nf/1.08).ceil() != ((nf+1.0)/1.08).ceil(){
        println!("{}", ((nf+1.0)/1.08).floor());
    }else{
        println!(":(");
    }
}


Measured memory_bytes: 4352
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N, S, W, Q;
	while (cin >> N >> S >> W >> Q, N) {
		vector<int> A(N);
		for (int i = 0; i < N; ++i) {
			A[i] = (S / 7) % 10;
			if (S % 2 == 0) S /= 2;
			else S = (S / 2) ^ W;
		}
		long long ans = 0;
		if (Q == 2 || Q == 5) {
			int cnt = 0;
			for (int i = 0; i < N; ++i) {
				if (A[i] != 0) ++cnt;
				if (A[i] % Q == 0) ans += cnt;
			}
		}
		else {
			map<int, int> tbl;
			++tbl[0];
			int pw = 1, tailsum = 0;
			for (int i = N - 1; i >= 0; --i) {
				tailsum = (tailsum + 1LL * A[i] * pw) % Q;
				if (A[i] != 0) ans += tbl[tailsum];
				++tbl[tailsum];
				pw = 10LL * pw % Q;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 7224
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		class Data {
			public int n;
			public int count;
			
			public Data(int n, int count) {
				this.n = n;
				this.count = count;
			}
		}
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		Queue<Data> queue = new ArrayDeque<>();
		queue.add(new Data(N, 0));
		
		for (; ;) {
			Data d = queue.poll();
			if (d.n == 0) {
				System.out.println(d.count);
				return;
			}
			
			int six = calc(d.n, 6);
			if (six > 0) queue.add(new Data(d.n - six, d.count + 1));
			int nine = calc(d.n, 9);
			if (nine > 0) queue.add(new Data(d.n - nine, d.count + 1));
			if (six == 0 && nine == 0) {
				queue.add(new Data(d.n - 1, d.count + 1));
			}
		}
	}
	
	private static int calc(int n, int a) {
		if (a > n) {
			return 0;
		}
		int b = a;
		
		while (true) {
			if (b * a > n) {
				break;
			} else {
				b *= a;
			}
		}
		
		return b;
	}
}

Measured memory_bytes: 25940
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) ((x)&(-(x)))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pr;

const ld inf = 2e18;
const int N = 1020;
const int maxn = 200020;
const ll mod = 998244353;

/*struct node{
	int next,to;
}e[maxn * 2];*/
vector <int> e[N];
int head[maxn],cnt;
int reach[N][N],vis[N],tag[N];
int n,m;
vector <pr> edge;

inline void adde(int x,int y){
	//e[++cnt].to = y;
	//e[cnt].next = head[x];
	//head[x] = cnt;
	e[x].pb(y);
}
void dfs(int x,int from){
//	if ( vis[x] >= 2 ) return;
	if ( !vis[x] ) vis[x] = 1 , tag[x] = from;
	else{
		if ( from != tag[x] ) vis[x]++;
		else return;
		if ( vis[x] > 2 ) return;
	}
	rvc(i,e[x]){
	//	dfs(e[i].to,from);
		if ( vis[e[x][i]] < 2 ) dfs(e[x][i],from);
	}
}
void solve(int id){
	rep(i,1,n) vis[i] = 0;
	vis[id] = n;	
	rvc(i,e[id]){
		dfs(e[id][i],e[id][i]);
	}
	rep(i,1,n){
		reach[id][i] = vis[i];
	}
}
int main(){
	scanf("%d %d",&n,&m);
	rep(i,1,m){
		int x,y;
		scanf("%d %d",&x,&y);
		adde(x,y);
		edge.pb(mp(x,y));
	}
	rep(i,1,n) solve(i);
//	rep(i,1,n) rep(j,i + 1,n){
//		cout<<i<<" "<<j<<" "<<reach[i][j]<<endl;
//		cout<<j<<" "<<i<<" "<<reach[j][i]<<endl;
//	}
	rep(i,0,m - 1){
		int x = edge[i].fi , y = edge[i].se;
		if ( reach[x][y] > 1 && reach[y][x] ) puts("same");
		else if ( reach[x][y] == 1 && !reach[y][x] ) puts("same");
		else puts("diff");
	}
}


Measured memory_bytes: 8432
#include<iostream>

using namespace std;

int main(void) {
	long long k, ans;
	cin >> k;
	ans = (k / 11) * 2;
	k %= 11;
	if (k != 0 && k <= 6)
		ans++;
	else if(k > 6)
		ans += 2;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[123456];
signed main() {
	int n, m, a, b = 1, ans = 0; cin >> n;
	while (n > 0) {
		ans += b; b *= 2;
		n /= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


long t[105];
long v[105];
long h[105];
long st[105];

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &t[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%ld", &v[i]);
    }
    st[0]=0;
    for(i=1; i<=n; i++) {
        st[i]=st[i-1]+t[i-1];
    }

    h[0]=h[n]=0;
    for(i=1; i<n; i++) {
        h[i] = MIN(v[i-1], v[i]);
    }

    long j;
    for(i=1; i<n; i++) {
        for(j=0; j<=n; j++) {
            h[i] = MIN(h[i], h[j]+abs(st[j]-st[i]));
        }
    }

    double ss = 0.0;
    for(i=0; i<n; i++) {
        double tmp=0;
        double tmp2 = (double)(t[i]+h[i]+h[i+1])/2.0;
        if( v[i] >tmp2 ) {
            tmp= (double)t[i] * tmp2 - (double)(tmp2-h[i])*(tmp2-h[i])*0.5 - (double)(tmp2-h[i+1])*(tmp2-h[i+1])*0.5;
        }
        else {
            tmp= (double)t[i] * v[i] - (double)(v[i]-h[i])*(v[i]-h[i])*0.5 - (double)(v[i]-h[i+1])*(v[i]-h[i+1])*0.5;
        }
        ss += tmp;
    }

    printf("%.8lf\n", ss);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] ac = new int[n];
    int[] wa = new int[n];
    for(int i = 0; i < m; i++) {
      int p = sc.nextInt() - 1;
      String s = sc.next();
      if(s.equals("AC")) {
        ac[p] = 1;
      } else {
        if(ac[p] == 0) wa[p]++;
      }
    }
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < n; i++) {
      if(ac[i] == 1) {
        ans1++;
        ans2 += wa[i];
      }
    }
    System.out.println(ans1 + " " + ans2);
  }
}


Measured memory_bytes: 65324
# queueのライブラリをインポート
import queue

n,m = map(int,input().split())
# 各都市から繋がっている都市を記録
road = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)
ans = 0
# まだ訪れていない都市を記録
city = set(i for i in range(n))
# まだ訪れていない都市がある間繰り返す
while len(city):
  # queueを用意する
  q = queue.Queue()
  # 初期値としてまだ訪れていない都市を入れる
  q.put(city.pop())
  # 1つのグループを全て辿る
  while not q.empty():
    x = q.get()
    for i in road[x]:
      # 既に訪れたか調べる
      if i in city:
        # 訪れていなければqueueに追加する
        q.put(i)
        # 未訪問の都市のリストから除外する
        city.discard(i)
  # まだ訪れていない都市があれば答えを増やす
  if len(city):
    ans += 1
print(ans)

Measured memory_bytes: 34544
import heapq
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort(reverse = True)
que = []
def div(a,b):
    if a % b == 0:
        return a//b
    else:
        return a//b + 1
for i in range(n):
    heapq.heappush(que,-a[i])
for i in range(m):
    p = heapq.heappop(que)
    p = div(p,2)
    heapq.heappush(que,p)
print(-sum(que))

Measured memory_bytes: 64484
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    cout << fixed << setprecision(5);

    double a, b, c, S, L, h, PI;
    int C;

    PI = acos(-1);
    cin >> a >> b >> C;

    S = a * b * sin(C*PI/180) / 2;
    c = sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(C*PI/180));
    L = a + b + c;
    h = 2 * S / a;

    cout << S << endl;
    cout << L << endl;
    cout << h << endl;

    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

using pint = pair<int, int>;
using ppint = pair<pint, pint>;

int main() {
	int h, w;
	cin >> h >> w;

	vvi a(h, vi(w));
	int odd = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] & 1) ++odd;
		}
	}

	vector<ppint> res;
	int num = 0;
	int x = 0, y = 0;
	for (int itr = 0; itr < w * h; ++itr) {
		//cout << x << " " << y << endl;
		if (a[x][y] & 1) ++num;

		int nx = x, ny = y;
		if (x % 2 == 0) {
			if (ny == w - 1) ++nx;
			else ++ny;
		}
		else {
			if (ny == 0) ++nx;
			else --ny;
		}

		if (num & 1) if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
		x = nx, y = ny;
	}

	cout << res.size() << endl;
	for (auto p : res) {
		cout << p.first.first + 1 << " " << p.first.second + 1 << " " << p.second.first + 1 << " " << p.second.second + 1 << endl;
	}
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define L "\n"
#define S " "
#define ll long long
#define pb push_back
#define mp make_pair
#define vi std::vector<int>
#define si std::set<int>
#define vl std::vector<long long>
#define qi std::queue<int>
#define de(a) cout << #a << "  ------>  " << a << "\n"
#define SIZE 3002
#define INF INT_MAX
#define FOR(i, n) for (i = 1; i <= n; i++)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;
double p[SIZE];
int n;

double dp[SIZE][SIZE];
bool flag[SIZE][SIZE];

double f(int i, int no){
    flag[i][no] = 1;
    double a1, a2;
    if(no < 0) return 0;
    if(i == n){
        if(no == 0){return dp[i][no] = 1 - p[i];}
        else if(no == 1){ return dp[i][no] = p[i];}
        else {return dp[i][no] = 0;}
    }
    if(flag[i + 1][no - 1]) a1 = p[i] * dp[i + 1][no - 1];
    else a1 = p[i] * f(i + 1, no - 1);
    if(flag[i + 1][no]) a2 = (1 - p[i]) * dp[i + 1][no];
    else a2 = (1 - p[i]) * f(i + 1, no);

    return dp[i][no] = a1 + a2;
}

void solve()
{
    int i, mnm;
    double prob = 0.0;
    cin >> n;
    FOR(i, n) cin >> p[i];
    mnm = n/2 + 1;
    for(i = mnm ; i <= n ; i++){
        prob += f(1, i);
    }
    // cout << prob << L;
    printf("%.12lf\n", prob);
}
int main()
{
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    // #endif
    int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 79616
n = int(input())
res = ""
for i in range(1,100):
    a = n % 26
    if n <= 26:
        break

    n = int(n / 26)
    
    if a == 0:
        res = "z" + res
        n -= 1
    if a == 1:
        res = "a" + res
    if a == 2:
        res = "b" + res
    if a == 3:
        res = "c" + res
    if a == 4:
        res = "d" + res
    if a == 5:
        res = "e" + res
    if a == 6:
        res = "f" + res
    if a == 7:
        res = "g" + res
    if a == 8:
        res = "h" + res
    if a == 9:
        res = "i" + res
    if a == 10:
        res = "j" + res
    if a == 11:
        res = "k" + res
    if a == 12:
        res = "l" + res
    if a == 13:
        res = "m" + res
    if a == 14:
        res = "n" + res
    if a == 15:
        res = "o" + res
    if a == 16:
        res = "p" + res
    if a == 17:
        res = "q" + res
    if a == 18:
        res = "r" + res
    if a == 19:
        res = "s" + res
    if a == 20:
        res = "t" + res
    if a == 21:
        res = "u" + res
    if a == 22:
        res = "v" + res
    if a == 23:
        res = "w" + res
    if a == 24:
        res = "x" + res
    if a == 25:
        res = "y" + res
        
if a == 0:
    res = "z" + res
if a == 1:
    res = "a" + res
if a == 2:
    res = "b" + res
if a == 3:
    res = "c" + res
if a == 4:
    res = "d" + res
if a == 5:
    res = "e" + res
if a == 6:
    res = "f" + res
if a == 7:
    res = "g" + res
if a == 8:
    res = "h" + res
if a == 9:
    res = "i" + res
if a == 10:
    res = "j" + res
if a == 11:
    res = "k" + res
if a == 12:
    res = "l" + res
if a == 13:
    res = "m" + res
if a == 14:
    res = "n" + res
if a == 15:
    res = "o" + res
if a == 16:
    res = "p" + res
if a == 17:
    res = "q" + res
if a == 18:
    res = "r" + res
if a == 19:
    res = "s" + res
if a == 20:
    res = "t" + res
if a == 21:
    res = "u" + res
if a == 22:
    res = "v" + res
if a == 23:
    res = "w" + res
if a == 24:
    res = "x" + res
if a == 25:
    res = "y" + res
print(res)

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int N;
    
    cin >> N;
    
    long long a[N];
    
    for(int i = 0; i < N; i++) cin >> a[i];
    
    bool flag = false;
    int ans = 0;
    
    while(true){
        
        for(int i = 0; i < N; i++){
            
            if(a[i]%2 == 0){
                a[i] = a[i]/2;
                flag = true;
                break;
            }
            
        }
        
        if(flag) ans++;
        else break;
        
        flag = false;
        
    }
    
    cout << ans << endl;

    
}

Measured memory_bytes: 384
import sys
n=int(input())
a=[int(input())-1 for i in range(n)]
used=[0]*n
cur=0
cnt=0
while not used[cur]:
    if cur==1:
        print(cnt)
        sys.exit()
    used[cur]=1
    cnt+=1
    cur=a[cur]

print(-1)

Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  int n,m;
  if(a%d==0){
    n=a/d;
  }
  if(a%d!=0){
    n=a/d+1;
  }
  if(c%b==0){
    m=c/b;
  }
  if(c%b!=0){
    m=c/b+1;
  }
  
  Ans(n>=m);
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
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 (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
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 ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, A, B := sc.nextInt(), sc.nextInt(), sc.nextInt()
	X := sc.nextIntSlice(N)
	ans := 0
	for i := 1; i < N; i++ {
		d := X[i] - X[i-1]
		if B < d*A {
			ans += B
		} else {
			ans += d * A
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a-x) < abs(b-x)) cout << "A" << endl;
  else cout << "B" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
int a[10][10];

int main() {
	int h, w;
	LL s = 0;
	scanf("%d%d", &h, &w);
	for(int i = 0; i <= 9; i++) 
		for(int j = 0; j <= 9; j++) 
			scanf("%d", &a[i][j]);
	for(int k = 0; k <= 9; k++) 
		for(int i = 0; i <= 9; i++) 
			for(int j = 0; j <= 9; j++) 
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	for(int i = 1; i <= h * w; i++) {
		int n;
		scanf("%d", &n);
		if(n != 1 || n != -1) s += a[n][1];
	}
	printf("%lld\n", s);
	return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); //for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int a[3001+1][3001+1];
int dp[3002][3002][4];
int32_t main()
{
    IOS
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif    

	int r,c,k;
	cin>>r>>c>>k;

	memset(a,0,sizeof(a));
	for(int i=1;i<=k;i++)
	{
		int x,y,val;
		cin>>x>>y>>val;
		a[x][y]=val;
	}
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=r;i++)
	{
		for(int j=1;j<=c;j++)
		{
			for(int k=0;k<=3;k++)
			{
				dp[i][j][k]=dp[i][j-1][k];
			}
			for(int k=0;k<=3;k++)
			{
				dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
			}
			if(a[i][j]!=0)
			{
				for(int k=0;k<=3;k++)
				{
					dp[i][j][1]=max(dp[i-1][j][k]+a[i][j],dp[i][j][1]);
				}	
				for(int k=1;k<=3;k++)
				{
					dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+a[i][j]);
				}	
			}
			
		}
	}
	int ans=0;
	for(int k=0;k<=3;k++)
		ans=max(ans,dp[r][c][k]);
	cout<<ans<<endl;
}    



Measured memory_bytes: 355692