akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		String[] n_array = new String[n];
		for(int i = 0; i < n; i++) {
			n_array[i] = sc.next();
		}

		String[] m_array = new String[m];
		for(int i = 0; i < m; i++) {
			m_array[i] = sc.next();
		}


		for(int i = 0; i < n - m + 1; i++) {
			for(int j = 0; j < n - m + 1; j++) {
				String first = n_array[i].substring(j, j + m);//n_arrayを考えらえるだけ切り取る
				if(first.equals(m_array[0])) { //切り取った中で、m_arrayの一行目とマッチする場合
					boolean isNG = false;
					for(int k = 1; k < m; k++) {
						String next = n_array[i + k].substring(j, j + m);
						if(!next.equals(m_array[k])) {
							isNG = true;
							break;
						}
					}
					if(!isNG) {
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
}



Measured memory_bytes: 35712
N=int(input())
T,A=list(map(int,input().split()))
ans=0
min_=10**6
for i,h in enumerate(map(int,input().split())):
    if abs(T-h*0.006-A)<min_:
        min_=abs(T-h*0.006-A)
        ans=i+1
print(ans)

Measured memory_bytes: 3060
from itertools import combinations

S = input()

ret = 0
for i in range(len(S)) :
    for comb in combinations(range(1, len(S)), i) :
        comb = [0] + list(comb) + [len(S)]
        for i in range(1, len(comb)) :
            ret += int(S[comb[i-1]:comb[i]])
         
print(ret)      

Measured memory_bytes: 39792
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    string ans;
    if (S.size() <= K) {
        ans = S;
    } else {
        ans = S.substr(0, K) + "...";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector < vector<int> > graph(N * N + 1);
  vector <int> enter(N * N + 1);

  for (int i = 0; i < N; i++){
    int bedge = i + 1;
    int before = i + 1;
    for (int j = 0; j < N - 1; j++){      
      int A; cin >> A;
      int now = N * min(i + 1, A) + max(i + 1, A);
      
      if (j != 0){
        graph[before].push_back(now);
        enter[now]++;
      }
      bedge = A; before = now;
    }
  }

  queue <int> que;
  vector <bool> visited(N * N + 1);
  vector <int> cnt(N * N + 1);
  for (int i = 0; i < N * N + 1; i++){
    if (enter[i] == 0 && graph[i].size() > 0){
      que.push(i);
      cnt[i]++;
    }
  }




  int ans = 0;
  while (!que.empty()){
    int Q = que.front(); que.pop();
    visited[Q] = true;
    for (int i = 0; i < graph[Q].size(); i++){
      int next = graph[Q][i];
      enter[next]--;
      if (visited[next] == false){
        if (enter[next] == 0){
          que.push(next);
          ans = max(ans, cnt[Q] + 1);
          cnt[next] = cnt[Q] + 1;
        }
      }else{
        ans = -1; break;
      }
    }
    if (ans == -1) break;
  }

  for (int i = 0; i < N * N + 1; i++){
    if (enter[i] != 0){
      ans = -1;
    }
  }

  if (ans == 0) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 47232
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int w;
	cin >> w;
	cout << w * 32 << endl;
	return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String a_str = scan.next();
        String b_str = scan.next();
        char a = a_str.charAt(0);
        char b = b_str.charAt(0);
        char ans;

        if(a == 'H'){
            ans = (b == 'H')? 'H' : 'D';
        }else{
            ans = (b == 'D')? 'H' : 'D';
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
S = input()
T = input()
N = len(T)

if len(S) < N:
    print("UNRESTORABLE")
    import sys
    sys.exit()

flag = False
pos = 51
ans = ""
for i in range(len(S)-N+1):
    cnt = 0
    for j in range(N):
        if S[i+j] == "?" or S[i+j] == T[j]:
            cnt += 1
        else:
            break
    if cnt == N:
        pos = i
        flag = True
if flag:
    for i in range(len(S)):
        if pos <= i and i < pos + N:
            ans += T[i-pos]
        elif S[i] == "?":
            ans += "a"
        else:
            ans += S[i]
else:
    ans = "UNRESTORABLE"
print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define endl '\n'
#define ll long long

using namespace std;

int main() {
    int n, i;
    int t = 0;
    ll s_1 = 0, s_2 = 0, menor_dif = 0, dif;

    cin >> n;
    int v[n];

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

    for(i = 1; i < n; i++) {
        s_2 += v[i];
    }

    menor_dif = abs(s_1 - s_2);
    for(i = 1; i < n; i++) {
        s_1 += v[i];
        s_2 -= v[i];
        dif = abs(s_1 - s_2);
        
        if(dif < menor_dif) {
            menor_dif = dif;
        }
    }

    cout << menor_dif << endl;

    return 0;
}

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

using i64 = int64_t;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

i64 lcm(i64 m, i64 n) {
    return m / gcd(m, n) * n;
}

int main(){
    i64 a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String str = sc.nextLine();
		
		if(str.indexOf("a")==-1){
			System.out.println("a");
		}else if(str.indexOf("b")==-1){
			System.out.println("b");
		}else if(str.indexOf("c")==-1){
			System.out.println("c");
		}else if(str.indexOf("d")==-1){
			System.out.println("d");
		}else if(str.indexOf("e")==-1){
			System.out.println("e");
		}else if(str.indexOf("f")==-1){
			System.out.println("f");
		}else if(str.indexOf("g")==-1){
			System.out.println("g");
		}else if(str.indexOf("h")==-1){
			System.out.println("h");
		}else if(str.indexOf("i")==-1){
			System.out.println("i");
		}else if(str.indexOf("j")==-1){
			System.out.println("j");
		}else if(str.indexOf("k")==-1){
			System.out.println("k");
		}else if(str.indexOf("l")==-1){
			System.out.println("l");
		}else if(str.indexOf("m")==-1){
			System.out.println("m");
		}else if(str.indexOf("n")==-1){
			System.out.println("n");
		}else if(str.indexOf("o")==-1){
			System.out.println("o");
		}else if(str.indexOf("p")==-1){
			System.out.println("p");
		}else if(str.indexOf("q")==-1){
			System.out.println("q");
		}else if(str.indexOf("r")==-1){
			System.out.println("r");
		}else if(str.indexOf("s")==-1){
			System.out.println("s");
		}else if(str.indexOf("t")==-1){
			System.out.println("t");
		}else if(str.indexOf("u")==-1){
			System.out.println("u");
		}else if(str.indexOf("v")==-1){
			System.out.println("v");
		}else if(str.indexOf("w")==-1){
			System.out.println("w");
		}else if(str.indexOf("x")==-1){
			System.out.println("x");
		}else if(str.indexOf("y")==-1){
			System.out.println("y");
		}else if(str.indexOf("z")==-1){
			System.out.println("z");
		}else{
			System.out.println("None");
		}
		sc.close();
	}
}

Measured memory_bytes: 27976
#include<stdio.h>

int main(){

  char x,y;

  scanf("%c %c",&x,&y);

  if((int)x > (int)y){
    printf(">\n");
  }else if((int)x == (int)y){
    printf("=\n");
  }else{
    printf("<\n");
  }

  return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    int N;
    cin>>N;
    vector<ll> A(N),B(N),C(N);
    rep(i,0,N)cin>>A[i];
    rep(i,0,N)cin>>B[i];
    rep(i,0,N)cin>>C[i];

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    ll ans[3][100100];
    rep(i,0,N)ans[0][i]=i+1;

    auto itr =lower_bound(A.begin(),A.end(),B[0]);
    ans[1][0]= ans[0][itr-A.begin()-1];
    rep(i,1,N){
        itr =lower_bound(A.begin(),A.end(),B[i]);
        ans[1][i]= ans[0][itr-A.begin()-1]+ans[1][i-1];
    }
    
    itr =lower_bound(B.begin(),B.end(),C[0]);
    ans[2][0]= ans[1][itr-B.begin()-1];

    rep(i,1,N){
        itr =lower_bound(B.begin(),B.end(),C[i]);
        ans[2][i]=ans[1][itr-B.begin()-1]+ans[2][i-1];
    }

    cout<<ans[2][N-1];
    return 0;
}

Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s;
	cin >> s;
	auto is_pal = [](string& s)
	{
		for (int i = 0; i < sz(s) / 2; i++)
			if (s[i] != s[sz(s) - 1 - i])
				return false;
		return true;
	};
	string s1 = s.substr(0, sz(s) / 2);
	string s2 = s.substr((sz(s) + 3) / 2 - 1);
	bool ok = is_pal(s) && is_pal(s1) && is_pal(s2);
	cout << (ok ? "Yes" : "No");
	return 0;
}

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

using namespace std;
typedef long long ll;

ll n, m, f = 1, b;

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

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    f = f * a / gcd(f, a);
    ll cnt = 0;
    while(a % 2 == 0) {
      a /= 2;
      cnt++;
    }
    if (i == 0) {
      b = cnt;
    } else {
      if (b != cnt) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  
  cout << (m + f/2) / f << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int LinearSearch(int *,int,int);

int main(){
  int s[10001],n,q,cnt=0,el,i;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&el);
    cnt+=LinearSearch(s,el,n);

  }

  printf("%d\n",cnt);

  return 0;
}

int LinearSearch(int *a,int el,int n){
  int i;

  for(i=0;i<n;i++){

    if(el==a[i])  return 1;
    
  }

  
  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();

		char[][] b=new char[h][];
		for(int i=0;i<h;i++){
			b[i]=sc.next().toCharArray();
		}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(b[i][j]=='#' 
						&&(i!=0 && b[i-1][j]=='.')
						&&(j!=0 && b[i][j-1]=='.')
						&&(i!=h-1 && b[i+1][j]=='.')
						&&(j!=w-1 && b[i][j+1]=='.')){
					System.out.println("No");
					return;
				}
			}
		}
		
		System.out.println("Yes");
	}
	
	public static int gcd(int a, int b) {
		return a%b==0 ? b : gcd(b,a%b);
	}
}


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

int main() {
  int n, tmp;
  cin >> n;
  vector<int> rt(n);
  for(int i = 0; i < n; i++){
    cin >> rt[i];
  }
  int ans = INT_MIN;
  int minv = rt[0];
  for(int j = 1; j < n; j++){
    ans = (ans >= rt[j] - minv)? ans: rt[j] - minv;
    minv = (minv <= rt[j])? minv: rt[j];
  }
  cout << ans << endl;
    
  return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 100;

int a,b;

char g[maxn][maxn];

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

  cin>>a>>b;
  for (int i=0; i<50; i++) {
    for (int j=0; j<100; j++) {
      g[i][j]='.';
    }
  }
  a--;
  for (int i=50; i<100; i++) {
    for (int j=0; j<100; j++) {
      g[i][j]='#';
    }
  }
  b--;

  for (int i=0; i<50 && b>0; i+=2) {
    for (int j=0; j<100 && b>0; j+=2) {
      g[i][j]='#'; b--;
    }
  }

  for (int i=99; i>=50 && a>0; i-=2) {
    for (int j=0; j<100 && a>0; j+=2) {
      g[i][j]='.'; a--;
    }
  }

  cout<<"100 100\n";
  for (int i=0; i<100; i++) {
    for (int j=0; j<100; j++) {
      cout<<g[i][j];
    }
    cout<<'\n';
  }

  
  return 0;
}


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

int main() {
	string b;
	cin >> b;
	if (b == "A") {
		cout << "T" << endl;
	}
	else if (b == "T") {
		cout << "A" << endl;
	}
	else if (b == "C") {
		cout << "G" << endl;
	}
	else {
		cout << "C" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
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 NMAX 1000000000
int X,Y,A,B,C;
vi P,Q,R;

ll solve(){

	sort(allr(P));
	sort(allr(Q));
	sort(allr(R));

	// for(auto x:P)cout<<x<<" ";puts("");//
	// for(auto x:Q)cout<<x<<" ";puts("");//
	// for(auto x:R)cout<<x<<" ";puts("");//

	// vector<pair<int,int>> T;//<taste,0|1:red|green>
	priority_queue<int> T, S;
	rp(i, 0, X){
		T.push(P[i]);
	}
	rp(i, 0, Y){
		T.push(Q[i]);
	}

	rp(i, 0, C){
		S.push(R[i]);
	}

	// puts("---");//
	// while(T.size()){cout<<T.top()<<" "; T.pop();puts("");}puts("---");//
	// while(S.size()){cout<<S.top()<<" "; S.pop();puts("");}puts("===");//

	ll ans = 0;
	while(T.size()){
		int t = T.top(); T.pop();
		int s = S.top(); S.pop();
		if(t>s){
			S.push(s);
			ans += t;
		}
		else{
			S.push(t);
			ans += s;
		}
	}

	return ans;
}

int main(){
	cin>>X>>Y>>A>>B>>C;
	P.resize(A); rp(i, 0, A) cin>>P[i];
	Q.resize(B); rp(i, 0, B) cin>>Q[i];
	R.resize(C); rp(i, 0, C) cin>>R[i];
	cout<< solve() <<endl;
}


Measured memory_bytes: 3060
#include"bits/stdc++.h"

using namespace std;

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

	string S;
	cin >> S;

	int ans = 0;
	int cnt = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}

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

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

using namespace std;

const int max_n = 11, inf = 1000111222;

int n, m, k;
string s[max_n];

bool get_bit(int mask, int pos) {
    return (mask >> pos) & 1;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    int ans = 0;
    for (int m1 = 0; m1 < (1 << n); ++m1) {
        for (int m2 = 0; m2 < (1 << m); ++m2) {
            int cnt = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (s[i][j] == '#' && !get_bit(m1, i) && !get_bit(m2, j)) {
                        ++cnt;
                    }
                }
            }
            ans += (cnt == k);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  long long n,m,a;
  cin >> n >> m;
  priority_queue<int> pq;
  for (int i = 0; i < n; i++){
    cin >> a;
    pq.push(a);
  }
  for (int i = 0; i < m; i++){
    a = pq.top();
    pq.pop();
    pq.push(a/2);
  }
  a = 0;
  for (int i = 0; i < n; i++){
    a += pq.top();
    pq.pop();
  }
  cout << a << '\n';
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

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

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N;
VI ls;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N;
	rep (i, 2 * N) {
		int l;
		cin >> l;
		ls.pb(l);
	}
	sort(rall(ls));
	int ans = 0;
	for (int i = 0;i < ls.size() - 1;i += 2) {
		ans += min(ls[i], ls[i + 1]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    ll n  , i ; 
    cin >> n >> i ; 
    cout << abs(n - i + 1 ) << el ; 
    ro ; 

}





Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N,x;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &x);

  int *a=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&a[i]);
  }

  long sum=0;
  if(a[0]>x){
    int sub=a[0]-x;
    sum+=sub;
    a[0]=x;
  }
  srep(i,1,N){
    int sub;
    sub=a[i-1]+a[i]-x;
    if(sub<0){
      ;
    }
    else{
      sum+=sub;
      a[i]-=sub;
    }
  }

  printf("%ld\n", sum);

  return 0;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		int count = 0;

		if(b - a <= k) {
			if(c -a <= k) {
				if(d-a <= k) {
					if(e-a <= k) {
						if (c-b<=k) {
							if(d-b <= k) {
								if(e-b <= k) {
									if (d-c<=k) {
										if(e-c<=k) {
											if(e-d<=k) {
												count++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		if(count == 0) {
			System.out.print(":(");
		}else {
			System.out.println("Yay!");
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define int long long
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

signed main(){
	map<int,int> mp;
	int n,a;
	cin>>n;
	vector<int> vec;
	rep(i,n){
		cin>>a;
		mp[a]++;
		if(mp[a]%2==0)vec.pb(a);
	}
	if(vec.size()<2)while(vec.size()<2)vec.pb(0);
	sort(all(vec),greater<int>());
	cout<<vec[0]*vec[1]<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
const int N = 1e5+10;
int main()
{
	
	int n;
	cin>>n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int x;
		cin>>x;
		ans^=x;
	}
	if(ans ==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static List<Integer> graph[];
	static int cnt[];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		graph = new ArrayList[n+1];
		cnt = new int[n+1];
		
		for(int i=1;i<=n;i++)
			graph[i] = new ArrayList<>();
		
		for(int i=0;i<n-1;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			graph[a].add(b);
			graph[b].add(a);
		}
		
		for(int i=0;i<q;i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			cnt[p] += x;
		}
		
		dfs(1, -1, 0);
		
		// 出力文字列の編集
		// printは遅いので、1回実行だけで済むように、StringBuilderで解答の文字列を作成
		StringBuilder sb = new StringBuilder();
		for(int i=1;i<=n;i++)
			sb.append(cnt[i] + " ");
				
		System.out.println(sb.toString());
	}
	
	// 深さ優先探索 (Depth-First Search)
	static void dfs(int v, int p, int x) {
		cnt[v] += x;
		x = cnt[v];
				
		for(int to:graph[v]) {
			if(to == p)continue;
			dfs(to, v, x);
		}
	}
	
	
}


Measured memory_bytes: 225452
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


long long int mod = 4294967296;
ll rui(ll number1,ll number2){
    //abcのbed乗を計算する
    if(number2 == 0){return 1;}
    else{
        ll number3 = rui(number1,number2/2);
        number3 *= number3;
        number3 %= mod;
        if(number2 % 2 == 1){number3 *= number1; number3 %= mod;}
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,res,q;
ll x[500005],y[500005],z[500005];
char s[500005];

int main(){
    cin >> n >> k;
	cin >> s;
	for(i=1;i<n;i++){
		if(s[i-1] == 'A' && s[i] == 'C'){
			x[i] = x[i-1] + 1;
		}else{
			x[i] = x[i-1];
		}
	}
	for(i=0;i<k;i++){
		cin >> a >> b;
		p(x[b-1] - x[a-1]);
	}
	return 0;
}

Measured memory_bytes: 28416
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        h: usize, w: usize,
        sy: usize, sx: usize,
        gy: usize, gx: usize,
        graph: [Chars; h]
    }

    let mut dist = vec![vec![-1; w]; h];
    let directions = vec![(0, 1), (1, 0), (-1, 0), (0, -1)];
    let mut pq = BinaryHeap::new();
    pq.push((0, (sx-1, sy-1)));

    while let Some((dep, (x, y))) = pq.pop() {
        let dep = -dep;
        if dist[y][x] >= 0 { continue; }

        dist[y][x] = dep;

        for &(dx, dy) in directions.iter() {
            let (cx, cy) = (x as isize + dx, y as isize + dy);
            if cx < 0 || cy < 0 || cx >= w as isize || cy >= h as isize { continue; }

            let (cxu, cyu) = (cx as usize, cy as usize);
            if graph[cyu][cxu] == '#' { continue; }

            pq.push((-dep , (cxu, cyu)));
        }

        let left_bound = if x < 2 { 0 } else { x - 2 };
        let right_bound = if x + 3 >= w { w } else { x + 3 };
        let up_bound = if y < 2 { 0 } else { y - 2 };
        let down_bound = if y + 3 >= h { h } else { y + 3 };

        for wx in left_bound..right_bound {
            for wy in up_bound..down_bound {
                if graph[wy][wx] == '#' { continue; }
                pq.push((-(dep+1), (wx, wy)))
            }
        }
    }
    

    println!("{}", dist[gy-1][gx-1]);
}


fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

int main()
{
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> memo(60, std::vector<int> (25));
    for (int i = 0; i < n; ++i)
    {
        std::string a;
        std::cin >> a;
        int a_size = (int) a.size();
        int decimal = -1;
        for (int j = 0; j < a_size; ++j)
        {
            if (a[j] == '.')
            {
                decimal = j;
                break;
            }
        }
        long long b = 0;
        if (decimal == -1)
        {
            long long d = 1;
            for (int j = a_size - 1; j >= 0; --j)
            {
                b += d * (int) (a[j] - '0');
                d *= 10;
            }
            b *= 1e9;
        }
        else
        {
            long long d = 1;
            for (int j = decimal - 1; j >= 0; --j)
            {
                b += d * (int) (a[j] - '0');
                d *= 10;
            }
            b *= 1e9;
            d = 1e8;
            for (int j = decimal + 1; j < a_size; ++j)
            {
                b += d * (int) (a[j] - '0');
                d /= 10;
            }
        }
        int count2 = 0, count5 = 0;
        while (b % 2 == 0)
        {
            ++count2;
            b /= 2;
        }
        while (b % 5 == 0)
        {
            ++count5;
            b /= 5;
        }
        ++memo[count2][count5];
    }
    long long ans = 0;
    for (int i = 0; i < 60; ++i)
    {
        for (int j = 0; j < 25; ++j)
        {
            for (int ii = std::max(0, 18 - i); ii < 60; ++ii)
            {
                for (int jj = std::max(0, 18 - j); jj < 25; ++jj)
                {
                    if (i != ii || j != jj)
                    {
                        ans += 1LL * memo[i][j] * memo[ii][jj];
                    }
                }
            }
        }
    }
    ans /= 2;
    for (int i = 0; i < 60; ++i)
    {
        for (int j = 0; j < 25; ++j)
        {
            if (i + i >= 18 && j + j >= 18)
            {
                ans += 1LL * memo[i][j] * (memo[i][j] - 1) / 2;
            }
        }
    }
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	pair<int,pii> date = {2019,{4,30}};
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);	
	pair<int,pii> d2 = {y,{m,d}};
	cout << (d2 <= date?"Heisei":"TBD") << endl;
}


Measured memory_bytes: 256
X,K,D = map(int, input().split())

minusFLG = 0
if X < 0:
    minusFLG = 1
    X = abs(X)

minX = X % D
minXmove = X // D

# 移動回数足りない
if minXmove > K:
    print(X - K * D)
    exit()

# 移動回数超える
zanMove = K - minXmove
if zanMove % 2 == 0:
    print(minX)
else:
    print(abs(minX - D))


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


for i in range(N):
    a,b,c=map(int,input().split())
    A=max(a,max(b,c))
    B=min(a,min(b,c))
    C=a+b+c-A-B
    
    if B**2+C**2==A**2:
        print('YES')
    else:
        print('NO')


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

int main() {
  string S;
  cin >> S;
  long int N;
  N=S.length();
  vector<int> a(N);
  for(int i=0;i<N;i++){
    if(i==0){
      a.at(i)=1;
    }
    else if(i==1){
      if(S.at(i-1)==S.at(i)){
        a.at(i)=1;
      }
      else{
        a.at(i)=2;
      }
    }
    else if(i==2){
      if(S.at(i-2)==S.at(i-1)||S.at(i-1)==S.at(i)){
        a.at(i)=2;
      }
      else{
        a.at(i)=3;
      }
    }
    else{
      if(S.at(i-1)==S.at(i)){
        a.at(i)=a.at(i-3)+2;
      }
      else{
        a.at(i)=a.at(i-1)+1;
      }
    }
  }
  cout << a.at(N-1)<<endl;

}

Measured memory_bytes: 1412
from collections import deque
H,W,K = list(map(int, input().split()))
A = [[0] * W for _ in range(H)]
n = 1
P = []
B = []
for i in range(H):
    B.append(input())

for i in range(H):
    for j in range(W):
        if B[i][j] == "#":
            A[i][j] = n
            n += 1
            P.append([i,j])
def change(A,x,y,z):
    if y-1 >= 0:
        if A[x][y-1] == 0:
            A[x][y-1] = z
            change(A,x,y-1,z)
    if y + 1 <= (W-1):
        if A[x][y+1] == 0:
            A[x][y+1] = z
            change(A,x,y+1,z)
for i in P:
    change(A,i[0],i[1],A[i[0]][i[1]])
next_ = []
next_ = deque(next_)
for k in range(H):
    if 0 in A[k]:
        next_.append(k)
while len(next_) > 0:
    l = next_.popleft()
    if l == H-1:
        A[l] = A[l-1]
        if 0 in A[l]:
            next_.append(l)
    elif l == 0:
        A[l] = A[l+1]
        if 0 in A[l]:
            next_.append(l)
    else:
        if l+1 in next_ and l - 1 in next_:
            next_.append(l)
        elif l + 1 not in next_:
            A[l] = A[l + 1]
        else:
            A[l] = A[l - 1]
for w in range(H):
    print(*A[w])


Measured memory_bytes: 17488
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int mod = 998244353;
const int MAXN = (int)3e5 + 5;

int fact[MAXN];

int rev[MAXN];

ll a, b, k;

int n, ans;

int binPow(int a, int b, int m = mod) {
    int ret = 1;

    while (b > 0) {
        if (b & 1) {
            ret = (ret * 1ll * a) % m;
        }

        a = (a * 1ll * a) % m;
        b >>= 1;
    }

    return ret;
}

void pre() {
    fact[0] = rev[0] = 1;

    for (int i = 1; i < MAXN; ++i) {
        fact[i] = (fact[i - 1] * 1ll * i) % mod;
        rev[i] = binPow(fact[i], mod - 2);
    }
}

void addMod(int &a, int b, int m = mod) {
    a += b;

    if (m <= a) {
        a -= m;
    }
}

int C(int n, int k) {
    if (k < 0 || k > n) {
        return 0;
    }

    return fact[n] * 1ll * rev[k] % mod * rev[n - k] % mod;
}

void solve() {
    scanf("%d %lld %lld %lld", &n, &a, &b, &k);

    for (int x = 0; x <= n; ++x) {
        ll left = k - x * a;

        if (left < 0) {
            break;
        }

        if (left % b == 0 && left / b <= n) {
            int y = left / b;
            addMod(ans, C(n, x) * 1ll * C(n, y) % mod);
        }
    }

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

int main() {
    int tt = 1;

    pre();

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int L[N];
   int sum = 0;
   for(int i=0; i<N; ++i){
      std::cin >> L[i];
      sum += L[i];
   }

   int max = 0;
   for(int i=0; i<N; ++i)
      if(max<L[i]) max = L[i];


   if(max<sum-max) std::cout << "Yes" << std::endl;
   else std::cout << "No" << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, j;
    int a = 0;
    cin >> n;
    for ( i = 0; i <= n; i ++)
    for ( j = 0; j <= n; j ++)
    if ( 4 * i + 7 * j == n )
    a ++;
    if ( a >= 1)
    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;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(){
    int n;
    cin>>n;
    vector<tuple<string,int,int>> a(n);
    rep(i,n){
        string s;
        int p;
        cin>>s>>p;
        a.at(i)=make_tuple(s,100-p,i);
    }
    sort(a.begin(),a.end());
    rep(i,n)
    cout<<get<2>(a.at(i))+1<<endl;
}

Measured memory_bytes: 256
program reconciled;
uses math;
const
  md: int64 = 1000000007;
var
  n, m, x, i: int64;
begin
  read(n, m);
  if abs(n-m) > 1 then
  begin
    writeln(0);
    halt(0);
  end;
  x := ifthen(n = m, 2, 1);
  for i := 1 to min(n, m) do
    x := ((i*i mod md)*x mod md);
  for i := min(n, m)+1 to max(n, m) do
    x := (i*x mod md);
  writeln(x);
end.

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

int main() {
  int n;
  cin >> n;
  vector<tuple<string,int,int>> a(n);
  rep(i,n){
    string s;
    int p;
    cin >> s >> p;
    a.at(i) = make_tuple(s,-p,i+1);
  }
  sort(a.begin(),a.end());
  rep(i,n) cout << get<2>(a.at(i)) << endl;
  
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 3005
ll inf = 1e14;
ll mod = 1e9 + 7;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ld dp[N][N];
ld arr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, 0, sizeof(dp));

  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  dp[0][0] = 1;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 0; j <= i; j++) {
      if (j)
        dp[i][j] += (arr[i] * dp[i - 1][j - 1]);

      dp[i][j] += (1 - arr[i]) * dp[i - 1][j];
    }
  }

  ll val = n / 2;
  val++;

  ld res = 0;
  for (ll i = val; i <= n; i++)
    res += dp[n][i];

  cout << fixed << setprecision(12) << res << en;
  return 0;
}


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

int main(){
    int n,i,a;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        if(a%2==0 and a%3!=0 and a%5!=0){cout<<"DENIED";return 0;}
    }
    cout<<"APPROVED";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a;
string s;
signed main()
{
	cin>>a>>s;
	if(a<3200){
		cout<<"red";
	}else{
		cout<<s;
	}
}

Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
const int LOGN = 20;
int dp[maxn];
vi g[maxn];
bool vis[maxn];
void dfs(int u)
{
    vis[u]=1;
    dp[u] = 0;
    for(int v:g[u]){
        if(!vis[v])
            dfs(v);
        dp[u] = max(dp[u], 1+dp[v]);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m,u,v;
    cin>>n>>m;
    f1(i,m)
    {
        cin>>u>>v;
        g[u].pb(v);
    }
    int mx = 0;
    f1(i,n){
        if(!vis[i])
            dfs(i);
        mx = max(mx, dp[i]);
        //cout << i << ": " << dp[i] << "\n";
    }
    cout << mx << "\n";
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,ans,b[200005],w[200005];
int main(void){
    cin>>n;
    ans=n;
    for(int i=1;i<=n;i++){
		char c;
		scanf(" %c",&c);
		if(c=='.')w[i]++;
		else b[i]++;
		b[i]+=b[i-1];
	}
	for(int i=n-1;i>=0;i--)w[i]+=w[i+1];
	for(int i=0;i<=n;i++)ans=min(ans,b[i]+w[i+1]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
P[]={6,10,2,14,8,12,4,0},p[8],d,r,i,s,m;char*C="4 1 4 1 2 1 2 1 4 1 4 1 2 1 2";main(b){for(;~scanf("%d",p+d);)if(++d==8){m=0;for(r=8;r--;s<m||(m=s,b=P[r]))for(s=0,i=8;i--;s+=p[i]<d?p[i]:d)d=C[P[r]+i*2]-48;printf("%.15s\n",C+b);d=0;}}

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

signed main(){
    string s; cin >> s;
    bool ok = false;
    if(s[2] == s[3] && s[4] == s[5]) ok =  true;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int r = sc.nextInt(), c = sc.nextInt();

		int[][] A = new int[r + 1][c + 1];

		for (int i = 0; i < r; i++)
			for (int j = 0; j < c; j++) {
				A[i][j] = sc.nextInt();
			}

		for (int i = 0; i < r; i++) {
			int sum = 0;
			for (int j = 0; j < c; j++) {
				sum += A[i][j];
			}
			A[i][c] = sum;
		}
		for (int j = 0; j <= c; j++) {
			int sum = 0;
			for (int i = 0; i < r; i++) {
				sum += A[i][j];
			}
			A[r][j] = sum;
		}

		for (int i = 0; i <= r; i++)
			ln(join(A[i], " "));
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}

	public static String join(int[] array, String separator) {
		StringBuilder str = new StringBuilder(array[0] + "");
		for (int i = 1; i < array.length; i++) {
			str.append(separator).append(array[i] + "");
		}
		return str.toString();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007


int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        map< vector<int>, ll > mp;
        lp(i, n) {
                string str; cin >> str;
                vector<int> v(26, 0);
                lp(j, sz(str)) v[(str[j] - 'a')]++;
                mp[v]++;
        }
        ll an = 0;
        for (auto x: mp) {
                an += x.second * (x.second - 1) / 2;
        }
        cout << an;
return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    ll x,y;
    cin>>x>>y;
    ll ans = 0;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, p, t int
	fmt.Scan(&N)
	max := 0

	for i := 0; i < N; i++ {
		fmt.Scan(&p)
		t += p
		if max < p {
			max = p
		}
	}
	fmt.Println(t - max/2)
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

#define int long long

int _gcd(int a,int b){
  if ( ( 0 == a ) || ( 0 == b ) )
    return 0;
  while( a != b ){
    if ( a > b ) a = a - b;
    else b = b - a;
  }
  return a;
}

//lcm
int _lcm(int a,int b){
  if ( ( 0 == a ) || ( 0 == b ) )
    return 0;
  
  return ((a / _gcd(a, b)) * b); 
}

signed main(){
  int N, M;
  string S, T;
  cin >> N >> M;
  cin >> S >> T;
  int L = _lcm(N, M);

  map<int, char> data;

  int cnt = 0;
  for(int i = 0; i < S.size(); i++){
    // cout << i << endl;
    data[cnt] = S[i];
    cnt += L/N;
  }
  // cout << str << endl;

  cnt = 0;
  for(int i = 0; i < T.size(); i++){
    //cout << data[cnt] << " " << T[i] << endl; 

    if(data[cnt] == 0){
      cnt += L/M;
      continue;
    }
    
    if(data[cnt] != T[i]){
      cout << -1 << endl;
      return 0;
    }

    cnt += L/M;
  }
  
  cout << L << endl;
  return 0;
}


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

using namespace std;

int main(){
	long long a,b,x;
	cin >> a >> b >> x;
	if(a==0){
		cout << b/x+1 << endl;
	}else{
		cout << (b/x+1)-((a-1)/x+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import itertools


def main():
  n = int(input())
  p = [tuple(map(int, input().split())) for _ in range(n)]
  c = {}

  if n == 1:
    print(1)
    return

  for i, j in itertools.product(range(len(p)), repeat=2):
    if i == j:
      continue

    d = (p[j][0] - p[i][0], p[j][1] - p[i][1])

    if d not in c:
      c[d] = 1
    else:
      c[d] += 1

  print(len(p) - max(c.values()))


if __name__ == '__main__':
  main()


Measured memory_bytes: 3444