akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

ll n,k;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;
    /* end code */
	return 0;
}

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

string S, T;
vector<vector<int64_t>> inS(26);

int64_t solve(char ch, int64_t p){
  int c = ch - 'a'; 
  if(inS[c].empty()) return -p;

  p %= S.length();
  int res = lower_bound(inS[c].begin(), inS[c].end(), p) - inS[c].begin();
  return inS[c][res] + 1 - p;
}
 
int main(){
  cin >> S >> T;
  
  string S2 = S+S;
  for(int i=0; i<S2.length(); i++) inS[S2[i]-'a'].push_back(i);
  
  int64_t ans = 0;
  for(int i=0; i<T.length(); i++){
    ans += solve(T[i], ans);
    if(ans == 0){
      cout << -1 << endl; return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define mod 1000000007
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int main(){
	int n,m;
	while(cin>>m>>n&&n+m){
		priority_queue<P,vector<P>,greater<P> >Q;
		vector<PP> v[110];
		int dis[110];
		lol(i,m){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			v[a].push_back(make_pair(b,make_pair(c,d)));
			v[b].push_back(make_pair(a,make_pair(c,d)));
		}
		cin>>m;
		lol(u,m){
			lol(i,n)dis[i+1]=mod;
			int s,t,c;cin>>s>>t>>c;
			Q.push(make_pair(0,s));
			while(!Q.empty()){
				int b=Q.top().first,a=Q.top().second;
				Q.pop();
				if(dis[a]<mod)continue;
				dis[a]=b;
				lol(i,v[a].size()){
					int to=v[a][i].first,co=b+(c?v[a][i].second.second:v[a][i].second.first);
					if(dis[to]==mod)Q.push(make_pair(co,to));
				}
			}
			cout<<dis[t]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<string>

using namespace std;

bool solve(string s) {
    int n = s.size();
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[n - 1 - i])
        {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string a, b;
    a = s.substr(0, n / 2);
    b = s.substr((n + 1) / 2, n / 2);
    bool ans = solve(a) && solve(b) && solve(s);
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	ll all = pow(3, n);
	ll ki = 1;
	rep(i, n){
		int in;
		cin >> in;
		if(in%2 == 0) ki *= 2;
	}
	cout << all - ki << endl;
	return 0;
}

Measured memory_bytes: 640
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x: i32 = sc.read();
    let y: i32 = sc.read();

    if x % y != 0 {
        println!("1");
    } else {
        println!("0");
    }
}



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

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

using namespace std;

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a(n);
  std::map<int, int> map;
  rep(i, n) {
    int tmp;
    std::cin >> tmp;
    a[i] = tmp;
    map[tmp]++;
  }

  std::vector<int> v;
  int num = 0;
  for (auto i : map) {
    num++;
    v.push_back(i.second);
  }

  sort(v.begin(), v.end());

  int ans = 0;
  rep(i, num - k) { ans += v[i]; }

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

  return 0;
}


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

int main()
{
    int a,b,sum=0,t=2;
    cin>>a>>b;
    while(t--){
    if(a>b) {
        sum+=a;
        a--;}
        else {
            sum+=b;
            b--;}}
            cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    set<ll> st;
    ll ct = 0;

    rep(i, N){
        ll x;
        cin >> x;
        if(x < 3200) st.insert(x / 400);
        if(x >= 3200) ++ct;
    }

    cout << max(len(st), 1LL) << " " << len(st) + ct << endl;

    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
M = [[0]*(W+1) for _ in range(H+1)]
for i in range(H):
    M[i+1][1:] = list(map(int,input().split()))

dp = [[0]*(W+1) for _ in range(H+1)]
for h in range(1,H+1):
    for w in range(1,W+1):
        if M[h][w] == 0:
            dp[h][w] = min(dp[h-1][w-1],dp[h-1][w],dp[h][w-1]) + 1
        else:
            dp[h][w] = 0

print(max([max(x) for x in dp])**2)

        



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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while (A > 0 && C > 0){
    C -= B;
    if (C <= 0){
      cout << "Yes" << endl;
      break;
    } else {
      A -= D;
      if (A <= 0){
        cout << "No" << endl;
      }
    }
  }
 
  
  
}



Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int K = Integer.parseInt(in.next());
            Integer[] H = new Integer[N];
            long ans = 0;
            for (int i = 0; i < N; i++) {
                H[i] = Integer.valueOf(in.next());
                ans += H[i];
            }
            Arrays.sort(H, Collections.reverseOrder());
            if (K > N) K = N;
            for (int i = 0; i < K; i++) {
                ans -= H[i];
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 64216
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n = 0;
  int l[110] = {0};
  int all=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  
  sort(l,l+n, greater<int>());
  for(int i=1;i<n;i++){
    all+=l[i];
  } 
  if(all > l[0]) {
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }  
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	bool can = false;
	rep(i, 9) {
		if(N%(i+1)==0) {
			if(N/(i+1) <= 9) can = true; 
		}
	}
	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<iostream>
#include <algorithm>
using namespace std;

class DICE
{
private:
	const int dice_tem[4][6] = { { 3,2,6,1,5,4 },{ 2,6,3,4,1,5 },
	{ 5,1,3,4,6,2 },{ 4,2,1,6,5,3 } };
	const int sort_num[6] = { 1,4,2,5,3 ,6 };
	static int top;
	static int front;
	const int n = 6;
	int dice_i[6] = { 0 };
	int dice_j[6] = { 0 };
	int ee[6];
	int p;

	void setup() {
		for (int i = 0; i < n; i++) {
			cin >> dice[i];
			dice_i[i] = dice[i];
			ee[i] = dice[i];
		}
		sort(ee,ee+n);
		for (int i = 0, o = 0; i < n && o < 2; i++) {
			ee[o] = ee[i];
			if (ee[m] != ee[i])o++;
		}
		if (m == 0) {
			top = ee[0];
			front = ee[1];
		}
	}

	void dice_sort() {
		for (int d = 0; dice_i[0] != top; d++) {
			for (int i = 0; i < n; i++) {
				dice_j[i] = dice_i[dice_tem[d % 2][i] - 1];
			}
			for (int i = 0; i < n; i++)dice_i[i] = dice_j[i];
		}
		for (p = 0; p < 4; p++) {
			for (int i = 0; i < n; i++) {
				dice_j[i] = dice_i[dice_tem[p][i] - 1];
			}
			if (front == dice_j[0]) break;
		}
		int a = p == 0 ? 3 : p == 1 ? 0 : p == 2 ? 2 : p == 3 ? 1 : -1;
		if (a == 0) {
			for (int i = 0; i < n; i++)sort_dice[i] = dice_i[i];
		}
		else {
			for (int q = 0; q < a; q++) {
				for (int i = 0; i < n; i++)	sort_dice[i] = dice_i[sort_num[i] - 1];
				for (int i = 0; i < n; i++) dice_i[i]=sort_dice[i];
				
			}
		}
	}

public:
	int dice[6];
	int sort_dice[6];
	static int m;
	DICE() {
		setup();
		dice_sort();
		m++;
	}
};
int DICE::m = 0;
int DICE::top = 0;
int DICE::front = 0;
int main() {
	const int n = 6;
	bool flag = true;
	DICE i = DICE();
	DICE j = DICE();
	for (int w = 0; w < n; w++) {
		if (i.sort_dice[w] != j.sort_dice[w])flag = false;
	}
	if (flag == true) {
		cout << "Yes" << endl;
	}
	else if (flag == false) {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
import           Data.Ratio

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  print $ solve n k

solve :: Int -> Int -> Double
solve n k = realToFrac $ (1 % n) * sum [(1 % 2) ^ f i | i <- [1 .. n]] where
  f i = length . takeWhile (< k) $ iterate (* 2) i


Measured memory_bytes: 1020
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI p(n);
    REP(i, n) {
        cin >> p[i];
        p[i]--;
    }

    VI a(n), b(n);
    a[0] = 1;
    FOR(i, 1, n) {
        a[i] = a[i - 1] + n;
    }
    b[n - 1] = 1;
    for (int i = n - 2; i >= 0; --i) {
        b[i] = b[i + 1] + n;
    }
    REP(i,n){
        b[p[i]] += i;
    }

    REP(i,n){
        cout<< (i==0?"":" ") << a[i];
    }
    cout <<  endl;
    REP(i,n){
        cout<< (i==0?"":" ") << b[i];
    }
    cout <<  endl;

    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
        double x = Double.parseDouble(sc.next());
        
        if(x < a*a*b/2){
            double c = (2*x)/(a*b);
            double d = b/c;
            System.out.println(Math.toDegrees(Math.atan(d)));
        }else{
            double c = (2*(a*a*b - x))/(a*a);
            double d = c/a;
            System.out.println(Math.toDegrees(Math.atan(d)));
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e8 + 7;

int main() {
    int n,m;
    cin >> n >> m;
    int fib[n];
    int a[m+2];
    REP(i, m) {
        scanf("%d", &a[i]);
        a[i]--;
    }
    if (m<1) {
        a[0] = -1;
        a[1] = -1;
    } else if (m<2) {
        a[1] = -1;
    }
    int a_index = 0;
    if (a[0] == 0) {
        // 1だんめ死
        fib[0] = 0;
        a_index++;
        if (a[1] == 1) {
            // 1だんめも2だんめも死
            fib[1] = 0;
            a_index++;
        } else {
            fib[1] = 1;
        }
    } else if (a[0] == 1) {
        fib[0] = 1;
        fib[1] = 0;
        a_index++;
    } else {
        fib[0] = 1;
        fib[1] = 2;
    }
    for(int i=2; i<n; i++) {
        fib[i] = fib[i-1] + fib[i-2];
        if(a[a_index] == i) {
            fib[i] = 0;
            if(a_index != m) a_index++;
        } else {
            fib[i] = fib[i] % MOD;
        }
    }
    OUT(fib[n-1]);
    return 0;
}

/*
1 -> 1
2 -> 2
3 -> 0
4 -> 2
5 -> 2
6 -> 4
fibなので
*/

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
f={}
f2={}
for i in range(n):
    z=i+a[i]
    z1=i-a[i]
    #print(z,z1)
    try:
        f[z]+=1
    except:
        f[z]=1
    try:
        f2[z1]+=1
    except:
        f2[z1]=1
s=0
for i in f.keys():
    if(i in f2):
        s+=f[i]*f2[i]
print(s)


Measured memory_bytes: 145912
#include <iostream>

int main(){
	int **array;
	int r,c;
	std::cin>>r>>c;
	array=new int*[r+1];
	for(int i=0;i<r+1;i++){
		array[i]=new int[c+1];
		for(int j=0;j<c+1;j++){
			array[i][j]=0;
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			std::cin>>array[i][j];
			array[i][c]+=array[i][j];
			array[r][j]+=array[i][j];
			array[r][c]+=array[i][j];
		}
	}
	for(int i=0;i<r+1;i++){
		for(int j=0;j<c+1;j++){
			std::cout<<(j?" ":"")<<array[i][j];
		}
		std::cout<<std::endl;
	}

	return 0;
}

Measured memory_bytes: 1236
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            
            int[] list = new int[n];
            
            for(int i=0; i<n; i++){
            	int a = sc.nextInt();
            	list[i] =a;
            }
            Arrays.sort(list);
            int sum1 = 0;
            int sum2 = 0;
            for(int i=0; i<n; i+=2){
            	sum1 += list[i];
            	if(i!=n-1){
            		sum2 += list[i+1];
            	}
            }
            //出力
            System.out.println(Math.abs(sum1 - sum2));
            sc.close();
        }
    }

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> x >> a >> b;
	A = x - a;
	if (A < 0) {
		A *= -1;
	}
	B = x - b;
	if (B < 0) {
		B *= -1;
	}
	if (A > B) {
		cout << "B";
	}
	else {
		cout << "A";
	}
}

Measured memory_bytes: 256
n = int(input())
s = {}
for i in range(n):
  text = ''.join(sorted(input()))
  if text in s:
    s[text] += 1
  else:
    s[text] = 1

sum = 0
for v in s.values():
  sum += (v*(v-1)//2)
print(sum)

Measured memory_bytes: 17852
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  long long int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
string A,B,C;
int main(){
    map<char,int> m;
    string str;cin >> str;
    FOREACH(a,str){
        if(m.find(a)==m.end()){
            m[a]=1;
        }else{
            m[a]++;
        }
    }
    FOREACH(a,m){
        if(a.second%2!=0){
            COUT("No");
            return 0;
        }
    }
    COUT("Yes");
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque, defaultdict
N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

graph = defaultdict(set)
visited = [False for _ in range(N)]

for x,y in xy:
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

def dfs(v):
    que = deque()
    vis_list = []
    visited[v] = True
    vis_list.append(v)
    que.append(v)
    while len(que) > 0:
        i = que.pop()   #深さ優先探索
        # i = que.popleft() #幅優先探索
        for n in list(graph[i]):
            if visited[n] == False:
                visited[n] = True
                vis_list.append(n)
                que.append(n)

    return vis_list

grps = []
for i in range(N):
    if visited[i] == False:
        grps.append(dfs(i))

ans = 0
for g_list in grps:
    if len(g_list) == 1:
        if g_list[0] == p[g_list[0]]-1:
            ans += 1
    else:
        tmp = set([])
        for i in g_list:
            tmp.add(p[i]-1)
        ans += len( set(g_list) & tmp)

print(ans)


Measured memory_bytes: 119660
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int H,W;
    cin >> H >> W;
    vector<vector<char>>s(H+2,vector<char>(W+2,'.'));
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            char x;
            cin >> x;
            s[i][j] = x;
        }
    }
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            if(s[i][j] == '.') {
                continue;
            }
            if(s[i-1][j] != '#' && s[i+1][j] != '#' &&
               s[i][j-1] != '#' && s[i][j+1] != '#') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 256
import sys
f=lambda:tuple(map(int,sys.stdin.readline().split()))
n,m,k=f()
lta=[f() for _ in range(m)]
ltb=[f() for _ in range(k)]
p=[-1]*n
def root(x):
  while p[x]>=0: x=p[x]
  return x
def unite(x,y):
  x,y=root(x),root(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return -p[root(x)]
l=[0]*n
for a,b in lta:
  unite(a-1,b-1)
  l[a-1]-=1
  l[b-1]-=1
for c,d in ltb:
  if same(c-1,d-1):
    l[c-1]-=1
    l[d-1]-=1
for i in range(n):
  l[i]+=size(i)-1
print(*l)

Measured memory_bytes: 38412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int n = Math.abs(A - B);
        if (n % 2 == 0) {
            if (A < B) {
                System.out.println(B - n / 2);
            } else {
                System.out.println(A - n / 2);
            }
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
        string t;cin>>t;
        int cnt = 0;
        rep(i,7){
            if(t == s[i])break;
            cnt++;
        }
        cout<<7-cnt;
    }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define vi vector<int>
#define mi map<int,int>
#define mc map<char,int>

//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int n,T,c;
     cin>>n>>T;
     vi A(n),B(n),C;
     for(int i=0;i<n;i++){
		 cin>>A[i]>>B[i];
		 }
		 for(int i=0;i<n;i++){
			 if(B[i]<=T){
				 C.push_back(A[i]);
				 }
			 }
			 c=*min_element(C.begin(),C.end());
			 if(C.size()==0){cout<<"TLE" <<"\n";}
			 else{cout<<c <<"\n";}
}


Measured memory_bytes: 3656
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N,D,x,y,ans=0;
    cin >> N;
    cin >> D;
    for(int i=0;i<N;i++){
        cin >> x;
        cin >> y;
        if(pow(pow(x,2)+pow(y,2),0.5)<=D) ans++; 
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 4248
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	double r;
	cin >> r;
	cout << fixed << setprecision(10)
		 << M_PI * r * r << " "
		 << 2 * M_PI * r << endl;
}



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

int main() {
long long int x,k,d,w;
cin>>x>>k>>d;
if(x<0)
{x=-x;}
w=x/d;
if(w<=k)
{
if((k-w)%2==0)
{


cout<<x%d<<endl;

}
else{
cout<<d-x%d<<endl;
}
}
else{
cout<<x%d+(w-k)*d<<endl;
}


}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
bool check(vector <int> &before, vector <int> &after){
    for (int i=0;i<after.size();i++){
       // cout<<before [i] <<' ' <<after[i]<<endl;
        if(before[i]!= after[i]) return 1;
    }
    return 0;
}
int main(void){
    int n; cin>>n;
    int count=0;
    vector <int> after(n);
    for(int i=0;i<n;i++){
        cin>>after[i];
        
    }
    vector <int> before(n);
    while (check(before,after)){
        for(int i=0;i<n;i++){
        if(before[i]!=after[i]){
            before[i]++;
            if(i+1==n) break;
        if(before[i+1]==after[i+1]) break;
        }
        
        }
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    import math
    n=I()
    mini=1e+13
    for i in range(1,int(math.sqrt(n))+1):
        if n%i==0:
            mini=min(mini,i+(n//i)-2)
    print(mini)
    

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0] * M
X = [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())

for i in range(M):
    print(sum(T[: P[i] - 1]) + X[i] + sum(T[P[i]:]))


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

int main(){
  int a, b, k; cin >> a >> b >> k;
  vector<int> vec;
  for(int i=1;i<=max(a,b);i++){
    if(a % i == 0 && b % i == 0) vec.push_back(i);
  }
  reverse(vec.begin(), vec.end());
  cout << vec[k-1] << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(void){
  char str[2000];
  char *adr1,*adr2;
  scanf("%s",str);
  adr1 = strchr(str,(int)'7');
  if(adr1 == '\0'){
printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 1732
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
    static String INPUT = "";

    public static void main(String[] args) {
        InputStream is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());

        Scanner scanner = new Scanner(is);

        int n = scanner.nextInt();

        boolean[][] isOpen = new boolean[n][];

        for (int i = 0; i < n; i++) {
            isOpen[i] = new boolean[10];
            for (int j = 0; j < 10; j++) {
                isOpen[i][j] = scanner.nextInt() == 1;
            }
        }

        int[][] profit = new int[n][];
        for (int i = 0; i < n; i++) {
            profit[i] = new int[11];
            for (int j = 0; j < 11; j++) {
                profit[i][j] = scanner.nextInt();
            }
        }

        int ret = solve(isOpen, profit);
        System.out.println(ret);
    }

    static int solve(boolean[][] isOpen, int[][] profit) {
        int limit = 1 << 10;
        int max = Integer.MIN_VALUE;
        for (int k = 1; k < limit; k++) {
            int profitSum = 0;
            for (int i = 0; i < isOpen.length; i++) {
                int count = 0;
                for (int j = 0; j < 10; j++) {
                    if (((k >> j) & 1) == 1 && isOpen[i][j]) {
                        count++;
                    }
                }
                profitSum += profit[i][count];
            }
            max = Math.max(max, profitSum);
        }
        return max;
    }

    static boolean[] primeSieve(int n) {
        boolean[] isPrime = new boolean[n];
        for (int i = 0; i < isPrime.length; i++) {
            isPrime[i] = true;
        }
        isPrime[1] = false;
        int limit = (int) Math.ceil(Math.sqrt(n));
        for (int i = 2; i < limit; i++) {
            for (int j = 2; j * i < n; j++) {
                isPrime[j * i] = false;
            }
        }
        return isPrime;
    }
}


Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  sort(ALL(x));
  sort(ALL(y));
  int Z = min(Y, y[0]);
  if (Z > X && x[n-1] < Z) cout << "No War\n";
  else cout << "War\n";

}

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

int main()
{

	int  n, m;
	cin >> n >> m;
	double total = 0;
	double a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		total += a[i];
	}
	double v = 4 * m;
	double d = (total / v);
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= d)
			ans++;
	}

	if (ans >= m)
		cout << "Yes" << "\n";

	else
		cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define FAIL { cout << "NO\n"; return 0; }

int main() {
    int a[3] = {}, i, N = 0;
    char c;

    while (cin >> c) {
        if (c == '=') break;
        a[(int)(c-'a')]++;
        N++;
    }
    sort(a, a+3, greater<int>()); // descending

    for (i = 0; i < 3; i++) {
        if (1+i+3*(a[i]-1) > N) FAIL;
    }
    cout << "YES\n";
}

Measured memory_bytes: 256
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>

const char main_[] = {
	0x48, 0xc7, 0xc1, 0x01, 0x00, 0x00, 0x00,
	0x4d, 0x31, 0xc0,
	0x4d, 0x31, 0xc9,
	0x49, 0x89, 0xd2,
	0x49, 0xc7, 0xc3, 0x0a, 0x00, 0x00, 0x00,
	0x48, 0x89, 0xc8,
	0x48, 0x31, 0xd2,
	0x49, 0xf7, 0xf3,
	0x49, 0x83, 0xe8, 0x09,
	0x48, 0x83, 0xfa, 0x00,
	0x74, 0xf3,
	0x49, 0x83, 0xc0, 0x0a,
	0x4c, 0x39, 0xc6,
	0x77, 0x08,
	0x4d, 0x39, 0xc2,
	0x72, 0x03,
	0x49, 0x01, 0xc9,
	0x48, 0xff, 0xc1,
	0x48, 0x39, 0xf9,
	0x76, 0xd4,
	0x4c, 0x89, 0xc8,
	0xc3
};

int main(void){
	int fd = open("/dev/zero", O_RDONLY);
	int (*solve)(int, int, int) = mmap(NULL, sizeof main_, PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
	memcpy(solve, main_, sizeof main_);

	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d\n", solve(n, a, b));

	close(fd);
	munmap(solve, sizeof main_);
	return 0;
}


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

bool isHarshad(int a){
    int ketasum = 0;
    int b = a;
    while(a > 0){
        ketasum += a%10;
        a /= 10;
    }
    if(b % ketasum == 0) return true;
    else return false;
}

int main() {
    int n; cin >> n;
    if(isHarshad(n)) cout << "Yes";
    else cout << "No";
}


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

int gcd(int a, int b) {
  int c;
  if (a >= b) {
    c = a % b;
    if (c == 0) return b;
    else return gcd(b, c);
  } else {
    c = b % a;
    if (c == 0) return a;
    else return gcd(a, c);
  }
}

int main(void) {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

int main() {
	int n;
	ll x;
	cin >> n >> x;
	vector<pair<int, pair<int, int>>> v;
	if(n%2==0)
	{
		for(int i=1; i<=n/2; i++)
		{
			v.push_back(make_pair(i+n+(n/2)+i, make_pair(i, n+(n/2)+i)));
		}
		for(int i=1; i<n/2; i++)
		{
			v.push_back(make_pair(i+(n/2)+(n+1)+i, make_pair(i+(n/2), n+1+i)));
		}
		v.push_back(make_pair(n+n+1, make_pair(n, n+1)));
	}
	else
	{
		int k=(n/2)+1;
		for(int i=1; i<k; i++)
		{
			v.push_back(make_pair(i+n+k+i, make_pair(i, n+k+i)));
			v.push_back(make_pair(k+i+n+1+i, make_pair(k+i, n+1+i)));
		}
		v.push_back(make_pair(k+n+1, make_pair(k, n+1)));
	}
	sort(v.begin(), v.end());
	bool muri=false;
	rep(i, n)
	{
		if(2*(x-1)+(ll)v[i].first>x+2*(ll)n+(ll)i) muri=true;
	}
	if(muri) cout << "-1" << endl;
	else
	{
		rep(i, n)
		{
			cout << x-1+(ll)v[i].second.first << ' ' << x-1+(ll)v[i].second.second << ' ' << x+2*(ll)n+i << endl;
		}
	}
	return 0;
}

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

long long gcd(long long a, long long b);

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

  long long result = 1;
  for (i = 0; i < n; i++) {
    result *= t[i] / gcd(result, t[i]);
  }
  cout << result << endl;

  return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;


int main() {
    ll N;
    cin>>N;
    vector<string> data(N);
    set<string> S;
    rep0(i,N){cin>>data[i];}
    rep0(i,N){S.insert(data[i]);}
    cout<<S.size()<<endl;
}


Measured memory_bytes: 25080
x = int(input())
 
a = int(x / 100)
b = int((x / 10) % 10)
c = int(x % 10)
cnt = 0
 
if a == 1:
  cnt += 1
if b == 1:
  cnt += 1
if c == 1:
  cnt += 1
print(cnt)

Measured memory_bytes: 3060
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
//#include <bits/stdc++.h>
#include <iomanip>
#include <cstring>
#include <cmath>
//#include <minmax.h>
#include<queue>
#define MCV main
#define lldin(a) scanf("%lld",&a)
#define din(a) scanf("%d",&a)
#define reset(a,b) memset(a,b,sizeof(a))
const int INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
char s[500000];
int MCV()
{
   cin>>s;
   int cnt1=0,cnt2=0;
   for(int i=0;s[i];i++)
   {
      if(s[i]=='0')
       cnt1++;
      else
       cnt2++;
   }
   cout<<min(cnt1,cnt2)*2<<endl;
   return 0;
}

Measured memory_bytes: 384
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
vector<int>p;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		p.push_back(x);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			swap(p[i],p[j]);
			vector<int>orz=p;
			sort(orz.begin(),orz.end());
			if(orz==p){
				puts("YES");
				return 0;
			}
			swap(p[i],p[j]);
		}
	}
	puts("NO");
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<std::string> A, std::vector<std::string> B){

    for(long long i = 0; i <= N - M; ++i){
        for(long long j = 0; j <= N - M; ++j){
            bool flag = true;
            for(long long k = i; k < i + M; ++k){
                //cout << "B: " << B[k-i] << endl;
                //cout << "A: " << A[k].substr(j, M) << endl;
                if(A[k].substr(j, M) != B[k-i]) flag = false;
            }
            //cout << flag << endl;
            if(flag){
                cout << YES << endl;
                exit(0);
            }
        }
    }
    cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> A(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> A[i];
    }
    std::vector<std::string> B(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> B[i];
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

typedef long long ll;

using namespace std;

void solve(){
    int n;
    cin >> n;
    int x[n];
    int min = INT_MAX, max = INT_MIN;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        if(x[i] < min){
            min = x[i];
        }
        if(x[i] > max){
            max = x[i];
        }
        sum += x[i];
    }
    cout << min << " " << max << " " << sum << endl;
}

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

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

int main() {
  
  string a;
  cin >> a;
  int sum = 0;
  
  rep(i,3) {
    if (a[i] == '1') sum += 1;
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin>>s;
  ll f=0;
  for(ll i=a;i<=c;i++){
    if(s[i]=='#')f++;
    else f=0;
    if(f>=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  f=0;
  for(ll i=b;i<=d;i++){
    if(s[i]=='#')f++;
    else f=0;
    if(f>=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(d<c){
    f=0;
    for(ll i=b-1;i<=d+1;i++){
      if(s[i]=='.')f++;
      else f=0;
      if(f>=3){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
    return 0;
  }
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <thread>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, ans;
vector<ll> s;
void solve(ll a, ll b) {
	ll now = a;
	while (b > 0) {
		if (b % 2 == 1) s.push_back(now);
		ans += b / 2;
		now *= 2;
		if (now >= 10) {
			now = now / 10 + now % 10;
			ans += b / 2;
		}
		b /= 2;
	}
	
}
int main() {
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		solve(a, b);
	}
	ll now = s[0];
	FOR(i, 1, s.size()) {
		now *= 10;
		now += s[i];
		now = now / 10 + now % 10;
		ans++;
		if (now >= 10) {
			now = now / 10 + now % 10;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35044
def main():
    N, M = (int(i) for i in input().split())

    def enum_divisors(n):
        # 約数列挙
        divs = set()
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.add(i)
                if n//i != i:
                    # i が平方数でない
                    divs.add(n//i)
        return divs

    divs = enum_divisors(N) & enum_divisors(M)
    ans = 1
    v = 1
    from math import gcd
    for s in sorted(divs):
        if s == 1:
            continue
        if gcd(v, s) == 1:
            v *= s
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67556
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define PI 3.14159265358979323846264338327950288
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	ll N;
	cin >> N;
	vector<ll> A(N);
	bool ck = false;
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0) ck = true;
	}

	if (ck == true) {
		cout << 0 << endl;
	}
	else {
		ll ans = A[0];
		for (int i = 1; i < N; i++) {
			if (A[i] <= (ll)1e18 / ans) {
				ans *= A[i];
			}else{
				cout << "-1" << endl;
				return 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int a,b;    cin>>a>>b;
    if(a==1 and b==2 or a==2 and b==1 )   cout << 3;
    else if(a==2 and b==3 or a==3 and b==2)   cout << 1;
    else
    {
        cout << 2;
    }
    return 0;
}


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) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);
    
    System.out.println(a ^ b ^ c);

  }

}

Measured memory_bytes: 22228
import sys
import math
import re

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

s2 = input()
t = input()

#辞書順の小さいものを作るためにパターンマッチは後ろから実施したい
#ので入力を反転させる
s2_r = s2[::-1]
t_r = t[::-1]

ans_flag = False
#全文字の組み合わせを試す
for i in range(len(s2)):
    for j in range(i+1,len(s2)+1):
        #tと同じ文字数の時だけ部分一致するか判定する
        if (j-i) == len(t_r):
            flag = True
            #一文字ごとに判定する
            for k,l in enumerate(range(i,j)):
                if s2_r[l] != t_r[k] and s2_r[l] != '?':
                    flag = False
            if flag == True:
                #一致した位置を置換
                ans = s2_r[:i] + t_r + s2_r[j:]
                #残りの?を辞書順最小のaに置換
                ans = ans.replace('?','a')
                #元の順番に反転
                ans = ans[::-1]
                print(ans)                
                ans_flag = True
                break

    #forをbreakしないとcontinueする
    else:
        continue
    break
            
if ans_flag == False:
    print('UNRESTORABLE')

Measured memory_bytes: 9668
# coding: utf-8
# Your code here!
def main():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    resf=10**7
    z=0
    for i in a:
        if i==a[0]:
            res=min(a[-1]-a[0],k-(a[1]-a[0]))
        elif i==a[-1]:
            res=min(k-(a[-1]-a[-2]),a[-1]-a[0])
        else:
            if k-(a[z+1]-i)<=k-(i-a[z-1]):
                res=k-(a[z+1]-i)
            else:
                res=k-(i-a[z-1])
        if resf>=res:
            resf=res
        z+=1
    print(resf)

if __name__ == '__main__':
    main()



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

ll dp[100100][13]; // i桁目まで見て、余りがjとなる場合の数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  dp[0][0]=1;
  rep(i,n){
    if(s[i]!='?'){
      ll num=s[i]-'0';
      rep(j,13){
        ll rem=(j*10+num)%13;
        (dp[i+1][rem]+=dp[i][j])%=MOD;
      }
    }else{
      rep(num,10){
        rep(j,13){
          ll rem=(j*10+num)%13;
          (dp[i+1][rem]+=dp[i][j])%=MOD;
        }
      }
    }
  }
  
  cout<<dp[n][5]<<endl;
  
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+1;

int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    string n=t.substr(0,t.length()-1);
    if(s==n)
    {
        sayyes;
    }
    else
    {
        sayno;
    }
    
}

Measured memory_bytes: 3632