akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,x;
    cin >> a >> b >> x;
    if(a % x != 0) a = a + x - a%x;
    if(a > b) cout << 0<<endl;
    else cout << (b-a)/x +1 << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
/*16D8103008D Yukki Nishimura 5/14 */

#include<stdio.h>
#include<stdlib.h>
#include<iostream>

using namespace std;

#define MAX 100000

bool check(int C[], int y,int j) {
	if (j != 0) {
		for (int i = 0; i < j; i++) {
			if (C[i] == y) {
				return true;
			}
		}
	}

	return false;  //探索失敗
}

int func(int S[], int T[], int q, int n)
{
	int s = n;
	int t = q;
	int j = 0;

	int C[MAX] = { };


	for (int i = 0; i < s; i++) {
	
		for (int k = 0; k < t; k++) {
			if (check(C, S[i],j)) {
				break;
			}

			else if (S[i] == T[k]) {
				C[j] = S[i];
				j++;
				break;
			}
			
		}
	}
	
	return j;
}



int main(void)
{
	int n, q, c;

	int S[MAX] = { }, T[MAX] = { };

	cin >> n;


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

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> T[i];

	}

	c = func(S, T, q, n);

	cout << c << endl;

	return 0;


}




Measured memory_bytes: 4240
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, X, Y = map(int, input().split())
cnt = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        if j <= X:
            cnt[j-i] += 1
            # print(0, i, j)
        elif i <= X and X < j <= Y:
            cnt[min(j-i, X-i+1+Y-j)] += 1
            # print(1, i, j)
        elif i <= X and Y <= j:
            cnt[X-i+1+j-Y] += 1
            # print(2, i, j)
        elif X <= i <= Y and j <= Y:
            cnt[min(j-i, i-X+1+Y-j)] += 1
            # print(3, i, j)
        elif X <= i <= Y and Y <= j:
            cnt[min(j-i, i-X+1+j-Y)] += 1
            # print(4, i, j)
        else:
            cnt[j-i] += 1
            # print(5, i, j)
for i in range(1, N):
    print(cnt[i])

Measured memory_bytes: 47068
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        t = a[i]
        while True:
            if t % 2 == 0:
                cnt += 1
                t //= 2
            else:
                break
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40432
# coding: utf-8

n = int(input().rstrip())

monster = [int(i) for i in input().rstrip().split(" ")]

def get_dev(num1:int, num2:int):
    if num1 % num2 == 0:
        return num2
    return get_dev(num2, num1 % num2)

cur = monster[0]
for i in range(1,n):
    cur = get_dev(cur, monster[i])

print(cur)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans = a[N - 1] - a[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  long i;
  long multi = 1;

  vector<int> prime(100);
  int tmp=0,j;
  for(j=2;j<n+1;j++){
    tmp = j;
    for(i=2;i<98;i++){
      while(tmp % i == 0){
        tmp /= i;
        prime[i]++;
      }
  }
    }
  int ans  = 0;
  int five = 0,thr = 0,fifteen = 0,twentfif = 0,sevenfor = 0;
  for(i=2;i<98;i++){
    if(prime[i] >= 74){
      five++;thr++;fifteen++;twentfif++;sevenfor++;
    }else if(prime[i] >= 24){
      five++;thr++;fifteen++;twentfif++;
    }else if(prime[i] >= 14){
      five++;thr++;fifteen++;
    }else if(prime[i] >= 4){
      five++;thr++;
    }else if(prime[i] >= 2){
      thr++;
    }
  }
  if(five != 0 && thr >= 2){
    ans = sevenfor + twentfif * (thr-1) + fifteen * (five - 1) + ((five * (five -1)) / 2) * (thr -2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

struct Node {
  ll key;
  Node *parent, *left, *right;
};
Node *root, *NIL;

void insert(ll k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

Node *find(Node *u, ll k) {
  while (u!=NIL && k!=u->key) {
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  ll n; cin >> n;
  string com;
  REP(i, n) {
    cin >> com;
    if (com == "insert") {
      ll x; cin >> x;
      insert(x);
    } else if (com == "find") {
      ll x; cin >> x;
      Node *t = find(root, x);
      if (t != NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



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

int main()
{
  std::string s;
  std::cin >> s;

  if (s == "ABC")
  {
    std::cout << "ARC" << std::endl;
  }
  else
  {
    std::cout << "ABC" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
typedef struct Dice{
	int	f1;
	int	f2;
	int	f3;
	int	f4;
	int	f5;
	int	f6;
	int tmp;
}Dice;

int main(void)
{
	int n, upper, front, right, a, i, j;
	Dice D0;
	scanf("%d%d%d%d%d%d", &D0.f1, &D0.f2, &D0.f3, &D0.f4, &D0.f5, &D0.f6);
	scanf("%d", &n);
	for(j=0; j<n; j++){
		scanf("%d%d", &upper, &front);
		a=0;
		while(D0.f1 != upper){
			D0.tmp = D0.f1;
			a++;
			switch(a%2){
				case 0:
					D0.f1 = D0.f4;
					D0.f4 = D0.f6;
					D0.f6 = D0.f3;
					D0.f3 = D0.tmp;
					break;
				case 1:
					D0.f1 = D0.f2;
					D0.f2 = D0.f6;
					D0.f6 = D0.f5;
					D0.f5 = D0.tmp;
			}
		}
		if(front == D0.f2){
			right = D0.f3;
		}else if(front == D0.f3){
			right = D0.f5;
		}else if(front == D0.f5){
			right = D0.f4;
		}else if(front == D0.f4){
			right = D0.f2;
		}
		printf("%d\n", right);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        String retA = "";
        String retB = "";
        for(int i=0;i<b;i++){
            retA += String.valueOf(a);
        }
        for(int i=0;i<a;i++){
            retB += String.valueOf(b);
        }
        String ret = retA.length()>retB.length() ? retA : retB;
        System.out.println(ret);
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  double w,h;
  cin >> w >> h;
  double x,y;
  cin >> x >> y;
  double ans = (w*h)/2;
  cout << ans << " ";
  if(x == w/2 && y == h/2) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

int main(){
	int n, s;
	cin >> n >> s;
	int d[n];
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		d[i]=abs(s-x);
	}
	int g=d[0];
	for(int i=0; i<n; i++){
		g=gcd(g, d[i]);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;ll k;
    cin>>n>>k;
    vin a(n);
    rep(i,n)cin>>a[i];
    vin arrive(n,0);
    arrive[0]=1;
    int prev=1;
    int next;
    int i=1;
    int circle;
    int tmp;
    while(1){
        i++;
        next=a[prev-1];
        if(arrive[next-1]!=0){
            circle=i-arrive[next-1];
            tmp=arrive[next-1]-1;
            break;
        }
        else arrive[next-1]=i;
        if(i==k+1){
            cout<<next<<endl;
            return 0;
        }
        prev=next;
    }
    /*if(k<=(ll)tmp){
        rep(i,n){
            if(arrive[i]==k+1){
                cout<<i+1<<endl;
                return 0;
            }
        }
    }*/
    ll ans=(k-(ll)tmp)%circle;
    rep(i,n){
        if(arrive[i]==tmp+1+ans){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=1;
    int tmp=-1;//0なら単調非減少1なら単調非増加-1なら未決定
    rep(i,n-1){
        //cout<<i<<" "<<tmp<<endl;
        if(tmp==1){
            if(a[i]>=a[i+1])continue;
            else{
                tmp=-1;
                res++;
                continue;
            }
        }else if(tmp==0){
            //if(i==1)cout<<a[i]<<" "<<a[i+1]<<endl;
            if(a[i]<=a[i+1])continue;
            else{
                tmp=-1;
                res++;
                continue;
            }
        }else{
            if(a[i]==a[i+1])continue;
            else if(a[i]>a[i+1]){
                tmp=1;
                continue;
            }else{
                tmp=0;
                continue;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    const char *Yes = "Yes";
    const char *No = "No";

    int X, Y;
    if (scanf("%d%d", &X, &Y) < 2) return 0;

    vector<int> groupA {1, 3, 5, 7, 8, 10, 12};
    vector<int> groupB {4, 6, 9, 11};
    vector<int> groupC {2};

    vector<int>::iterator ita = find(groupA.begin(), groupA.end(), X);
    size_t ixa = distance(groupA.begin(), ita);

    vector<int>::iterator itb = find(groupB.begin(), groupB.end(), X);
    size_t ixb = distance(groupB.begin(), itb);

    vector<int>::iterator itc = find(groupC.begin(), groupC.end(), X);
    size_t ixc = distance(groupC.begin(), itc);

    if (ixa == groupA.size())
    {
        if (ixb == groupB.size())
        {
            if (ixc == groupC.size())
            {
                printf("%s", No);
            }
            else
            {
                vector<int>::iterator itcy = find(groupC.begin(), groupC.end(), Y);
                size_t ixcy = distance(groupC.begin(), itcy);

                if (ixcy == groupC.size()) printf("%s", No);
                else printf("%s", Yes);
            }
        }
        else
        {
            vector<int>::iterator itby = find(groupB.begin(), groupB.end(), Y);
            size_t ixby = distance(groupB.begin(), itby);

            if (ixby == groupB.size()) printf("%s", No);
            else printf("%s", Yes);
        }
    }
    else
    {
        vector<int>::iterator itay = find(groupA.begin(), groupA.end(), Y);
        size_t ixay = distance(groupA.begin(), itay);

        if (ixay == groupA.size()) printf("%s", No);
        else printf("%s", Yes);
    }

    return 0;
}


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

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll p = max(a, b) * max(c, d);
	ll q = max(a, b) * min(c, d);
	ll r = min(a, b) * min(c, d);
	ll s = min(a, b) * max(c, d);

	cout << max(p, max(q, max(r, s))) << endl;
	
	return 0;
} 

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

int main(){
  int n;cin >> n;
  int v[n],c[n];
  for(int i=0;i<n;i++)cin >> v[i];
  for(int i=0;i<n;i++)cin >> c[i];
  int x=0,y=0;
  for(int i=0;i<n;i++){
    if((x+v[i])-(y+c[i]) > x-y){
      x += v[i];
      y += c[i];
    }
  }
  cout << x - y << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	double a, b;
	scanf("%lf %lf", &a, &b);
	printf("%d\n", (int)ceil((a-1) / (b-1)));
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int32 N, M;
vector<int32> G[112345];
int32 cnt[4] = {};
int32 id[112345] = {};
int main(void){
	cin >> N >> M;
	REP(i, M){
		int32 u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	queue<PII> q;
	q.push({0, 2});
	while(q.size()){
		int32 v, k;
		tie(v, k) = q.front(); q.pop();
		id[v] |= k;
		int32 nxt = (id[v] < 3 ? 3-id[v] : 3);
		REP(i, G[v].size()){
			if(id[G[v][i]] ^ nxt){
				id[G[v][i]] |= nxt;
				q.push({G[v][i], id[G[v][i]]});
			}
		}
	}
	REP(i, N) cnt[id[i]]++;
	int64 res = 0;
	REP(i, N){
		if(id[i] < 3)
			res += cnt[3]+cnt[3-id[i]];
		else
			res += cnt[1]+cnt[2]+cnt[3]-1;
	}
	cout << res/2-M << endl;
}

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

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

using namespace std;

inline int binomial_parity(int n,int r){ return ~n&r?0:1; }

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

	rep(i,n) s[i]--;

	int res=0;
	rep(i,n) if(binomial_parity(n-1,i)==1) res=(res+s[i]-'0')%2;
	if(res==1) return puts("1"),0;

	if(count(s.begin(),s.end(),'1')>0) return puts("0"),0;

	replace(s.begin(),s.end(),'2','1');

	res=0;
	rep(i,n) if(binomial_parity(n-1,i)==1) res=(res+s[i]-'0')%2;
	puts(res==0?"0":"2");

	return 0;
}


Measured memory_bytes: 1412
map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;++$N}for++$q[1]..<>;while(--$N){$b=1;$a<($~=$q[$N]*($b-1-$_)/($#$N||1))or$a=$~for grep$e[$N]=$b+=$_/@$N,@e[@$N]}print$a+$b

Measured memory_bytes: 108308
class SegmentTree
  MIN = -Float::INFINITY
  def initialize(data)
    @offset = 1 << data.length.bit_length
    @data = Array.new(@offset * 2, MIN)
    data.each_with_index do |v, i|
      @data[@offset + i] = v
    end
    i = @offset - 1
    while i > 0
      @data[i] = merge(@data[2 * i], @data[2 * i + 1])
      i -= 1
    end
  end
  def merge(l, r); l > r ? l : r; end
  def max(a, b, k = 1, l = 0, r = @offset)
    mid = (l + r) / 2
    return MIN if b <= l || r <= a
    return @data[k] if a <= l && r <= b
    return merge(max(a,b,2 * k, l, mid), max(a,b,2 * k + 1, mid, r))
  end
end

def max(a,b); a > b ? a : b; end
def min(a,b); a < b ? a : b; end
  
def extract_cycle(s, used)
  cycle = []
  u = s
  until used[u]
    used[u] = true
    cycle << u  
    u = P[u]
  end
  return cycle
end

def max_score_of_cycle(dp, z)
  # セグ木を使って、閉路上の任意の点 s を始点としたときの
  # 最大スコアを O(N log N) で計算
  segtree = SegmentTree.new(dp)
  (0 ... z).map do |s|
    if K >= z
      m = segtree.max(s + 1, s + z + K % z + 1) 
      r = K / z - 1
      r * max(0, dp[z]) + m - dp[s]
    else
      m = segtree.max(s + 1, s + K + 1)
      m - dp[s]
    end
  end.max
end

N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i).tap{|array| array.unshift(0) }
C = gets.split.map(&:to_i).tap{|array| array.unshift(0) }

used = Array.new(N + 1)
ans = (1 .. N).inject(-1e20) do |max_score, s|
  next max_score if used[s]
  # sを始点とする閉路を抽出
  cycle = extract_cycle(s, used)
  z = cycle.size
  
  # 閉路の各頂点から最大2周分のスコアを計算できるように事前準備
  score = Array.new(3 * z + 1, 0)
  (1 .. z * 3).each do |i|
    v = cycle[i % z]
    score[i] = score[i - 1] + C[v]
  end

  # 閉路の最大スコアを計算
  cycle_score = max_score_of_cycle(score, z)
  max(max_score, cycle_score)
end

puts ans


Measured memory_bytes: 15352
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<ull> L(N+1);
  L[0]=2,L[1]=1;
  for(int i=2;i<=N;i++) {
    L[i] = L[i-1]+L[i-2];
  }
  cout << L[N] << endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    long long mod = 1E9 + 7;
    vector<long long> prefix_sum(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        prefix_sum[i + 1] = (prefix_sum[i] + A[i]) % mod;
    }
    long long ans = 0;
    for (int i = 1; i < N; ++i) {
        ans = (ans + (A[i] * prefix_sum[i]) % mod) % mod;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6364
s = list(input())
n = int(input())

t = []

for i in range(len(s)):
    string = ""
    if i < 4:
        for j in range(0,i+1):
            string = s[i-j] + string
            if string not in t:
                t.append(string)
            else:
                continue
    else:
        for j in range(0,5):
            string = s[i-j] + string
            if string not in t:
                t.append(string)
            else:
                continue
t.sort()
print(t[n-1])

Measured memory_bytes: 4084
a, b, c = map(int, input().split())
r_a, r_b, r_c = a % 2, b % 2, c % 2
num = 0
if r_a == r_b and r_b == r_c:
    pass
elif r_a == r_b:
    a += 1
    b += 1
    num += 1
elif r_b == r_c:
    b += 1
    c += 1
    num += 1
else:
    a += 1
    c += 1
    num += 1
a, b, c = tuple(sorted([a, b, c], key=lambda x: -x))
num += (2 * a - b - c) // 2
print(num)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> v;
int n;
int cnt[10010];
int main()
{
	while(1)
	{
		memset(cnt,0,sizeof(cnt));
		v.clear();
		scanf("%d",&n);
		if(n==0)break;
		for(int i=1;i<n;i++)v.pb((i*i)%n);
		SORT(v);
		v.erase(unique(all(v)),v.end());
		//cout << v.size() << endl;
		for(int i=0;i<v.size();i++)
		{
			for(int j=0;j<v.size();j++)
			{
				if(i==j)continue;
				int k=v[i]-v[j];
				if(k<0)k+=n;
				if(k>(n-1)/2)k=n-k;
				cnt[k]++;
			}
		}
		for(int i=1;i<=(n-1)/2;i++)printf("%d\n",cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n ;
   cin >> n ;
   vector < ll > a(n) ;
   ll sum = 0 ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] , sum += a[i] ;
   ll ans = 1e18  , cur = 0 ;
   for( int i = 0 ; i < n ; i++){
        cur += a[i] ;
        ans = min(ans,abs(sum-2*cur));
   }
   cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


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

int main(){
  vector<int> a(3);
  for (int i = 0; i < 3;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(0) + a.at(1) << 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>;

void Main()
{
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  rep(i,Q) {cin >> a[i] >> b[i] >> c[i] >> d[i];}
  // 全てのAについて全パターンを考える
  vector<int> A(10);
  int maxsum = 0;
  for(int A1 = 1; A1 <= M; A1++) {
    A[0] = A1;
    for (int A2 = A1; A2 <= M; A2++) {
      A[1] = A2;
      for (int A3 = A2; A3 <= M; A3++) {
        A[2] = A3;
        for (int A4 = A3; A4 <= M; A4++) {
          A[3] = A4;
          for (int A5 = A4; A5 <= M; A5++) {
            A[4] = A5;
            for (int A6 = A5; A6 <= M; A6++) {
              A[5] = A6;
              for (int A7 = A6; A7 <= M; A7++) {
                A[6] = A7;
                for (int A8 = A7; A8 <= M; A8++) {
                  A[7] = A8;
                  for (int A9 = A8; A9 <= M; A9++) {
                    A[8] = A9;
                    for (int A10 = A9; A10 <= M; A10++) {
                      A[9] = A10;
                      int sum = 0;
                      rep(i,Q) {
                        if (c[i] == A[b[i]-1] - A[a[i]-1]) sum += d[i];
                      }
                      maxsum = max(maxsum, sum);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << maxsum << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3660
from collections import deque
n,m = (int(i) for i in input().split())
x = [[] for i in range(n+1)]
for _ in range(m):
	a,b = (int(i) for i in input().split())
	x[a].append(b)
	x[b].append(a)
s,g,v = 1,x[1][0],[True]*(n+1)
ans = deque([s,g])
while True:
	v[s],v[g],c = False,False,1
	for i in x[s]:
		if v[i]:
			s,c = i,0
			ans.appendleft(i)
			break
	if c:
		for i in x[g]:
			if v[i]:
				g,c = i,0
				ans.append(i)
				break
	if c: break
print(len(ans))
for i in ans: print(i,end=" ")

Measured memory_bytes: 23988
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b) {
			System.out.println("a > b");
		} else if(a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26076
#include <iostream>
using namespace std;
int main()
{
    int N,b=0,i;
    int a[100];
    cin>>N;
    for (i = 0; i < N; ++i) {
        cin>>a[i];
        if ((a[i]%2!=0)&&((i+1)%2!=0))
        {
            b++;
        }
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 3592
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
for i in range(n-1):
  A[i+1]=A[i+1]+A[i]
ans=10**12
for i in range(n-1):
  x=A[i]
  y=A[-1]-A[i]
  ans=min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 76880
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		Long num=Long.valueOf(new Scanner(System.in).nextLine());
		int sum=0;
		for(long temp=num;temp>0;temp/=10) {
			sum+=temp%10;
		}
		System.out.println(num%sum==0?"Yes":"No");
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

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

	ll N;
	string s;
	map<char, ll> m;

	string march = "MARCH";
	rep(i, march.size()) {
		m[march[i]] = 0;
	}

	cin >> N;
	rep(i, N) {
		cin >> s;
		m[s[0]]++;
	}

	ans += m['M'] * m['A'] * (m['R'] + m['C'] + m['H']);
	ans += m['A'] * m['R'] * (m['C'] + m['H']);
	ans += m['M'] * m['R'] * (m['C'] + m['H']);
	ans += m['C'] * m['H'] * (m['M'] + m['A'] + m['R']);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            ans+=c[a[i][j]][1]
print(ans)


Measured memory_bytes: 3444
// 2014/07/17 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;

		if(H==0 && W==0)
			break;

		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){
				if((i+j)%2==0){
					cout << '#';
				}
				else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e16;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	vector<int> a(n+1);
	vector<int> pref(n+1);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		pref[i] = a[i]+pref[i-1];
	}
	int ans = inf;
	for(int i=1; i<n; i++) {
		int s1 = pref[i];
		int s2 = pref[n] - pref[i];
		ans = min(ans, abs(s1-s2));
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define umi unordered_map<int,int>
#define uml unordered_map<ll,ll>
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"

ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

ll gcd(ll a, ll b)
{ 
	return !b ? a : gcd(b, a % b); 
}
ll lcm(ll a, ll b)
{ 
	return (a / gcd(a, b)) * b; 
}
ll fastExponentiation(ll n, ll x, ll modulo) 
{
	ll res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}


ll power(ll n , ll p ){
	if(p==0)
	   return 1;
 
	 ll res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}


void solve()
{
	int k;
	cin>>k;
	
	int n;
	cin>>n;
	
	vi a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
// 		if(i==n-1 && a[0]!=0)
// 		a.pb(a[0]);
// 		else if(i==n-1 && a[0]==0)
        if(i==n-1)
		a.pb(k+a[0]);
		
	}
	
	ll max=INT_MIN;
	for(int i=0;i<a.size()-1;i++)
	{
	    if(max<=abs(a[i]-a[i+1]))
	    max=abs(a[i]-a[i+1]);
	}
// 	cout<<max<<" "<<k<<endl;
	cout<<k-max<<endl;
	
	
	
}


int main()
{
	fastio
	
	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int x,y,tmp=0,c=0;
	bool check=false,haji=true;
	vector<int> stx,sty;
	cin>>s>>x>>y;
	x+=8000;
	y+=8000;
	for(int i=0;i<s.length();i++){
		if(s[i]=='T'){
			if(tmp==0){
				if(check==true) check=false;
				else check=true;
			} 
			if(tmp!=0 && check==false){
				stx.push_back(tmp);
				check=true;
			}else if(tmp!=0 && check==true){
				sty.push_back(tmp);
				check=false;
			}
			tmp=0;
			haji=false;
		}else{
			if(haji){
				x--;
				c++;
			}
			else tmp++;
		}
	}
	if(tmp!=0 && check==false){
		stx.push_back(tmp);
		check=true;
	}else if(tmp!=0 && check==true){
		sty.push_back(tmp);
		check=false;
	}

	if(stx.size()==0 && sty.size()==0 && count(s.begin(),s.end(),'F')==8000 && x==8000){
		cout<<"Yes\n";
		return 0;
	}

	bool dp[stx.size()+10][16100];
	for(int i=0;i<stx.size()+10;i++){
		for(int j=0;j<16100;j++){
			dp[i][j]=false;
		}
	}
	dp[0][c+8000]=true;
	for(int i=0;i<stx.size();i++){
		if(i==0){
			dp[i+1][8000+stx[i]]=true;
			dp[i+1][8000-stx[i]]=true;
			continue;
		}
		for(int j=0;j<16100;j++){
			if(dp[i][j-stx[i]] && j-stx[i]>0) dp[i+1][j]=dp[i][j-stx[i]];
			if(dp[i][j+stx[i]] && j+stx[i]<16100) dp[i+1][j]=dp[i][j+stx[i]];
		}
	}

	bool dp2[sty.size()+10][16100];
	for(int i=0;i<sty.size()+10;i++){
		for(int j=0;j<16100;j++){
			dp2[i][j]=false;
		}
	}
	dp2[0][8000]=true;
	for(int i=0;i<sty.size();i++){
		if(i==0){
			dp2[i+1][8000+sty[i]]=true;
			dp2[i+1][8000-sty[i]]=true;
			continue;
		}
		for(int j=0;j<16100;j++){
			if(dp2[i][j-sty[i]] && j-sty[i]>0) dp2[i+1][j]=dp2[i][j-sty[i]];
			if(dp2[i][j+sty[i]] && j+sty[i]<16100) dp2[i+1][j]=dp2[i][j+sty[i]];
		}
	}

	if(dp[stx.size()][x] && dp2[sty.size()][y]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

int main()
{
    vector<char> s(3);
    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> s.at(i);
        if (s.at(i) == 'o')
            count +=100;
    }
    cout << 700 + count;
}


Measured memory_bytes: 256
import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n < 2 or n & 1 == 0:
		return False
	d = (n-1) >> 1
	while d & 1 == 0:
		d >>= 1
	
	for i in range(5):
		a = rand(1,n-1)
		t = d
		y = pow(a,t,n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Measured memory_bytes: 45276
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new B().doIt();
	}
	class B{
		void doIt(){
			String str = sc.next();
			int length = str.length();
			char ctr[] = str.toCharArray();
			int cnt = 0;
			for(int i = 0;i < length;i++){
				if(i % 2 == 0){
					if(ctr[i] == 'p')cnt--;
				}else{
					if(ctr[i] == 'g')cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 13208
from bisect import bisect_left as bl
from itertools import accumulate as ac
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=[0]+list(ac(a[::-1]))
l,r=2*a[-1]*(n**2)+1,0
while l-r>1:
    t=(l+r)//2
    p=0
    for i in range(n-1,-1,-1):
        if a[i]+a[-1]>=t:
            x=bl(a,t-a[i])
            p+=n-x
        else:
            break
    if p<m:
        l=t
    else:
        r=t
c,d=0,0
w=0
for i in range(n-1,-1,-1):
    if a[i]+a[-1]>=r:
        g=bl(a,r-a[i])
        x=n-g
        c+=s[x]+x*a[i]
        w+=x
    else:
        break
print(c-r*max(0,(w-m)))


Measured memory_bytes: 60636
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main() {
  string hand[3];
  int idx[] = {0, 0, 0};
  for(int i=0; i<3; i++) {
    cin >> hand[i];
  }
  int turn = 0;
  while(true) {
    if(idx[turn] >= hand[turn].size()) {
      printf("%c\n", 'A' + turn);
      break;
    }
    turn = hand[turn][idx[turn]++] - 'a';
  }
  return 0;
}

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

int main(){
  long int n,i,ans=0;
  cin>>n;
  for(i=1;i<(-1.0+sqrt(1+4*n))/2;i++){
    if(n%i==0){ans+=n/i-1;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Deque;
    import java.util.List;
    import java.util.Scanner;

    //
    public class Main {

        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [][] arrys_bingo;
        arrys_bingo = new int [4][4];

        String strs="No";

        int [][] arrys_bingo_result;
        arrys_bingo_result = new int [4][4];


        for(int i=1;i<=3;i++){
            for(int j=1;j<=3;j++){arrys_bingo[i][j]=sc.nextInt();}
        }

        int N = sc.nextInt();
        int [] arrys_n;
        arrys_n = new int [N+1];
        for(int i=1;i<=N;i++){
        arrys_n[i] = sc.nextInt();
        }

        //ビンゴ結果
        for(int i=1;i<=3;i++){
            for(int j=1;j<=3;j++){
                arrys_bingo_result[i][j]=0;
                for(int k=1;k<=N;k++){
                    if(arrys_bingo[i][j]==arrys_n[k]){
                        arrys_bingo_result[i][j]=1;
                    }
                }
            }
        }

        int [] tatekakka;
        tatekakka = new int [4];
        int [] yokokekka;
        yokokekka = new int [4];
        int nanamekekka=1;
        int nanamekekkaa=1;

        //ビンゴ判定1
        for(int i=1;i<=3;i++){
        yokokekka[i]=1;
            for(int j=1;j<=3;j++){
                if(arrys_bingo_result[i][j]==0){
                    yokokekka[i]=0;
                }
            }
        }
        //ビンゴ判定2
        for(int i=1;i<=3;i++){
        tatekakka[i]=1;
            for(int j=1;j<=3;j++){
                if(arrys_bingo_result[j][i]==0){
                    tatekakka[i]=0;
                }
            }
        }
        //ビンゴ判定3
        for(int i=1;i<=3;i++){
                if((arrys_bingo_result[i][i]==0)){
                    nanamekekka=0;
                }
        }
        //ビンゴ判定4
        for(int i=1;i<=3;i++){
                if((arrys_bingo_result[i][4-i]==0)){
                    nanamekekkaa=0;
                }
        }
        for(int i=1;i<=3;i++){
            if((yokokekka[i]==1)||(tatekakka[i]==1)||(nanamekekka==1)||(nanamekekkaa==1)){
            strs="Yes";
            }
        }
        System.out.println(strs);
        }
    }







Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int odp = 0;
    for (int dl = 3; dl <= 9; ++dl)
    {
        for (int mask = 0; mask < pow(3, dl); ++mask)
        {
            vector<int> c;
            int t = mask;
            while (t != 0 || c.size() < dl)
            {
                c.push_back(t % 3);
                t /= 3;
            }
            reverse(c.begin(), c.end());
            int l = 0;
            vector<bool> jest(3, false);
            for (int i = 0; i < c.size(); ++i)
            {
                if (c[i] == 0)
                    l = l * 10 + 3;
                if (c[i] == 1)
                    l = l * 10 + 5;
                if (c[i] == 2)
                    l = l * 10 + 7;
                jest[c[i]] = true;
            }
            if (l <= n && jest[0] && jest[1] && jest[2])
                ++odp;
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] a = new int[3];
		for (int i=0; i<3; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
	}
}

Measured memory_bytes: 17356
n, x, y = map(int, input().split())
l = [0]*n

for i in range(1, n):
    for j in range(i + 1, n + 1):
        diff1 = j - i
        diff2 = abs(x - i) + abs(y - j) + 1
        diff = min(diff1, diff2)
        l[diff] = l[diff] + 1

for i in range(1, n):
    print(l[i])

Measured memory_bytes: 46684
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	vector<int> le, ri;
	vector<int> G[100000];
	bool used[100000];
	int n, m; cin >> n >> m;
	fill(used, used + n, false);
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	le.push_back(0); ri.push_back(G[0][0]);
	used[0] = used[G[0][0]] = true;
	int now = 0;
	while (true) {
		int len = G[now].size();
		bool g = true;
		rep(i, len) {
			int v = G[now][i];
			if (!used[v]) {
				le.push_back(v);
				now = v; used[v] = true; g = false;
				break;
			}
		}
		if (g)break;
	}
	now = G[0][0];
	while (true) {
		int len = G[now].size();
		bool g = true;
		rep(i, len) {
			int v = G[now][i];
			if (!used[v]) {
				ri.push_back(v);
				now = v; used[v] = true; g = false;
				break;
			}
		}
		if (g)break;
	}
	int l1 = le.size(); int l2 = ri.size();
	cout << l1 + l2 << endl;
	per(i, l1) {
		if (i < l1 - 1)cout << " ";
		cout << le[i]+1;
	}
	rep(i, l2) {
		cout << " "<<ri[i]+1;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n , k ,t ;
           cin >> n >> k >> t;
           
           if(n % k == 0)
           {
               cout << (n / k) * t;
           }
           else
           {
               cout << (n / k + 1) * t;
           }
        }
    }



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    string ans="";
    ans.push_back(s[0]);
    for(int i=0; i<n-1; i++) {
        if(s[i]!=s[i+1]){
            ans.push_back(s[i+1]);
        }
    }
    cout<<ans.length()<<endl;
    return  0;
}


Measured memory_bytes: 592
n = int(input())
di = {}
for i in range(n):
    sl = "".join(sorted(list(input())))
    if sl in di:
      di[sl] += 1
    else:
      di[sl] = 1
def nc2(n):
    a = n * (n-1) /2
    return int(a) #1c2 =0
ls = di.items()
cnt = 0
for i in ls:
    cnt += nc2(i[1])
print(cnt)


Measured memory_bytes: 17932