akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b;
  scanf("%d %d", &a, &b); 
  int ans = a * b - a - b + 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<iomanip>
#define PI 3.141592653589793
using namespace std;
int main(void){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double hour_arg,min_arg;
    hour_arg = (double)30 * (h + (double)m / 60);
    min_arg = (double)m * 6;
    double hour_pos[2], min_pos[2];
    hour_pos[0] = (double)a * cos((double)hour_arg*PI/180);
    hour_pos[1] = (double)a * sin((double)hour_arg*PI/180);
    min_pos[0] = (double)b * cos((double)min_arg*PI/180);
    min_pos[1] = (double)b * sin((double)min_arg*PI/180);
    cout<<fixed<<setprecision(9)<<sqrt(pow(hour_pos[0]-min_pos[0],2)+pow(hour_pos[1]-min_pos[1],2))<<endl;
    return 0;
}

Measured memory_bytes: 3700
n=int(input())
a=[]
for i in range(n):
  s=input()
  if "." in s:
    s+="0"*(9-(len(s)-s.find(".")-1))
    s=s.replace(".","")
  else:s+="0"*9
  s=int(s)
  a.append(int(s))
n=len(a)
tf=[[0]*19 for _ in range(19)]
for x in a:
  two=0
  five=0
  while x%2==0:
    x//=2
    two+=1
  while x%5==0:
    x//=5
    five+=1
  two=min(two,18)
  five=min(five,18)
  tf[two][five]+=1
ans=0
for t1 in range(19):
  for f1 in range(19):
    for t2 in range(19):
      for f2 in range(19):
        if t1+t2<18 or f1+f2<18:continue
        if t1==t2 and f1==f2:
          ans+=tf[t1][f1]*(tf[t1][f1]-1)
        else:
          ans+=tf[t1][f1]*tf[t2][f2]
print(ans//2)

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


int main() {
    int r; cin>>r;
    const double PI = acos(-1);
    cout<<2*PI*r<<endl;
}

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

template<typename T>
void chmax(T& a, T b){
    a = max(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int64_t money = 1000;
    pair<int64_t, int64_t> kabu;
    for(int a : A){
        chmax(money, kabu.first*a + kabu.second);
        chmax(kabu, {money/a, money%a});
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3592
import math
while True:
    n=int(input())
    if n==0:
        break
    l=[]
    for i in range(n):
        l.append(int(input()))
    slist=sorted(l)
    del slist[0]
    del slist[n-2]
    x=sum(slist)/len(slist)
    print(math.floor(x))
    





Measured memory_bytes: 5664
using System;
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var student = ToInt32(input[0]);
        var checkPoint = ToInt32(input[1]);
        var students = new int[student][];
        var checkPoints = new int[checkPoint][];
        for (var i = 0; i < student + checkPoint; i++)
        {
            if (i < student) students[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            else checkPoints[i - student] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        }

        for(var i = 0; i < student; i++)
        {
            var length = GetLength(i, 0,students,checkPoints);
            var point = 1;
            for(var j = 1; j < checkPoint; j++)
            {
                if (length > GetLength(i, j,students,checkPoints)) { length = GetLength(i, j,students,checkPoints);point = j + 1; }
            }
            WriteLine(point);
        }
        
    }

    private static int GetLength(int i,int j,int[][] students,int[][] checkPoints)
    {
        return Math.Abs(students[i][0] - checkPoints[j][0]) + Math.Abs(students[i][1] - checkPoints[j][1]);
    }
}



Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N,L;
  cin>>N>>L;
  int ans=0;
  int temp=9999;
  int bufi=0;
  REP(i,N){
    ans+=i+L;
    if(max(-(i+L),(i+L))<temp){
      temp=max(-(i+L),(i+L));
      bufi=i;
    }
  }
  ans-=bufi+L;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
n = I()
A,B = [],[]
for i in range(n):
    a,b = neo()
    A += [a+b]
    B += [a-b]
A.sort()
B.sort()
Ans = max(A[-1]-A[0],B[-1]-B[0])
print(Ans)


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

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int x = vec.at(0);
  int ans;
  for (int i=1; i<N; i++){
    ans = gcd(x,vec.at(i));
    x = ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream> 

  

using namespace std; 

  

int main() 

{ 

  int a,b,x,y;   


  cin >> a >> b; 

   

  x=a*b; 

  y=a*2+b*2; 

   

   cout << x << " " << y <<endl ; 

   

    

   return 0; 

} 


Measured memory_bytes: 3080
#include<stdio.h>
int main(void) {
  int a[3], c, i, j;
  for(i = 0; i < 3; i++) {
    scanf("%d",&a[i]);
  }
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3-i-1; j++) {
      if(a[j] >= a[j+1]) {
        c = a[j];
        a[j] = a[j+1];
        a[j+1] = c;
      }
    }
  }
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}


Measured memory_bytes: 2120
import numpy as np
n,m,k = map(int,input().split())
a = np.array([int(i) for i in input().split()], dtype='int64')
b = np.array([int(i) for i in input().split()], dtype='int64')

# 読まないという選択肢を先頭に入れておく
a_c = np.zeros(n+1,dtype='int64')
a_c[1:] = np.cumsum(a)

b_c = np.zeros(m+1,dtype='int64')
b_c[1:] = np.cumsum(b)

a_c = a_c[a_c <= k]
b_c = b_c[b_c <= k]

ans_l = np.searchsorted(b_c, k - a_c, side='right') - 1
ans_l += np.arange(len(a_c))
print(ans_l.max())

Measured memory_bytes: 53460
import collections

n = int(input())

f = [1] * (n + 1)
for i in range(2, n + 1):
    if f[i] != 1: continue
    m = i
    while m <= n:
        tmp = m
        cnt = 0
        while tmp % i == 0:
            tmp = tmp // i
            cnt += 1
        f[m] *= cnt + 1
        m += i

ans = 0
for i in range(1, n + 1):
    ans += i * f[i]
print(ans)

Measured memory_bytes: 151976
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.size() < 26)
    {
        for(char i = 'a';i < 'z';i++)
        {
            if(s.find(i) == string::npos)
            {
                cout << s << i << "\n";
                break;
            }
        }
    }
    else
    {
        string t = s;
        if(s == "zyxwvutsrqponmlkjihgfedcba")
        {
            cout << "-1\n";
        }
        else
        {
            next_permutation(t.begin(),t.end());
            int i = 0;
            while(s[i] == t[i])
            {
                cout << t[i];
                i++;
            }
            cout << t[i] << "\n";
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
    int data[10][10];
    int n;

    while (cin >> n, n) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> data[i][j];
            }
        }
        int ans;
        for (int i = 0; i < n; i++) {
            ans = 0;
            for (int j = 0; j < n; j++) {
                printf("%5d", data[i][j]);
                ans += data[i][j];
            }
            printf("%5d\n", ans);
        }
        int s = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                sum += data[j][i];
            }
            printf("%5d", sum);
            s += sum;
        }
        printf("%5d\n", s);
    }
    return 0;
}

Measured memory_bytes: 3092
<?php
const MAX = 10;
const ANS =  3;

$mt = array();
for($i = 0; $i < MAX; $i++) {
    $mt[] = trim(fgets(STDIN));
}

rsort($mt);
for($i = 0; $i < ANS; $i++) {
    echo $mt[$i], PHP_EOL;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

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

	ll n = min(a,k);

	ll ans =0; ans+=n;

	k =  max(0LL, k-n);

	n = min(b,k);

	k  = max(0LL , k-n);

	n = min(c,k);

	writeln(ans-n);

}


Measured memory_bytes: 3648
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], cnt[N], ans;
bool used[N];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], cnt[a[i]] ++;
   for (int i = 1; i <= 1000000; i ++) {
      if (cnt[i]) {
         if (cnt[i] > 1) used[i] = 1;
         for (int j = i + i; j <= 1000000; j += i)
            used[j] = 1;
      }
   }
   for (int i = 1; i <= n; i ++) ans += !used[a[i]];
   cout << ans; 
}               
 
signed main () {                                       
  // #ifdef QWERTY
  //    freopen("input", "r", stdin);
  // #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 9308
N=int(input())
s = [input() for _ in range(N)]
M=int(input())
t = [input() for _ in range(M)]

l = list(set(s)) 

cnt=0
for k in range(len(l)):
    cnt = max(cnt, s.count(l[k]) - t.count(l[k]))

print(cnt)

Measured memory_bytes: 3064
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second

const int MAX_LIMIT = 5003;
const int charSetSize = 2;

ll dp[MAX_LIMIT][MAX_LIMIT];
int moves, target;
string str1;

ll myPow(ll base, ll expo)
{
	long long r=1;
    while(expo){
        if(expo&1){
            r=(r*base)%MOD;
        }
        base=(base*base)%MOD;
        expo>>=1;
    }
    return r % MOD;
}

ll rec(int move, int ind)
{
	if(move == moves)
	{
		return ind == target;
	}

	ll &ret = dp[move][ind];
	if(ret != -1)
		return ret;
	ret = 0;

	ret += rec(move + 1, max(ind - 1, 0));
	ret += charSetSize * rec(move + 1, ind + 1);
	return ret %= MOD;
}

int main()
{
	int i, j;

	int cases = 1;
	// si(cases);

	// assert(cases >= 1 && cases <= 5);

	wl(cases)
	{
		mem(dp, -1);

		si(moves);
		// assert(moves >= 1 && moves <= 2000);

		cin>>str1;

		target = str1.SZ();
		// assert(target >= 1 && target <= 2000);

		ll ans = rec(0,0);

		ll co = 1LL;

		ll invMod = myPow(charSetSize, MOD - 2);

		fl(i,0,target)
		{
			co = co * (invMod);
			co %= MOD;
		}

		ans *= co;
		cout<<ans%MOD;
		nline;
	}


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 195968
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrB = list(map(int,input().split()))

arrA = [0 for _ in range(n)]

for i in range(len(arrB)):
    if i == 0:
        arrA[i] = arrB[i]
        arrA[i+1] = arrB[i]
    else:
        if arrB[i] <= arrA[i]:
            arrA[i] = arrB[i]
            arrA[i+1] = arrB[i]
        else:
            arrA[i+1] = arrB[i]

ans = sum(arrA)
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
    while(true){
        int x, y;
        cin >> x >> y;
        int cnt = 0;
        if(x == 0 and y == 0) break;

        for(int i = 1; i <= x; i++)
        {
            for(int j = i + 1; j <= x; j++)
            {
                for(int k = j + 1; k <= x; k++)
                {
                    if(i + j + k == y) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    


    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,now,sum,tot,e[500010],hd[500010],nt[500010],f[500010],a[500010],b[500010];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void get(int x,int fa,int zuida){
	int i;
	if(x>zuida)return;
	sum++;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		get(e[i],x,zuida);
	}
}
void dfs(int x,int fa,int zuida,int daan){
	int i;
	if(x==1){
		for(i=hd[x];i;i=nt[i])dfs(e[i],x,zuida,daan);
		return;
	}
	if(x>zuida){
		now=0;
		if(zuida>0){
			for(i=hd[x];i;i=nt[i])if(e[i]!=fa){
				sum=0;
				get(e[i],x,zuida);
				a[e[i]]=-sum;
				now+=sum;
			}
			b[x]=daan+now+1;
		}
		 else b[x]=1;
		for(i=hd[x];i;i=nt[i])if(e[i]!=fa){
			sum=0;
			get(e[i],x,x);
			a[e[i]]+=sum;
		}
		if(x==6){
			for(i=hd[x];i;i=nt[i]){
				if(e[i]==fa)continue;
				//printf("%d %d\n",e[i],a[e[i]]);
			}
		}
		for(i=hd[x];i;i=nt[i])if(e[i]!=fa)dfs(e[i],x,x,b[x]+a[e[i]]);
	}
	 else{
	 	b[x]=daan;
	 	for(i=hd[x];i;i=nt[i]){
	 		if(e[i]==fa)continue;
	 		dfs(e[i],x,zuida,daan);
		 }
	 }
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
	}
	dfs(1,0,0,0);
	for(i=2;i<=n;i++)printf("%d ",b[i]);
}

Measured memory_bytes: 27176
while True:
    a,op,b=input().split()
    a,b=int(a),int(b)
    if op=='?':
        exit()
    if op=='+':
        print(a+b)
    if op=='-':
        print(a-b)
    if op=='*':
        print(a*b)
    if op=='/':
        print(a//b)

    


Measured memory_bytes: 5600
from fractions import gcd as m_gcd

n = int(input())
a = list(map(int, input().split()))


def gcd(a, b):
    if a == 0 or b == 0:
        return max(a, b)
    return m_gcd(a, b)


l = [0] * (n + 2)
r = [0] * (n + 2)
ans = [0] * n

for i in range(1, n+1):
    l[i] = gcd(l[i - 1], a[i - 1])
    r[n - i + 1] = gcd(r[n - i + 2], a[n - i])

for i in range(1, n + 1):
    ans[i-1] = gcd(l[i-1], r[i+1])

print(max(ans))


Measured memory_bytes: 16140
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize,
        y: usize,
    }
    let mut money = 0;
    money += match x {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };
    money += match y {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };
    if (x ==1 ) & (y == 1) {
        money += 400000;
    }
    println!("{}", money);
}


Measured memory_bytes: 4476
n = int(input())
for i in range(1,n+1):
    x = i
    if x%3 == 0:
        print(" ",i,sep="",end="")
        continue
    while x != 0:
	    if x%10 == 3:
	        print(" ",i,sep="",end="")
	        break
	    x //= 10

print("")

Measured memory_bytes: 8112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define lSOne(x)(x&-x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 100 + 9;

ll x; string s;

int main(){
    FASTIO //ONLINE__JUDGE();

    cin >> x >> s;
    if ( x >= 3200 ) cout << s;
    else cout << "red";
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    ll A; string B;
    cin >> A >> B;
    string m = "...";
    m[0] = B[0];
    m[1] = B[2];
    m[2] = B[3];
    ll v = stoi(m);
    ll C = A*v;
    C -= C%100;
    C /= 100;
    prt(C);
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n,m; cin>>n>>m;
  VI p(m); vector<string> s(m);
  rep(i,m) cin>>p[i]>>s[i];
  vector<int> f(n,0);
  int c = 0, w = 0;
  rep(i,m){
    int pr = p[i]-1;
    if(s[i]=="WA"){
      if(f[pr]!=-1) f[pr]++;
    }else{
      if(f[pr]==-1) continue;
      w += f[pr]; c++;
      f[pr] = -1;
    }
  }
  cout << c SP w << endl;




  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

long long modPow(ll x, long long a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % mod;
    long long t = modPow(x, a / 2);
    return (t * t) % mod;
}

ll solve(ll n){
    cin.tie(0); ios::sync_with_stdio(false);
    ll ans = modPow(10, n) - (2 * modPow(9, n)) % mod + modPow(8, n);
    return (ans + mod) % mod;
}

int main() { 
    ll n;
    cin >> n;
    cout << solve(n) << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=1e5+5;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int a,b;cin>>a>>b;
	int c=a+b>>1;
	if(abs(c-a)!=abs(b-c))
		cout<<"IMPOSSIBLE"<<endl;
	else cout<<c<<endl;		
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp;
    writeln(to!char(N[0] + 1));
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

char S[200010];
int N,A,B;

int calc_pow(int x, int pow,int m) {
    if (pow == 0) return 1;
    int a = calc_pow(x, pow / 2,m);
    a = a * a % m;
    if (pow % 2 == 1) a *= x;
    return a % m;
}

int calc_div(int a,int b,int m) {
    return a * calc_pow(b, m - 2,m) % m;
}

signed main(){
    scanf("%lld %lld %lld",&N,&A,&B);
    int ans=0;
    ans+=(calc_pow(2,N,mod)-1)%mod;
    int X=1,Y=1;
    for(int i=1;i<=A;i++){
        X*=i;X%=mod;
        Y*=(N-i+1);Y%=mod;
    }
    ans-=calc_div(Y,X,mod);
    ans=(ans+mod)%mod;
    X=1,Y=1;
    for(int i=1;i<=B;i++){
        X*=i;X%=mod;
        Y*=(N-i+1);Y%=mod;
    }
    ans-=calc_div(Y,X,mod);
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
    return 0;
}


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

    if (n == 1)
        cout << "Yes";
    else
    {
        for (int i = 2; i <= 9; i++)
        {
            int m = n % i;
            if (m == 0 && (n / i) < 10)
                k = 1;
        }
        if (k == 1)
        {
            cout << "Yes" << endl;
        }
        else
            cout << "No";
    }
}

Measured memory_bytes: 256
/*****************************************************/
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define   offcin        ios::sync_with_stdio(false)
#define   DEBUG         freopen("#.txt", "r", stdin)
#define   sigma_size    26
#define   lson          l,m,v<<1
#define   rson          m+1,r,v<<1|1
#define   slch          v<<1
#define   srch          v<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   lowbit(x)     (x&-x)

const int    INF    = 0x3f3f3f3f;
const ll     INFF   = 1e18;
const double pi     = acos(-1.0);
const double inf    = 1e18;
const double eps    = 1e-9;
const ll     mod    = 1e9+7;
const int    maxmat = 10;
const ull    BASE   = 133333331;

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
inline ll bits(ll x) {
      return !x ? x : bits(x - lowbit(x)) + 1;
}
/*****************************************************/

const int maxn = 1e6 + 5;
const char a[] = {'A', 'B'};

char s[maxn];

int main(int argc, char const *argv[]) {
    int N, K;
    cin>>N>>K;
    scanf("%s", s);

    int front = 0, last = N;
    bool flag = false;
    if (K <= 2 * N) {
        for (int i = 0; i < K; i ++) {
            if (s[front] == a[flag]) s[front] = a[flag ^ 1];
            else {
                front ++;
                flag ^= 1;
                s[last ++] = a[flag];
                s[last] = 0;
            }
        }
    }
    else {
        K -= 2 * N;
        K %= 2;
        for (int i = 0; i < 2 * N; i ++) {
            if (s[front] == a[flag]) s[front] = a[flag ^ 1];
            else {
                front ++;
                flag ^= 1;
                s[last ++] = a[flag];
                s[last] = 0;
            }
        }
        if (K) {
            if (s[front] == a[flag]) s[front] = a[flag ^ 1];
            else {
                front ++;
                flag ^= 1;
                s[last ++] = a[flag];
                s[last] = 0;
            }
        }
    }

    if (flag) {
        for (int i = front; i < last; i ++)
            s[i] = s[i] == 'A' ? 'B' : 'A';
    }

    printf("%s\n", s + front);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += (a[i] + ans) % b[i] == 0 ? 0 : b[i] - (a[i] + ans) % b[i];
  }
  cout << ans << endl;
}



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

using namespace std;


int main() {
    int n,x; cin>>n;
    vector<int> cost;
    vector<int> h;
    for(int i=0; i<n; i++){
        cin>>x;
        h.push_back(x);
    }
    cost.push_back(0);
    cost.push_back(abs(h[1] - h[0]));
    for(int i= 2 ; i<n; i++){
        x = abs(h[i] - h[i-1]) + cost[i-1] < abs(h[i] - h[i -2]) + cost[i-2] ? abs(h[i] - h[i-1]) + cost[i-1] : abs(h[i] - h[i -2]) + cost[i-2] ;
        cost.push_back(x);
    }
    cout<<cost[n-1];
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void){

	int N;
	int a[100000];

	scanf("%d", &N);

	int i;
	
	for(i = 1; i <= N; i++){
		scanf("%d", &a[i]);
	}

	int X = 1;
	int count = 0;

	while(X != 2){				
		count++;
		X = a[X];

		if(count == 10 * N){
			break;
	
		}
		
	}

    if(count == 10 * N) count = -1;
	printf("%d\n", count);

	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  string s;
  cin>>s;
  int n = s.length();
  vi ans(n,0);
  // Rについて見る
  int cnt=0;
  rep(i,n){
    if(s[i]=='R')cnt++;
    else {
      ans[i]+=(cnt)/2;
      ans[i-1]+=(cnt+1)/2;
      cnt=0;
    }
  }
  cnt=0;
  for(int i = n-1;i>=0;i--){
    if(s[i]=='L')cnt++;
    else {
      ans[i]+=(cnt)/2;
      ans[i+1]+=(cnt+1)/2;
      cnt=0;
    }
  }
  rep(i,n-1){
    cout<<ans[i]<<' ';
  }
  cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 1024
#define MOD 1000000007

#include <iostream>
#include <vector>
using namespace std;

long pow(long a, long b) {
	if (!b) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<long> a(N + 1, 1), b(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		a[i] = a[i - 1] * i % MOD;
		b[i] = pow(a[i], MOD - 2);
	}
	for (int i = 1; i <= K; i++) {
		if (N - K + 1 < i) cout << 0;
		else {
			long c = a[N - K + 1] * b[N - K - i + 1] % MOD * b[i] % MOD;
			long d = a[K - 1] * b[K - i] % MOD * b[i - 1] % MOD;
			cout << c * d % MOD;
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val w = readLine()!!.split(' ').map(String::toInt)
    val sum = w.sum()
    var s = 0
    for (i in 0 until n) {
        val newS = s + w[i]
        if (Math.abs(sum - 2 * newS) < Math.abs(sum - 2 * s)) {
            s = newS
        } else {
            break
        }
    }
    println(Math.abs((sum - 2 * s)))
}


Measured memory_bytes: 40352
n = int(input())
xy = []
diff = []
for _ in range(n):
  tmp = list(map(int,input().split()))
  xy.append(tmp)
for i in range(n):
  for j in range(n):
    if j != i:
      tmpd = [ xy[j][0] - xy[i][0] , xy[j][1] - xy[i][1] ]
      flag = 0
      for mxy in diff:
        if mxy[1:] == tmpd:
            flag = 1
            mxy[0] += 1
            break
      if flag == 0:
        diff.append([0]+tmpd)
diff.sort()
diff.reverse()
if n == 1:
  print(1)
else:
  print(n-diff[0][0]-1)

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A.at(i);

    int count = 1;
    int d = 0;
    for (int i=1; i<N; i++) {
        if (d >= 0 && A.at(i) > A.at(i-1)) d = 1;
        else if (d <= 0 && A.at(i) < A.at(i-1)) d = -1;
        else if (A.at(i) != A.at(i-1)) {
            d = 0;
            count++;
        }

    }
    cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k, c;std::cin >> n >> k >> c;
  string s;std::cin >> s;

  ll now = 1;
  vll LEFT(n+2, -1), RIGHT(n+2, -1);
  for(int i=0;i<n;i++){
    if(s[i]=='x') continue;
    if(now==1||i - LEFT[now-1]>c){
      LEFT[now] = i;
      now++;
    }
  }
  now = 1;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='x') continue;
    if(now==1||RIGHT[now-1] - i>c){
      RIGHT[now] = i;
      now++;
    }
  }
  if(LEFT[k+1]!=-1){
    std::cout << '\n';
    return 0;
  }
  vll ans;
  for(int i=1;i<=k;i++){
    ll l = LEFT[i];
    ll r = RIGHT[k+1-i];
    if(l==r) ans.push_back(l);
  }
  re(i, ans.size()) std::cout << ans[i] + 1 << '\n';
  return 0;
}


Measured memory_bytes: 6640
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

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

using namespace std;
string s;
int s1, s2, s3, s4;

int main() 
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    char a = s[0];
    if (a == 'A') ++s1;
    else if (a == 'T') ++s2;
    else if (a == 'R') ++s3;
    else ++s4;
  }
  cout << "AC x " << s1 << '\n';
  cout << "WA x " << s4 << '\n';
  cout << "TLE x " << s2 << '\n';
  cout << "RE x " << s3 << '\n';
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  private static int[][] DIRS = new int[][]{ {+1, 0}, {0, +1}};
  private static long MOD = (long)1e9 + 7;

  private static long update(long a, long b) {
    long sum = a + b;
    if (sum >= MOD) {
      sum -= MOD;
    }
    return sum;
  }

  private static boolean isValidMove(char[][] grid, int nx, int ny) {
    if (nx < 0 || nx >= grid.length || ny < 0 || ny >= grid[0].length || grid[nx][ny] == '#') {
      return false;
    }
    return true;
  }

  public static void solve() {
    int h = scanner.nextInt();
    int w = scanner.nextInt();
    char[][] grid = new char[h][w];
    for (int i = 0; i < h; i++) {
      grid[i] = scanner.next().toCharArray();
    }
    long[][] ways = new long[h][w];
    ways[0][0] = 1L;
    for (int i = 1; i < h; i++) {
      if (grid[i][0] != '#') {
        ways[i][0] = update(ways[i][0], ways[i - 1][0]);
      }
    }
    for (int i = 1; i < w; i++) {
      if (grid[0][i] != '#') {
        ways[0][i] = update(ways[0][i], ways[0][i - 1]);
      }
    }
    for (int i = 1; i < h; i++) {
      for (int j = 1; j < w; j++) {
        if (grid[i][j] == '#') {
          continue;
        }
        ways[i][j] = update(ways[i][j], ways[i - 1][j]);
        ways[i][j] = update(ways[i][j], ways[i][j - 1]);
      }
    }
    printer.println(ways[h - 1][w - 1]);
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 40536
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h, w = map(int, input().split())
c = [ list(map(int, input().split())) for _ in range(10) ]

num_cnt = [0]*10
for _ in range(h):
    al = list(map(int, input().split()))
    for a in al:
        if a >= 0: num_cnt[a] += 1

warshall_floyd(c,10)

ans = 0
for num, cnt in enumerate(num_cnt):
    ans += c[num][1] * cnt

print(ans)

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

using namespace std;

bool check(vector<string> &va, vector<string> &vb, int offset_x, int offset_y) {
  int n = va.size(), m = vb.size();
  bool res = true;
  for (int y = 0; y < m; y++) {
    for (int x = 0; x < m; x++) {
      if (vb[y][x] != va[offset_y + y][offset_x + x]) {
        res = false;
        break;
      }
    }
  }

  return res;
}

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<string> va(n), vb(m);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    va[i] = s;
  }

  for (int i = 0; i < m; i++) {
    cin >> s;
    vb[i] = s;
  }

  bool ans = false;
  for (int y = 0; y < n - m + 1; y++) {
    for (int x = 0; x < n - m + 1; x++) {
      bool is_matched = check(va, vb, x, y);
      if (is_matched) {
        ans = true;
        break;
      }
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);

using namespace std;


int main()

{
    ll n , b , c , q , x;
    cin>>n;
    map<ll,ll> mp;
    ll sum = 0;
    for(ll i = 0 ; i < n ; i++)
    {
        cin>>x;
        mp[x]++;
        sum+=x;
    }
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        sum=sum-mp[b]*b+mp[b]*c;
        mp[c]+=mp[b];
        mp[b]=0;
        
        cout<<sum<<endl;

    }
}

Measured memory_bytes: 9300
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
using namespace std;
signed main() {
  int n;cin >> n;
  vector<int> a, b;
  a.reserve(n);
  b.reserve(n);
  for (int i = 0; i < n; ++i) { int t; cin >> t; a.push_back(t); }
  for (int i = 0; i < n; ++i) { int t; cin >> t; b.push_back(t); }
  int ans = 0;
  for (int i = 0; i < n; ++i)for (int j = 0; j < n; ++j) {
    ans ^= (a[i] + b[j]);
  }cout << ans << endl;
}

Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int bb=b;
  while(bb!=0){
  bb/=10;
  a*=10;  
  }
  int d;
  string ans="No";
  d=a+b;
  for(int i=0;i<d;i++){
    if(i*i==d){
      ans="Yes";
    }
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    ed = [[] for i in range(n)]
    edg = defaultdict(int)
    ans = [None] * (n - 1)
    for i in range(n - 1):
        a, b = LI_()
        ed[a].append((b, i))
        ed[b].append((a, i))
        edg[a] += 1
        edg[b] += 1
    ma = max(edg.values())
    print(ma)
    for num, a in enumerate(ed):
        if len(a) == ma:
            break
    q = deque([num])
    while q:
        a = q.pop()
        o = 1
        li = defaultdict(int)
        for b, i in ed[a]:
            if ans[i] != None:
                li[ans[i]] = 1
        for b, i in ed[a]:
            if ans[i] == None:
                q.appendleft(b)
                while li[o]:
                    o += 1
                ans[i] = o
                o += 1
    for i in ans:
        print(i)
    return


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


Measured memory_bytes: 90656