akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

int gcd(int a, int b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}
int main(){
  int k; cin>>k;
  int ans=0;
  
  for(int a=1; a<=k; a++){
    for(int b=1; b<=k; b++){
      for(int c=1; c<=k; c++){
        ans+=gcd(c, gcd(a,b));
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3620
x, y = map(int, input().split())
d = abs(abs(x) - abs(y))
if 0 <= x < y or x < y <= 0:
  print(d)
elif y < 0 < x or x < 0 < y:
  print(d+1)
elif 0 < y < x or y < x < 0:
  print(d+2)
elif y == 0 < x or y < x == 0:
  print(d+1)
else:
  raise Exception

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

int N;
string S; int X, Y;
vector<int> dx, dy;

constexpr int MAX_LEN = 16005;

int arrx[2][MAX_LEN], arry[2][MAX_LEN], *dpx[2], *dpy[2];

int main() {
    for (int j = 0; j < 2; ++j) {
        dpx[j] = arrx[j]+MAX_LEN/2;
        dpy[j] = arry[j]+MAX_LEN/2;
    }

    cin >> S >> X >> Y;
    N = S.size();

    int x = 0;
    while (x < N && S[x] == 'F') ++x;

    int iv = 1, acc = 0;
    for (int idx = x+1; idx < N; ++idx) {
        if (S[idx] == 'F') {
            ++acc;
        } else {
            if (acc > 0) {
                (iv == 0 ? dx : dy).push_back(acc);
                acc = 0;
            }
            iv = 1 - iv;
        }
    }
    if (acc > 0) {
        (iv == 0 ? dx : dy).push_back(acc);
    }

    fill(arrx[0], arrx[0]+MAX_LEN, 0);
    fill(arry[0], arry[0]+MAX_LEN, 0);
    dpx[0][x] = 1;

    for (int j = 0; j < (int)dx.size(); ++j) {
        int jj = j%2;
        fill(arrx[1-jj], arrx[1-jj]+MAX_LEN, 0);

        for (int k = -MAX_LEN/2; k <= MAX_LEN/2; ++k) {
            if (dpx[jj][k] == 1) {
                dpx[1-jj][k-dx[j]] = 1;
                dpx[1-jj][k+dx[j]] = 1;
            }
        }
    }

    dpy[0][0] = 1;
    for (int j = 0; j < (int)dy.size(); ++j) {
        int jj = j%2;
        fill(arry[1-jj], arry[1-jj]+MAX_LEN, 0);

        for (int k = -MAX_LEN/2; k <= MAX_LEN/2; ++k) {
            if (dpy[jj][k] == 1) {
                dpy[1-jj][k-dy[j]] = 1;
                dpy[1-jj][k+dy[j]] = 1;
            }
        }
    }

    cout << (dpx[dx.size()&1][X] == 1 && dpy[dy.size()&1][Y] == 1 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int f[100005];
int n;
int cnt;
struct house
{
	int x,y;
	int id;
};
house a[100005];
struct edge
{
	int x,y;
	int val;
};
edge e[100005<<2];
int find(int x)
{
	return x==f[x]? x : f[x]=find(f[x]);
}
bool cmp(house a,house b)
{
	return a.x<b.x;
}
bool cmp2(house a,house b)
{
	return a.y<b.y;
}
bool cmp3(edge a,edge b)
{
	return a.val<b.val;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<n;i++)
	{
		cnt++;
		e[cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].x-a[i+1].x);
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<n;i++)
	{
		cnt++;
		e[cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].y-a[i+1].y);
	}
	sort(e+1,e+cnt+1,cmp3);
	int p=0;
	long long ans=0;
	for(int i=1;i<=cnt;i++)
	{
		int fx=find(e[i].x);
		int fy=find(e[i].y);
		if(fx==fy)
		{
			continue;
		}
		f[fx]=fy;
		ans+=e[i].val;
		p++;
		if(p==n-1)
		{
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6528
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

cnt = 0
n.times do |i|
  j = i + 1
  k = i + 2
  while k < n
    cnt += 1 if s[i] != s[j] && s[j] != s[k] && s[i] != s[k]
    j += 1
    k += 2
  end
end

ans = s.count('R') * s.count('G') * s.count('B') - cnt

puts ans

Measured memory_bytes: 14292
from math import gcd
n=int(input())
a=list(map(int,input().split()))
x=[-1]*(10**6+5)
x[0]=0
x[1]=1
i=2
while i<=10**6+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**6+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1

z=[0]*(10**6+5)

g=gcd(a[0],a[0])
for i in range(n):
    g=gcd(g,a[i])
if g!=1:
    print("not coprime")
else:
    f=0
    for i in range(n):
        p=1
        while a[i]>=2:
            if p==x[a[i]]:
                a[i]=a[i]//p
                continue
            else:
                p=x[a[i]]
                z[p]+=1
                a[i]=a[i]//p

    for i in range(10**6+1):
        if z[i]>=2:
            f=1
    print("pairwise coprime" if f==0 else "setwise coprime")


Measured memory_bytes: 189172
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

s1=a1*t1+a2*t2
s2=b1*t1+b2*t2
ts=t1+t2
if s1==s2:
    print("infinity")
    exit()
faster=1 if s1>s2 else 2

if (a1>b1 and faster==1) or (a1<b1 and faster==2):
    print(0)
    exit()

if faster==2:
    a1,b1=b1,a1
    a2,b2=b2,a2

d=abs(s1-s2)
cnt=(b1*t1-a1*t1)//d
r=(b1*t1-a1*t1)%d
print(cnt*2+1 if r!=0 else cnt*2)


Measured memory_bytes: 3064
// #include<bits\stdc++.h>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_map>

using namespace std;

#define ll long long
#define MOD 1000000007


void solve(){
    int n;
    string st;
    cin >> n >> st;
    int r = 0;
    for(int i = 0; i < n; i++){
        if(st[i] == 'R') r++;
    }
    int ans = r;
    for(int i = 0; i < r; i++){
        if (st[i] == 'R') ans--;
    }
    cout << ans;
}

int main()
{   
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    {
        solve();
        }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vi v;
	for(int i=0;i<4;i++)
	{
		int x; cin>>x; v.pb(x);
	}
	sort(v.begin(),v.end());
	vi vec={1,4,7,9};
	cout<<(v==vec?"YES\n":"NO\n");
}


Measured memory_bytes: 256
H, W = gets.chomp.split(" ").map(&:to_i)
S = [Array.new(W+2, '.')]
H.times{
  S << gets.chomp.chars.unshift('.').push('.')
}
S << Array.new(W+2, '.')

ans = true
(1..H).each{|i|
  l = S[i]
  (1..W).each{|j|
    if l[j] == '#' then
      (ans = false; break) if S[i-1][j] == '.' && S[i+1][j] == '.' && S[i][j-1] == '.' && S[i][j+1] == '.'
    end
  }
  break if not ans
}

puts ans ? 'Yes' : 'No'


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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

int x,y;

int main()
{
    cin>>x;
    y=0;
    y+=x/500*1000;
    x%=500;
    y+=x/5*5;
    cout<<y;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoderSnippet
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var arr = new int[N];
            for (long x = 1; x <= 100; x++)
            {
                for (long y = 1; y <= 100; y++)
                {
                    for (long z = 1; z <= 100; z++)
                    {
                        long num = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                        if (num <= N) arr[num - 1] += 1;
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
}


Measured memory_bytes: 27788
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := a-b+1
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

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

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
def BubbleSort(A):
    for i in range(len(A)):
        for j in range(len(A)-1,i,-1):  
            
            if A[j][1] < A[j-1][1]:
                # リストの要素の文字列は2次元配列として記憶される
                A[j],A[j-1] = A[j-1],A[j]
    return A

def SelectionSort(A):
    for i in range(len(A)):
        mini = i
        for j in range(i,len(A)):
            if A[j][1] < A[mini][1]:
                mini = j
        A[i],A[mini] = A[mini],A[i]
    return A


N = int(input())
# example for input to array : H4 C9 S4 D2 C3 (from cards)
array = [i for i in input().split()]
array_cp = list(array)

result_bs = BubbleSort(array)
print(*result_bs)
print('Stable') # Bubble sort is stable

result_ss = SelectionSort(array_cp)
print(*result_ss)
if result_ss == result_bs:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

Measured memory_bytes: 256
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

void solve() {
    int n;
    long long int min,max,sum = 0;
    read(n);
    vint vec(n);
    read(min);
    max = min;
    sum += min;
    rep(i,n - 1){
        int tmp;
        read(tmp);
        if(tmp > max){
            max = tmp;
        } else if(tmp < min){
            min = tmp;
        }
        sum += tmp;
    }
    cout << min << " " << max << " " << sum << endl;
}

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


Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll n;
    cin >> n;

    ll ans = 0;
    if (n % 2 == 1)
    {
        ans = 0;
    }
    else
    {
        n /= 2;
        while (n >= 5)
        {
            ans += n / 5;
            n /= 5;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int MAX_N = 100000;
int n;
int64_t a[MAX_N];
int64_t b[MAX_N];
vector<pair<int64_t, int> > c;

int main()
{
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    c.push_back(make_pair(a[i], i));
    c.push_back(make_pair(b[i], i));
  }

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

  bool has_typex = false;
  vector<int64_t> seen(n, 0);
  for (int i = 0; i < n; i++) {
    if (seen[c[i].second] > 0) {
      has_typex = true;
      break;
    }
    seen[c[i].second] = c[i].first;
  }

  int64_t a_sum = accumulate(a, a+n, 0LL);
  int64_t b_sum = accumulate(b, b+n, 0LL);
  int64_t c_sum = 0;
  for (int i = 0; i < n; i++) {
    c_sum += c[i].first;
  }
  if (has_typex) {
    cout << min(c_sum, min(a_sum, b_sum)) << endl;
  } else {
    int64_t min_n = min(a_sum, b_sum);
    for (int w = 0; w < n; w++) {
      min_n = min(min_n, c_sum - seen[w] + (c[n].second != w ? c[n].first : c[n+1].first));
    }
    cout << min_n << endl;
  }

  return 0;
}


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

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

int main(){
  int n;cin>>n;
  int tmp1,tmp2;cin>>tmp1;
  for(int i=1;i<n;i++){
    cin>>tmp2;
    tmp1=gcd(tmp1,tmp2);
  }
  cout <<tmp1<<endl;
}

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

public class Main {

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

	int n;
	boolean[] color;
	int[][] map;
	int INF = 1 << 24;

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		map = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int e = scanner.nextInt();
				map[i][j] = e == -1 ? INF : e;
			}
		}
		System.out.println(prim());
	}

	private int prim() {
		int u;
		int minv;
		int[] d = new int[n];
		int[] p = new int[n];
		color = new boolean[n];
		Arrays.fill(d, INF);
		Arrays.fill(p, -1);
		d[0] = 0;
		while (true) {
			minv = 1 << 24;
			u = -1;
			for (int i = 0; i < n; i++) {
				if (minv > d[i] && !color[i]) {
					u = i;
					minv = d[i];
				}
			}
			if (u == -1)
				break;
			color[u] = true;
			for (int v = 0; v < n; v++) {
				if (!color[v]&& map[u][v] != INF) {
					if (d[v] > map[u][v]) {
						d[v] = map[u][v];
						p[v] = u;
					}
				}

			}

		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (p[i] != -1)
				sum += map[i][p[i]];
		}
		return sum;

	}
}

Measured memory_bytes: 31528
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
#define ull unsigned long long
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;

using namespace std;

int main() {



int a,b,c;
cin >> a >> b >> c;
if(c >= a and c <= b) cout << "Yes";
else cout << "No";


} 

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2 == 0:
                    print('#',end="")
                else:
                    print('.',end='')
            print()
        print()


Measured memory_bytes: 7004
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**5+1)
cnt=0
Q=int(input())
for a in A:
  cnt+=a
  dp[a]+=1
  
for i in range(Q):
  b,c=map(int,input().split())
  a=dp[b]
  cnt+=(c-b)*a
  dp[c]+=a
  dp[b]=0
  print(cnt)

Measured memory_bytes: 84124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll N,Q,a,b;
	cin >> N >> Q;
	vector<ll> v(N+2,-1);
	FOR(i,1,N+1)v[i]=i;
	set<ll> se;
	se.insert(1);
	se.insert(2);
	FOR(i,0,Q){
		cin >> a >> b;
		swap(v[a],v[b]);
		if(v[a]==1){
			se.insert(v[a-1]);
			se.insert(v[a+1]);
		}
		if(v[b]==1){
			se.insert(v[b-1]);
			se.insert(v[b+1]);
		}
		if(v[a-1]==1||v[a+1]==1){
			se.insert(v[a]);
		}
		if(v[b-1]==1||v[b+1]==1){
			se.insert(v[b]);
		}
	}
	ll m = se.count(-1);
	cout << se.size() - m << endl;

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long dp[100001][2];

long long dfs(int s, int c, vector<vector<int>> &adj, vector<int> &visited){
    if(dp[s][c] != -1)return dp[s][c];
    long long ans = 1;
    if(c == 0){
        for(int i = 0 ; i < adj[s].size(); i++){
          //  cout<<adj[s][i]<<"$$"<<endl;
            if(!visited[adj[s][i]]){
                visited[adj[s][i]] = 1;
                ans *= (dfs(adj[s][i], 1, adj, visited)%mod);
                ans = ans % mod;
                visited[adj[s][i]] = 0;
            }
        }

    }
    if( c == 1){
        long long x = 1;
        long long y = 1;
        for(int i = 0 ; i < adj[s].size(); i++){
         //   cout<<adj[s][i]<<"$$"<<endl;
            if(!visited[adj[s][i]]){
                visited[adj[s][i]] = 1;
                x =  (dfs(adj[s][i], 1, adj, visited)%mod);
                x = x % mod;
                
                y = (dfs(adj[s][i], 0, adj, visited)%mod);
                y = y % mod;
       //         cout<<s<<" "<<c<<" x "<<x<<" y "<<y<<endl;
                ans*=((x + y)%mod);
                ans = ans%mod;
                visited[adj[s][i]] = 0;
            }
            
        }
    }
    dp[s][c] = ans;
   // cout<<s<<" "<<c<< " "<<ans<<endl;
    return ans;
}

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    memset(dp, -1, sizeof(dp));
    
    int n;
    cin>>n;
    //nt count[n + 1] = {0};
    vector<vector<int>> adj(n + 1, vector<int>());
    for(int i = 0 ; i < n-1 ; i++){
        int x, y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        //count[y] += 1;
    }
   vector<int> visited(n + 1, 0);
   visited[1] = 1;
    cout<<(1ll*dfs(1, 0, adj, visited) + 1ll*dfs(1, 1, adj, visited))%mod<<endl;

    return 0;
}


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

signed main() {
    int n, h, ans, r;
    cin >> n;
    
    for ( int i = 0; i < n; i++ ) {
        cin >> h;
        if ( i == 0 ) {
            ans = 1;
            r = h;
        } else {
            if ( r <= h ) {
                r = h;
                ans++;
            } 
        }
    }
    
    cout << ans << endl;
    return (0);
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

struct Score {
    int win;
    int lose;
    char id;
    Score(char id, int win, int lose) : id(id), win(win), lose(lose) {}
};
bool operator<(const Score& a, const Score& b){
    return a.win == b.win ? a.lose < b.lose : a.win > b.win;
}

int main()
{
    int n;
    while (n = in()){
        vector<Score> scores;
        rep(i, n){
            char id[8];
            int bucket[3] = {};
            scanf("%s", id);
            rep(j, n - 1) bucket[in()]++;
            scores.push_back(Score(id[0], bucket[0], bucket[1]));
        }
        sort(scores.begin(), scores.end());
        eachv(scores, i) printf("%c\n", scores[i].id);
    }
    return (0);
}

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


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

    ll n,k;
    cin>>n>>k;
    ll ans = 500*n;
    if(ans >= k){
        cout << "Yes" << endl;
    }
    else cout << "No\n";
}


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

int main(void){
    while(1){
        int kami[MAX][MAX]={0};
		int w, h, t, p;
		cin >> w >> h >> t >> p;
        if(!w && !h && !t && !p) break;
        for(int i=0; i<h; i++){
			fill(kami[i], kami[i]+w, 1);
        }
 
        int origin_x = 0, origin_y =0;
        for(int k=0; k<t; k++){
			int d, c;
			cin >> d >> c;
			
			int dist = 1;
            if(d == 1){
				for(int j=origin_x+c; j<origin_x+(2*c); j++){
                     for(int i=origin_y; i<MAX; i++){
                        if(j-dist >= 0)kami[i][j] += kami[i][j-dist];
	                }
		            dist += 2;
			    }
                origin_x += c;
            } else{
                for(int i=origin_y+c; i<origin_y+(2*c); i++){
                    for(int j=origin_x; j<MAX; j++){
                        if(i-dist >= 0)kami[i][j] += kami[i-dist][j];
                    }
                    dist += 2;
                }
                origin_y += c;
            }
        }
         
        for(int k=0; k<p; k++){
			int x, y;
			cin >> x >> y;
			cout << kami[origin_y+y][origin_x+x] << endl;
        }
    }
 
    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s, t;
int q;
int sa[100005], sb[100005], ta[100005], tb[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s >> t >> q;
	int ca = 0, cb = 0;
	for (int i = 1; i <= s.size(); i++) {
		if (s[i-1] == 'A') ca++;
		else cb++;
		sa[i] = ca;
		sb[i] = cb;
	}
	ca = 0;
	cb = 0;
	for (int i = 1; i <= t.size(); i++) {
		if (t[i-1] == 'A') ca++;
		else cb++;
		ta[i] = ca;
		tb[i] = cb;
	}
	vector<string> ans(q);
	FOR(i, q) {
		int sl, sr, tl, tr;
		cin >> sl >> sr >> tl >> tr;
		int cnt0 = (sa[sr] - sa[sl-1]) + 2 * (sb[sr] - sb[sl-1]);
		int cnt1 = (ta[tr] - ta[tl-1]) + 2 * (tb[tr] - tb[tl-1]);
		cnt0 %= 3;
		cnt1 %= 3;
		if (cnt0 == cnt1) ans[i] = "YES";
		else ans[i] = "NO";
	}
	FOR(i, q) cout << ans[i] << endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

string res = "";
void dfs(ll num){
    if(num == 0){
        out(res);
        return;
    }
    num--;
    int num2 = num % 26;
    char c1 = ('a'+ num2);
    res = c1 + res;
    dfs(num/26);
}
signed main()
{   
    gearup;
    //ll MAX = 1000000000000001;
    ll n; cin >> n;
    dfs(n);
}

Measured memory_bytes: 3660
k = int(raw_input())

import collections
q = collections.deque(range(1,10))


h = {u:[u-1,u,u+1] for u in range(1,9)}
h[9] = [8,9]
h[0] = [0,1]

while(k):
	u = q.popleft()
	k -=1
	if k == 0: break
	ld = u % 10
	for delta in h[ld]: q.append(u*10 + delta)
print u

Measured memory_bytes: 38044
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

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

int main() {
	int N;
	int a[Nmax]={};
	cin >> N;
	REP(i,N) cin >> a[i];
	//REP(i,N-1){
		//a[i+1]=lcm(a[i],a[i+1]);
	//}
	ll ans=0;
	REP(i,N) ans+=a[i]-1;
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	ll r,d,x;
	cin>>r>>d>>x;
	REP(i,1,10) {
		x=r*x-d;
		cout<<x<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  if(n==22){cout << "Christmas Eve Eve Eve" << endl; return 0;}
  if(n==23){cout << "Christmas Eve Eve" << endl; return 0;}
  if(n==24){cout << "Christmas Eve" << endl; return 0;}
  if(n==25){cout << "Christmas" << endl; return 0;}

  
  return 0;
}


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

const int N = (int)1e5 + 50, LOGN = 18;

int n, cor[N];
int l;
int jp[LOGN][N];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> cor[i];
    cin >> l;
    for(int i = 0; i < n - 1; i++) {
        jp[0][i] = (int)(upper_bound(cor, cor + n, cor[i] + l) - cor - 1);
    }
    jp[0][n-1] = n;
    for(int i = 1; i < LOGN; i++) {
        for(int j = 0; j < n; j++) {
            int nxt = jp[i-1][j];
            jp[i][j] = nxt == n ? n : jp[i-1][nxt];
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int a, b; cin >> a >> b; a--, b--;
        if(a > b) swap(a, b);
        int cur = a, res = 0;
        for(int i = LOGN - 1; i >= 0; i--) {
            if(jp[i][cur] < b) {
                cur = jp[i][cur];
                res += (1 << i);
            }
        }
        cout << res + 1 << "\n";
    }
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
// const int  MOD = 1e9 + 7;
const int  N = 1e5 + 7;
vector<int> g[N];
ll MOD, dp[N] , dp2[N] , P[N];

void dfs(int v , int p){
    dp[v] = 1;
    P[v] = p;
    for(int i = 0; i < g[v].size(); i++){
        int x = g[v][i];
        if (x!=p) dfs(x,v);
    }
    for(int i = 0; i < g[v].size(); i++){
        int x = g[v][i];
        if (x == p) continue;
        dp[v] *= dp[x] + 1;
        dp[v] %= MOD;
    }
} 

void dfs2(int v , int p){
    dp2[v]++;
    vector<ll> v1,v2;
    vector<int> temp;
    for(int i = 0; i < g[v].size(); i++){
        int x = g[v][i];
        if (x!=p)
            temp.push_back(x);
    }
    ll mul = 1;
    v1.push_back(1);
    for(int i = 0; i < temp.size(); i++){
        int x = temp[i];
        mul *= dp[x]+1;
        mul %= MOD;
        v1.push_back(mul);
    }
    mul = 1;
    v2.push_back(1);
    reverse(temp.begin(),temp.end());
    for(int i = 0; i < temp.size(); i++){
        int x = temp[i];
        mul *= dp[x] + 1;
        mul %= MOD;
        v2.push_back(mul);
    }
    reverse(v2.begin(),v2.end());
    reverse(temp.begin(),temp.end());
    for(int i = 1; i <= temp.size();++i)
    {
        int u = temp[i-1];
        dp2[u] = (((dp2[v]*v1[i-1])%MOD)*v2[i])%MOD;
    }
    for(int i = 0; i < temp.size(); i++){
        int x = temp[i];
        dfs2(x,v);
    }
} 


//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    ll n , x, y;
    cin>>n>>MOD;
    for(int i = 0 ; i < n - 1; i++){
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1 , 0);
    dfs2(1 , 0);

    for(int i = 1 ; i <= n ; i++){
        cout<<(dp[i] * dp2[i]) % MOD<<endl;
    }
    

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll x;cin>>x;
    if(x==1){cout<<1<<" "<<0<<endl;return 0;}
    map<ll,ll>a,b,c;
    for(ll i=1;i<=3000;++i){
        ll cnt=1,z=i;
        while(cnt<5){
            cnt++;
            z*=i;
        }
        a[z]++;
        a[-z]++;
        if(a[z-x]>0){cout<<i<<" "<<b[z-x]<<endl;return 0;}
        b[z]=i;
        b[-z]=-i;
    }
}


Measured memory_bytes: 3644
a, b, c = gets.split.map(&:to_f)
puts 0.5 * a * b * Math.sin(c / 180 * Math::PI)
puts a + b + (Math.sqrt(a ** 2 + b ** 2 - (2 * a * b * Math.cos(c / 180 * Math::PI))))
puts b * Math.sin(c / 180 * Math::PI)


Measured memory_bytes: 8988
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		List<Integer> mList = new ArrayList<Integer>();		
		String ans = "NO";
		int i=0;
		
		while(true){
			int m = (i*a)%b;
			if(m==c){
				ans = "YES";
				break;
			}else if(mList.contains(m)){
				break;				
			}
			mList.add(m);
			i++;
		}
	
		System.out.println(ans);

	}

}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (S == "Rainy") {
		cout << "Sunny" << endl;
	}
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    bool check = false;
    rep(i, 1000) {
        if ((i * a) % b == c) {
            cout << "YES\n";
            return 0;
        }
    }

    cout << "NO\n";

    return 0;
}

Measured memory_bytes: 3508
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;
const int NONE = -1;
int main(void) {
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) cin >> v[i];

	//ある値の出現頻度を格納するmap型変数
	map<int, int> odd_index_value;
	map<int, int> even_index_value;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			even_index_value[v[i]]++;
		}
		else {
			odd_index_value[v[i]]++;
		}
	}


	vector<pair<int, int> > appearance_times_of_odd_index_value;//(出現回数,値)
	for (auto &kv:odd_index_value) {
		appearance_times_of_odd_index_value.push_back(make_pair(kv.second,kv.first));
	}
	sort(RALL(appearance_times_of_odd_index_value));


	vector<pair<int, int> > appearance_times_of_even_index_value;//(出現回数,値)
	for (auto& kv : even_index_value) {
		appearance_times_of_even_index_value.push_back(make_pair(kv.second, kv.first));
	}
	sort(RALL(appearance_times_of_even_index_value));

	//与えられた数値がすべて同じ場合
	if (appearance_times_of_even_index_value[0].second == appearance_times_of_odd_index_value[0].second and even_index_value.size() == 1 and odd_index_value.size() == 1) {
		cout << N / 2 << endl;
	}
	//与えられた数値の偶数indexと奇数indexの最頻値が同じ場合
	else if (appearance_times_of_even_index_value[0].second == appearance_times_of_odd_index_value[0].second) {
		cout << min(N - appearance_times_of_even_index_value[1].first - appearance_times_of_odd_index_value[0].first, N - appearance_times_of_even_index_value[0].first - appearance_times_of_odd_index_value[1].first) << endl;
	}
	//与えられた数値の偶数indexと奇数indexの最頻値が異なる場合
	else {
		cout << N - appearance_times_of_even_index_value[0].first - appearance_times_of_odd_index_value[0].first << endl;
	}

	return 0;
}

Measured memory_bytes: 6520
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string S; cin >> S;
  int N = S.size();
 
  string T1, T2;
  rep(i,N) {
    if(i%2==0) {
      T1 += '0';
      T2 += '1';
    }
    else {
      T1 += '1';
      T2 += '0';
    }
  }
  
  int cnt1 = 0, cnt2 = 0;
  rep(i,N) {
    if(S.at(i)!= T1.at(i)) cnt1++;
    if(S.at(i)!= T2.at(i)) cnt2++;
  }
  
  cout << min(cnt1,cnt2) << endl;
}

Measured memory_bytes: 768
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    xy = [list(map(int,input().split())) for i in range(N)]

    z_max = 0
    z_min = 2 * 10 **9

    w_max = - 10 ** 9
    w_min = 10 ** 9

    for i in range(N):
        z = xy[i][0] + xy[i][1]
        w = xy[i][0] - xy[i][1]
        z_max = max(z_max,z)
        z_min = min(z_min,z)
        w_max = max(w_max,w)
        w_min = min(w_min,w)

    res = max(z_max-z_min,w_max-w_min)

    print(res)



main()


Measured memory_bytes: 63320
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long LL;

const int N = 2e5 + 10;
const LL mod = 1e9 + 7;

struct BIT
{
	int n;
	LL sum[N];
	
	int lowbit(int x) { return x & - x; }
	
	void update(int x, LL d) { for (; x <= n; x += lowbit(x)) (sum[x] += d) %= mod; }
	
	LL inquire(int x)
	{
		LL ans = 0;
		for (; x; x -= lowbit(x)) (ans += sum[x]) %= mod;
		return ans;
	}
	
	LL inquire(int l, int r) { return (inquire(r) - inquire(l - 1) + mod) % mod; }
} T;

int n;
pair <int, int> inter[N];

struct P { int k, b, id; } p[N];

bool compk(P a, P b)
{
	if (a.k != b.k) return a.k < b.k;
	return a.b < b.b;
}
bool compb(P a, P b) { return a.b < b.b; }

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
		scanf("%d %d", &p[i].b, &p[i].k);
	sort(p + 1, p + n + 1, compk);
	for (int i = 1; i <= n; ++ i)
		p[i].id = i;
	sort(p + 1, p + n + 1, compb);
	int _min = n + 1;
	for (int i = n; i >= 0; -- i)
	{
		_min = min(_min, p[i].id);
		inter[p[i].id].first = _min;
	}
	int _max = 0;
	for (int i = 1; i <= n; ++ i)
	{
		_max = max(_max, p[i].id);
		inter[p[i].id].second = _max;
	}
	sort(inter + 1, inter + n + 1);
	T.n = n + 1;
	T.update(1, 1);
	for (int i = 1; i <= n; ++ i)
		T.update(inter[i].second + 1, T.inquire(inter[i].first, inter[i].second + 1));
	printf("%lld\n", T.inquire(n + 1, n + 1));
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define inf INT_MAX
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef  double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
typedef pair<ld , ld> pdd;
typedef vector<pdd> vdd;
typedef vector<ld> vd;
const int MOD = 1e9 + 7; //998244353;

int main(){
    boost;
    int n , a;
    cin >> n >> a;
    cout << (ll) n * a << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> b(N-1);
  for(int i=0;i<N-1;i++){
    cin >> b[i];
  }

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

  cout << b.front() + ans + b.back() << endl;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  while(N != 0){
    int a = N / K, b = N % K;
    cnt++;
    N /= K;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

struct Vec {

    double x, y;

    double size() {
        return sqrt(x * x + y * y);
    }

    double inner_product(Vec v2) {
        return x * v2.x + y * v2.y;
    }

    Vec product(double rate) {
        Vec v2;
        v2.x = x * rate;
        v2.y = y * rate;
        return v2;
    }
};


struct Point {
    double x, y;

    Point plus(Vec vec) {
        Point p;
        p.x = x + vec.x;
        p.y = y + vec.y;
        return p;
    }

    friend istream &operator>>(istream &is, Point &f) {
        cin >> f.x >> f.y;
        return is;
    }

    friend ostream &operator<<(std::ostream &os, Point const &f) {
        printf("%.20f %.20f\n", f.x, f.y);
        return os;
    }
};

struct Line {
    Point start, end;

    Vec to_vec() {
        Vec vec;
        vec.x = end.x - start.x;
        vec.y = end.y - start.y;
        return vec;
    }

    friend istream &operator>>(istream &is, Line &f) {
        cin >> f.start >> f.end;
        return is;
    }

};

int main() {
    Line line;
    cin >> line;
    Vec v_l1 = line.to_vec();

    int q;
    cin >> q;
    rep(i, q) {

        Line line2;
        line2.start = line.start;
        cin >> line2.end;

        Vec v_l2 = line2.to_vec();
        double bunshi = v_l1.inner_product(v_l2);
        double bunbo = v_l1.size() * v_l1.size();
        double rate = bunshi / bunbo;
        Vec ans_vec = v_l1.product(rate);
        Point p = line.start.plus(ans_vec);

        Line perpendicular;
        perpendicular.start = line2.end;
        perpendicular.end = p;

        Vec move_vec = perpendicular.to_vec().product(2);
        Point ans = line2.end.plus(move_vec);
        cout << ans << endl;
    }

}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r;
    cin>>r;
    int x = r*r;
    x = 3*x;
    cout<<x<<endl;
    return 0;
    
}



Measured memory_bytes: 256