akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <cstdio>
using namespace std;
 
const int r_MAX = 100,c_MAX = 100;
int n[r_MAX][c_MAX];
 
void input(int r,int c){
    for (int i1 = 0; i1 < r; i1++){
        for (int i2 = 0; i2 < c; i2++){
            cin >> n[i1][i2];
        }
    }
}
 
void list(int r,int c){
    int allsum = 0;
    for (int i1 = 0; i1 < r; i1++){
        int sum = 0;
        for (int i2 = 0; i2 < c; i2++){
            cout << n[i1][i2] << ' ';
            sum += n[i1][i2];
        }
        cout << sum << endl;
        allsum += sum;
    }
    for (int i2 = 0; i2 < c; i2++){
        int sum = 0;
        for (int i1 = 0; i1 < r; i1++){
            sum += n[i1][i2];
        }
        cout << sum <<' ';
    }
    cout << allsum << endl;
}
 
int main(){
 
    int r, c;
    cin >> r >> c;
 
    input(r, c);
 
    list(r, c);
 
    return 0;
}


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

using namespace std;

int main() {

	long n;
	cin >> n;

	string s;
	cin >> s;

	long counter;
	counter = s.size();
	for (long i = 0; i < s.size()-1; i++) {
		if (s[i] == s[i + 1]) { counter--; }
	}

	cout << counter << endl;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

LL dfs(vector<LL> &dic, int c, int i) {
    if(c == 3) {
        return 1;
    }
    if(i == 5) {
        return 0;
    }

    return dic[i]*dfs(dic, c + 1, i + 1) + dfs(dic, c, i + 1);
}

int main() {
    map<char, LL> m;
    int N;
    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        m[s[0]]++;
    }
    vector<LL> dic = {m['M'], m['A'], m['R'], m['C'], m['H']};
    LL res = dfs(dic, 0, 0);
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int A,B,C,X; cin>>A>>B>>C>>X;
    int ans=0;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++) {
                if(X==500*i+100*j+50*k){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
const int MOD = 1000000007;

signed main(){
    int n,ans=0;
    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];
    for(int i=0;i<n;i++){
        ans+=max(0,v[i]-c[i]);
    }
   cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):
    pool = set()
    for l in range(K):
        for i in range(0, len(s)-l):
            pool.add(s[i:i+l+1])
    return sorted(pool)[K-1]


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    print(solve(s, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 10580
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    vi p(n);
    rep(i, n) {
        cin >> p[i];
    }

    if(n == 0) {
        cout << x << endl;
        return 0;
    }

    sort(all(p));
    int ans;
    int j = 0;
    while(1) {
        if(*lower_bound(all(p), x-j) != x-j) {
            ans = x-j;
            break;
        } 
        if(*lower_bound(all(p), x+j) != x+j) {
            ans = x+j;
            break;
        } 
        j++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
N,M=map(int,input().split())
S=[]
for i in range(N):
  a,b=map(int,input().split())
  S.append((a,b))
P=[]
for i in range(M):
  c,d=map(int,input().split())
  P.append((c,d)) 
for i in range(N):
  D=10**9
  ans=0
  for j in range(M-1,-1,-1):
    if D>=(abs(S[i][0]-P[j][0])+abs(S[i][1]-P[j][1])):
      D=(abs(S[i][0]-P[j][0])+abs(S[i][1]-P[j][1]))
      ans=j
  print(ans+1)   

Measured memory_bytes: 9160
#include <algorithm> 
#include <cstdio>
#include <cstring>

const int N=5e5+5;

char s[N];

int n,a[N]; long long ans;

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;++i){
		if(s[i]=='<') a[i+1]=a[i]+1;
	}
	for(int i=n;i>=1;--i){
		if(s[i]=='>') a[i]=std::max(a[i],a[i+1]+1);
	}
	for(int i=1;i<=n+1;++i) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, A[10900], B[10900], acou=0, bcou=0;
    cin>>N;
    rep(i, N) cin>>A[i];
    rep(i, N) cin>>B[i];
    rep(i, N){
        ll a=A[i];
        ll b=B[i];
        if(a>b) bcou+=a-b;
        else{
            if(a%2==b%2) acou+=(b-a)/2;
            else acou+=(b-a+1)/2, bcou++;
        }
        //cout<<acou<<sp<<bcou<<endl;
    }
    cout<<(acou>=bcou ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Solution
{
    class Solution
    {
        static void Main(string[] args)
        {
            string s = System.Console.ReadLine();
            int n = 0;
            int ans = 0;
            for(int i = s.Length-1; i >=0;i--)
            {
                if (s[i] == 'T') n++;
                else if (n > 0) { n--; ans += 2; }
            }
            System.Console.WriteLine(s.Length-ans);
        }

    }
}


Measured memory_bytes: 11616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n; cin>>n;
	ll sm=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				int a=i, b=j;
				int po=__gcd(a,b);
				int y=__gcd(po,k);
				sm+=y;
			}
		}
	}
	cout<<sm;
	
}

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

int a[2005] = {0};
int main() {
	
	string s;
		
	while (cin >> s) {
		for (int i = 0	; i < s.size(); i++) {
			if ((s[i] >= 'a')&&(s[i] <= 'z')) {
				a[s[i] - 97] ++;
			} else if ((s[i] >= 'A')&&(s[i] <= 'Z')) {
				a[s[i] - 65] ++;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << (char)(i + 'a')<< " : " << a[i] << endl;
	}
	
	return 0;
}


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

#define INF 2000000000
#define LINF 9000000000000000000

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

int n, m;
bool d[8][8];
bool visited[8];

int dfs(int v) {
	bool all = true;

	for (int i = 0; i < n; i++) {
		if (!visited[i]) all = false;
	}
	if (all) return 1;

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (!d[v][i]) continue;
		if (visited[i]) continue;
		visited[i] = true;
		cnt += dfs(i);
		visited[i] = false;
	}

	return cnt;
}

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

	for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) d[i][j] = false;
	for (int i = 0; i < 8; i++) visited[i] = false;

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		d[a][b] = d[b][a] = true;
	}

	visited[0] = true;
	int ans = dfs(0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<int> vCnt(s.size()+1, 0);
    vector<int> vCS (s.size()+1, 0); // cumulative sum
    
    for(uint i=1; i<s.size(); ++i){
        if(s[i-1]=='A' && s[i]=='C'){ vCnt[i+1] = 1; }
    }
    
    vCS[0] = vCnt[0];
    for(uint i=1; i<vCS.size(); ++i){
        vCS[i] = vCS[i-1] + vCnt[i];
    }
    
    for(uint i=0; i<Q; ++i){
        uint l, r; cin >> l >> r; // 逐次読み込みながら出力しているため，表示は少しバグる．
        if(s[l-1]=='C'){ ++l; }
        cout << vCS[r] - vCS[l-1] << endl;
    }
    
    return 0;
}
/*
ACACTACG
3 7
2 3
1 8
           A C A C T A C G
vCnt = [ 0 0 1 0 1 0 0 1 0 ]
vCS  = [ 0 0 1 1 2 2 2 3 3 ]
*/


Measured memory_bytes: 1872
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

ll N;
ll c = 0;

void search(ll s,bool three,bool five,bool seven){
    if(s <= N) {
        if(three && five && seven) ++c;
        search(s*10 + 3 , true,five,seven);
        search(s*10 + 5 , three,true,seven);
        search(s*10 + 7 , three,five,true);
    }
    else return;
}

int main(){
    cin >> N;
    search(3,true,false,false);
    search(5,false,true,false);
    search(7,false,false,true);
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)






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

	char s[100000];
	rep(i, 0, n) cin >> s[i];
	int Ans = 1;


	rep(i, 0, n - 1) {
		if (s[i] == s[i + 1]) {
			continue;
		}
		else Ans++;
	}

	cout << Ans;
}

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

int main() {
  int n;
  cin >> n;
  while (n) {
    if (n%10 == 9) {
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

      int result1 = a * b;
      int result2 = (a + b) * 2;

      System.out.println(result1+" "+result2);
    }
}

Measured memory_bytes: 25884
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int mi = INT_MAX;
    int ans = INT_MIN;
    rep(i, n) {
        int r;
        cin >> r;
        ans = max(ans, r-mi);
        mi = min(r, mi);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  int cnt1=0,cnt2=0,cnt3=0;
  while(x>0||y>0){
    if(x>0&&y>0){
      if(a+b > 2*c){
	int t = min(x,y);
	x-=t; y-=t;
	cnt3 += 2*t;
      } else {
	int t = min(x,y);
	x-=t; y-=t;
	cnt1 += t; cnt2 += t;
      }
    } else {
      if(x > 0){
	if(a > 2*c){
	  cnt3 +=2*x;
	  x=0;
	} else {
	  cnt1 += x;
	  x = 0;
	}
      }

      
      if(y > 0){
	if(b > 2*c){
	  cnt3 +=2*y;
	  y=0;
	} else {
	  cnt2 += y;
	  y = 0;
	}
      }
    }
  }
  cout << cnt1 * a + cnt2 * b + cnt3 * c << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l1 = []
l2 = []
for i in range(n):
    l1.append(a[i]+i)
    l2.append(-a[i]+i)
j = {}
ans = 0
for i in l1:
    if i in j:
        j[i]+= 1
    else:
        j[i] = 1
for i in l2:
    if i in j:
        ans+=j[i]
print(ans)


Measured memory_bytes: 50860
N, A, B = map(int, input().split())
if abs(A-B)%2 == 0:
    print(abs(A-B)//2)
else:
    if A - 1 <= N - B:
        print(A + (B - A - 1) // 2)
    else:
        tmp = N - B + 1
        A += tmp
        tmp += (N - A + 1) // 2
        print(tmp)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

std::string IntToString(long long a){
  char x[100];
  sprintf(x,"%lld",a);
  std::string s = x;
  return s;
}
long long StringToInt(std::string a){
  char x[100]; long long res;
  strcpy(x,a.c_str());
  sscanf(x,"%lld",&res);
  return res;
}
inline void printIntVal(long long a) {
  std::cout << "The Value is: "<< IntToString(a) << std::endl;
}
inline void printStringVal(std::string a) {
  std::cout << "The Value of is: "<< a << std::endl;
}
inline std::string GetString(){
  char x[1000005];
  scanf("%s",x);
  std::string s = x;
  return s;
}

inline int GetInt(){
  int x;
  scanf("%d",&x);
  return x;
}

inline std::string uppercase(std::string s){
  int n = (int)s.size();
  for(int i = 0; i < n; i++) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline std::string lowercase(std::string s){
  int n = (int)s.size();;
  for(int i = 0; i < n; i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN (std::string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}
inline long long CharToInt(char c) {
    return (c - '0');
}

// ---------------------------------------------------------

int main() {

  int a = GetInt();
  int mod = GetInt();
  int c = GetInt();

  bool solve = false;

  for(int i = 0; i < 300; i++) {
    if(c % mod == (i*a) % mod) {
      std::cout << "YES" << std::endl;
      solve = true;
      break;
    }
  }

  if(!solve) {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int n;cin>>n;
    vector<string> S(n);
    map<char,int> mp;
    REP(i,n){
        map<char,int> cnt;
        cin>>S[i];
        REP(j,S[i].size()) cnt[S[i][j]]++;
        if(i==0) mp=cnt;
        else REP(j,26){
            mp[char(j+'a')]=min(mp[char(j+'a')],cnt[char(j+'a')]);
        }
    }
    string ans;
    for(auto e:mp) ans+=string(e.second,e.first);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = [_ for _ in input()]
d = {'r':p,"s":r,"p":s}
ans = 0
t_hand = []
for i,x in enumerate(t):
    if i-k<0:
        ans += d[x]
        t_hand.append(d[x])
        continue
    if (t[i-k] == x)and(t_hand[i-k]!=0):
        ans += 0
        t_hand.append(0)
    else:
        ans += d[x]
        t_hand.append(d[x])
        
print(ans)

Measured memory_bytes: 4796
import math
import os
import sys
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())


@lru_cache(maxsize=None)
def func(n, k):
    if n < k:
        return n
    if n % k == 0:
        return func(n // k, k)
    else:
        # return func(n - k, k)
        return n % k


def test(N):
    cnt = 0
    for k in range(2, N + 1):
        c = func(N, k)
        if c == 1:
            cnt += 1
        print(k, c)
    print(cnt)


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


# test(N)

# k == N - 1 の約数のとき 1 になる
ans = len(get_divisors(N - 1))
for k in get_divisors(N):
    if (N - 1) % k == 0:
        continue
    p = N // k
    if p >= k:
        ans += func(N // k, k) == 1
print(ans)


Measured memory_bytes: 41072
s[50],j,p,q;main(i){for(;p=atoi(gets(s));printf("%d\n",i)){for(i=0;i<p;s[i++]=strlen(gets(s+i)));for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=0x886860>>j++*4&15;q>1;q-=s[p++]);}}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    // 3^45 mod. 1000000007 を計算してみる
    long long a,b;
    cin>>a>>b;
    cout << modpow(a, b, 1000000007) << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    int n,i;
    double x[100],y[100],mink_1=0,mink_2=0,mink_3=0,mink_mugen=0,a=0,b=0;
 
    scanf("%d",&n);
 
    for(i=0;i<n;i++)
    {
        scanf("%lf",&x[i]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%lf",&y[i]);
    }
    for(i=0;i<n;i++)
    {
        if(x[i]>y[i])
        {
            mink_1+=x[i]-y[i];
        }
        else
        {
            mink_1+=y[i]-x[i];
        }
    }
    printf("%f\n",mink_1);
 
    for(i=0;i<n;i++)
    {
        if(x[i]>y[i])
        {
            a+=pow(x[i]-y[i],2);
        }
        else
        {
            a+=pow(y[i]-x[i],2);
        }
    }
    mink_2=sqrt(a);
    printf("%f\n",mink_2);
 
    for(i=0;i<n;i++)
    {
        if(x[i]>y[i])
        {
            b+=pow(x[i]-y[i],3);
        }
        else
        {
            b+=pow(y[i]-x[i],3);
        }
    }
    mink_3=pow(b,1.0/3.0);
	printf("%f\n",mink_3);
    
	mink_mugen=(double)abs((int)(x[0]-y[0]));
	for(i=1;i<n;i++)
	{
		
		if((double)abs((int)(x[i]-y[i]))>mink_mugen)
		{
			mink_mugen=(double)abs((int)(x[i]-y[i]));
		}
		
	}
	printf("%f\n",mink_mugen);
	 
    return 0;
}


Measured memory_bytes: 2104
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
pls = 1
mod = 10**9+7
a_minu = [i for i in a if i <0]
if k==len(a):
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans)

elif len(a_minu)==len(a) and k%2==1:
    a.sort(reverse=True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans)

else:
    ani= 0
    anj= 0
    tmp = 0
    tmp2  = 0
    alis = []
    lasim = -1
    lasip = -1
    for i in a:
        if i<0:
            alis.append([-i,-1])
        else:
            alis.append([i,1])
    alis.sort(key=lambda x:x[0], reverse=True)
    for i in range(k):
        if alis[i][1]==-1:
            lasim =  i
        else:
            lasip = i
        ans *= alis[i][0]
        ans %= mod
        pls *= alis[i][1]
    if pls ==1:
        print(ans)
    else:
        ju= 0
        jud = 0
        if lasim >= 0:
            tmp = ans*pow(alis[lasim][0],mod-2,mod)
            for i in range(k,n):
                if alis[i][1]==-1:
                    continue
                else:
                    #print(alis[i][0],tmp)
                    tmp *= alis[i][0]
                    ju = 1
                    ani = alis[i][0]
                    break
            if ju==0:
                tmp = 0
        if lasip >= 0:
            tmp2 = ans*pow(alis[lasip][0],mod-2,mod)
            for i in range(k,n):
                if alis[i][1]==1:
                    continue
                else:
                    #print(alis[i][0],tmp2)
                    tmp2 *= alis[i][0]
                    jud = 1
                    anj = alis[i][0]
                    break
            if jud==0:
                tmp2 = 0

        if abs(alis[lasip][0]*ani)<=abs(alis[lasim][0]*anj):
            print(tmp2%mod)
        else:
            print(tmp%mod)


Measured memory_bytes: 117784
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, m;
    cin >> n >> m;

    while (m--) {
        int a;
        cin >> a;
        n -= a;
    }

    cout << max(n, -1) << "\n";
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w", stdout);
    #endif
	FAST();
	rl(n)
	ll a,b;
	ll st=0;
	bool c=0;
	fo(i,n)
	{
		cin>>a>>b;
		if(a==b)
		{
			if(st==2)
			{
				c=1;
			}
			st++;
		}
		else
		{
			st=0;
		}
		
	}
	if(c)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
#kenken

import sys
tmp = input()
limit = len(tmp)

i=0
numa=0
total=0
while(i<limit):
	if(tmp[i]=="A"):
		numa+=1
		i+=1
	elif(i+1==limit):
		break
	elif(tmp[i]=="B")and(tmp[i+1]=="C"):
		total+=numa
		i+=2
	else:
		numa=0
		i+=1

#print(tmp)
#print(limit)
print(total)



Measured memory_bytes: 3500
#include<stdio.h>

int main(){
    int x,y,z,i,temp,counter;
    scanf("%d %d %d",&x,&y,&z);
    for(i=x; i<=y ;i++){
        temp=z%i;
        if(temp == 0){
            counter++;
        }
    }
    printf("%d\n",counter);
}


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

vector<int> vis;
int cnt = 0;

void dfs(int i, vector<vector<int>>& adj) {
    if (vis[i]) return;
    vis[i] = 1;
    cnt++;
    for (int v : adj[i]) {
        dfs(v, adj);
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector<vector<int>> adj(n);
        int u, v;
        for (int i = 0; i < m; i++) {
            cin >> u >> v;
            u--;
            v--;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        vis = vector<int>(n);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (!vis[i]) {
                cnt = 0;
                dfs(i, adj);
                ans = max(ans, cnt);
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 21848
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List
import Data.Ord

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

diffs :: [Int] -> [Int]
diffs [_] = []
diffs [d1, d2] = [d1 - d2]
diffs (d1:d2:ds) = d1 - d2 : diffs (d2:ds)

solve :: Int -> Int -> [Int] -> Int
solve size 0 _ = size
solve size count (x:xs) = solve (size - x) (count - 1) xs

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  xs <- sortOn Down <$> readIntsLine
  let ds = sortOn Down $ diffs xs
  print $ solve (head xs - last xs) (min (length ds) (n - 1)) ds

Measured memory_bytes: 29052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
 
int main(){
  int n;
  cin>>n;
  long long ans=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    sc.nextInt()
    val W = Array.fill(sc.nextInt)((sc.nextInt, sc.nextInt)).map(A => A._1 * A._2).sum
    if (W < 0) {
      println(-W)
      for (_ <- 0 until -W) {
        println("1 1")
      }
    }else{
      println(W)
      for (_ <- 0 until W) {
        println("-1 1")
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 52708
#!/usr/bin/python
# coding: UTF-8

y,m,d = map(int,input().split("/"))

h='Heisei'
t = 'TBD'

if m > 4:
    print(t)
elif m < 4:
    print(h)
else:
    if m > 30:
        print(t)
    else:
        print(h)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = 0;
    }
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int x = i * i + j * j + k * k + i * j + j * k + k * i;
                if(x <= n) a[x - 1]++;
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int A[100001];

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

	int N; cin >> N;
	ll ans = 0;
	for (int i = 0; i < N; i++) cin >> A[i];
	A[N] = 0;

	for (int i = 0; i < N; i++) {
		ans += A[i] / 2;
		A[i] -= 2 * (A[i] / 2);
		if (A[i]) {
			if (A[i + 1]) {
				ans++;
				A[i + 1]--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int n,k,x;
  cin >> n >> k;
  set<int> num;
  for (int i = 0; i < k; i++) {
    int l; 
    cin >> l;
    for (int j = 0; j < l; j++) {
      cin >> x;
      num.insert(x);
    }
  }
  cout << n - num.size() << endl;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=998244353;

int main(){
  int N;
  double p[3000];
  cin>>N;
  for (int i(1);i<=N;i++) cin>>p[i];
  double dp[3000] = {0.0}; 
  dp[0] = 1;
  for (int i(1);i<=N;i++){
    for (int j(N);j>=0;j--){
      dp[j]=(dp[j]*(1-p[i]));
      if (j!=0){
        dp[j]+=(dp[j-1]*p[i]);
      }
    }
  }
  double ans(0.0);
  for (int i(N/2+1);i<=N;i++){
    ans+=dp[i];
  }
  cout <<setprecision(10) << ans << endl;
  return 0;
}

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

#define MAX_N 100
#define MAX_V 100000
#define INF 1LL<<60
typedef long long int ll;

ll dp[MAX_N + 1][MAX_V + 1];

int main() {
  int n, v[MAX_N + 1];
  ll W, w[MAX_N + 1];

  std::cin >> n >> W;
  for(int i = 0; i < n; ++i) {
    std::cin >> w[i] >> v[i];
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= MAX_V; ++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= MAX_V; ++j) {
      if(j - v[i] >= 0) {
        dp[i + 1][j] = std::min(dp[i][j], dp[i][j - v[i]] + w[i]);
      } else {
        dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
      }
    }
  }

  int ans = 0;
  for(int j = 0; j <= MAX_V; ++j) {
    if(dp[n][j] <= W) {
      ans = j;
    }
  }

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


Measured memory_bytes: 79104
#include<numeric>
#include<iostream>
#include<vector>

using namespace std;
int main(){

    int N, T, A;
    int diff = 1<<30;
    int ans = 0;
    cin >> N >> T >> A;
    for (int i = 0; i < N; i++){
        int tempH;
        cin >> tempH;

        int TAtTempH = T*1000 - tempH*6;
        
        if (diff > abs(TAtTempH - A * 1000)){
            diff = abs(TAtTempH - A * 1000);
            ans = i + 1;
        }
    }
    cout << ans << "\n";

    return 0;
}

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



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

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    vector<int> r(n);
    int result = 0;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        cin >> r[i];
        result += (r[i] - l[i]) + 1;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    int total = (800 * N) - 200 * (N / 15);
    cout << total << endl;
}

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

int main(void) {
	int i, j;
	int ans, ans_temp;
	int len_s, len_t;
	char S[1024];
	char T[1024];

	fgets(S, sizeof(S), stdin);
	fgets(T, sizeof(T), stdin);

	len_s = strlen(S);
	if(S[len_s - 1] == '\n') {
		len_s -= 1;
	}

	len_t = strlen(T);
	if(T[len_t - 1] == '\n') {
		len_t -= 1;
	}

	ans = len_t;
	for(i = 0; i <= len_s - len_t; i += 1) {
		ans_temp = 0;
		for(j = 0; j < len_t; j += 1) {
			if(T[j] != S[j + i]) {
				ans_temp += 1;
			}
		}
		if(ans_temp < ans) {
			ans = ans_temp;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2064
N = int(input())
root = list(map(int,input().split()))
root.append(0)
total = [0]*(N+2)
total[0] = abs(root[0])
for i in range(1,N+1):
    total[i] += abs(root[i]-root[i-1])
sumN = sum(total)
for j in range(N):
    tmp = sumN - (total[j] + total[j+1]) + abs(root[j+1] - root[j-1])
    print(tmp)

Measured memory_bytes: 14048
S = input()
l = len(S) - 1
for i in range(2 ** l):
    op = ["-"] * l
    for j in range(l):
        if ((i >> j) & 1):
            op[l - 1 - j] = "+"
    formula = ""
    for j in range(l):
        formula+=S[j]
        if op[j]=="+":
            formula+="+"
        else:
            formula+="-"
    formula+=S[l]
    if eval(formula)==7:
        print(formula+"=7")
        break

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

using namespace std;
#define int long long
typedef long long ll;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

signed main() {
    int a, b;
    cin >> a >> b;
    int cnt = a - 1;
    if (b >= a) cnt++;
    cout << cnt << endl;
}



Measured memory_bytes: 380
a, b = gets.chomp.split(" ").map(&:to_i)
if a == b
  puts "Draw"
else
  if a == 1
    puts "Alice"
  elsif b == 1
    puts "Bob"
  else
    if a > b
      puts "Alice"
    else
      puts "Bob"
    end
  end
end

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

using namespace std;

#define FOR(i, a, b) for (int(i) = a; (i) <= (b); ++(i))
#define rep(i, n) FOR(i, 0, n-1 )
#define all(c) (c).begin(), (c).end()
#define mod 1000000007LL
#define INF 123456789012345
#define int long long

bool ok[205];
int sosu[6] = {3,5,7,11,13,17};

signed main() {

  string s;cin>>s;
  int k; cin>> k;

  int cnt;
  rep(i,s.size())
  {
    if(i+1 == k)
    {
      cout << s[i] << endl;
      return 0;
    }

    if(s[i] == '1') continue;
    cnt = i;
    break;
  }

  cout << s[cnt] << endl;
  return 0;
     
}


Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}



signed main() {
	string s;
	cin >> s;
	int ans = 0;
	REP (i,s.size()) {
		if (s[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
const int N = 1405949; // 405949 is my favorite number, but it's less than 5e5
const int MOD = 1e9 + 7;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll inv(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int n;
int k;

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0)
    {
        cout << 0;
        return 0;
    }
    long long ans = 0;
    for (int t1 = 0; t1 <= 1000000; t1++)
    {
        long long xx = x - t1, yy = y - 2 * t1;
        if (xx >= 0 && yy >= 0 && xx == 2 * yy)
        {
            //cout << xx << " " << yy << endl;
            ans += cnk((x + y) / 3, yy);
            ans %= MOD;
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
Check corner cases.
*/


Measured memory_bytes: 33152
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

struct UnionFindTree{
	UnionFindTree():pos(pair<int, int>(-1, -1)), root(NULL), next(NULL){}
	pair<int, int> pos;
	UnionFindTree *root;
	UnionFindTree *next; //この問題で入れる意味は多分ない
};

void dfs(int x, int y, int &count, vector<vector<UnionFindTree> > &pos){
	if(pos[pos[y][x].pos.Y][pos[y][x].pos.X].root==NULL){
		if(pos[y][x].root==NULL) pos[pos[y][x].pos.Y][pos[y][x].pos.X].root = &pos[y][x];
		else pos[pos[y][x].pos.Y][pos[y][x].pos.X].root = pos[y][x].root;
		dfs(pos[y][x].pos.X, pos[y][x].pos.Y, count, pos);
	}
	else if(pos[y][x].root == pos[pos[y][x].pos.Y][pos[y][x].pos.X].root){
		count++;
		return;
	}
	else return;
}

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		vector<vector<UnionFindTree> > pos(n, vector<UnionFindTree>(n, UnionFindTree()));
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> pos[i][j].pos.X >> pos[i][j].pos.Y;
			}
		}
		int count = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(pos[i][j].root != NULL) continue;
				dfs(j, i, count, pos);
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
import fractions
A,B = map(int,input().split())
x = fractions.gcd(A,B)
pf = {}
for i in range(2,int(x**0.5)+2):
  while x%i == 0:
    pf[i] = pf.get(i,0) +1
    x //= i
if x > 1:
  pf[x] = 1
print(len(pf)+1)

Measured memory_bytes: 5048
n,m=map(int,input().split())
# print(n,m)
i=0
mini=0
maxi=0
while(i<m):
	if(i==0):
		mini,maxi=map(int,input().split())
			
	else:
		mint,maxt=map(int,input().split())
		mini=max(mini,mint)
		maxi=min(maxi,maxt)

	i+=1
t=maxi-mini+1
if(t<0):
	print(0)
else:
	print(t)

    

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
signed main() {
	int a, b;
	int n;
	cin >> n >> a >> b;
	n %= 12;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) a = a - b;
		else b = a + b;
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#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(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;
//const int MOD = 10e9+7;
const int MOD = 1000000007;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	const int MAX_NUM = 10004; // 最大のn
	vector<ll> fact;
	vector<ll> inv;
	FACTORIAL(): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modpow( fact[i], MOD-2 );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact;


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}

ll f(ll a, ll b){
	return cmb( a+b, a );
}

ll dp[4050][4050];
int main(){
	ll N, A[200005], B[200005], ans=0;
	int offset = 2005;

	cin >> N;
	rep(i,N){
		cin >> A[i] >> B[i];
		dp[ offset-A[i] ][ offset-B[i] ] += 1;
	}

	rep(i,4010) rep(j,4010){
		dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
		dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
	}

	ll sum = 0;
	rep(i,N){
		sum = (sum + dp[ offset+A[i] ][ offset+B[i] ]) % MOD;
	}
//	cout << sum << endl;

//	ll sum2 = 0;
//	rep(i,N) rep(j,N){
//		sum2 = (sum2 + f(A[i]+A[j], B[i]+B[j]) ) % MOD;
//	}
//	cout << sum2 << endl;

	ll db = 0;	// ダブリ
	rep(i,N){
		db = (db + f( A[i]+A[i], B[i]+B[i] ) ) % MOD;
	}

	ans = (((sum + MOD - db) % MOD) * modinv(2) ) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 130432