akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  vi64 sums(n + 1), psums(n + 1);
  rep(i, n) sums[i + 1] = sums[i] + a[i];
  rep(i, n) psums[i + 1] = psums[i] + max(a[i], 0);
  i64 ans = 0;
  rep(i, n - k + 1) {
    i64 sum = psums[i] + psums[n] - psums[i + k];
    amax(ans, sum);
    amax(ans, sum + sums[i + k] - sums[i]);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 2176
n=gets.to_i
a=gets.split.map(&:to_i)
b=0
c=0
s=0
n.times do |i|
  s+=a[i]
  if i.even?
    if s+b<=0
      d=1-(s+b)
      c+=d
      b+=d
    end
  else
    if s+b>=0
      d=s+b+1
      c+=d
      b-=d
    end
  end
end
cc=c
b=0
c=0
s=0
n.times do |i|
  s+=a[i]
  if i.odd?
    if s+b<=0
      d=1-(s+b)
      c+=d
      b+=d
    end
  else
    if s+b>=0
      d=s+b+1
      c+=d
      b-=d
    end
  end
end
puts [c,cc].min


Measured memory_bytes: 20740
import re
N = int(input())
S = [input() for i in range(N)]
nAB = sum(map(lambda x: x.count('AB'), S))
lastB = sum(map(lambda x: x[0] == 'B', S))
firstA = sum(map(lambda x: x[-1] == 'A', S))
matchAB = sum(map(lambda x: x[0] == 'B' and x[-1] == 'A', S))
if min(lastB, firstA) == 0:
    print(nAB)
elif lastB == firstA and matchAB - min(lastB, firstA) == 0:
    print(nAB+min(lastB, firstA)-1)
elif matchAB - min(lastB, firstA) == 0:
    print(nAB+min(lastB, firstA))
else:
    print(nAB+min(lastB, firstA))


Measured memory_bytes: 3956
import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = map(int, input().split())

h = list(map(int, input().split()))
route = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    route[a - 1].append(b - 1)
    route[b - 1].append(a - 1)
ans = 0
now = 0
for r in route:
    if len(r) == 0:
        ans += 1
    else:
        height = h[now]
        safe = True
        for rr in r:
            if height <= h[rr]:
                safe = False
                break
        if safe:
            ans += 1
    now += 1
print(ans)


Measured memory_bytes: 29536
#include <iostream>
#include <algorithm>
#include <vector>

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;

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

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

	int minEl = arr[0];

	int ans = minEl;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] % minEl != 0)
		{
			int gcd = GCD(arr[i], minEl);
			ans = min(ans, gcd);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans=0;
int main(int argc, char* argv[]){
	long long int a, b = 1, c = 1;
	scanf("%lld %lld %lld",&a,&b,&c);
	printf("%lld %lld %lld\n",c,a,b);
}


Measured memory_bytes: 128
N = gets.to_i

def draw(n, b)
  a = 0
  while n > 0
    a += n%b
    n /= b
  end
  a
end

res = 1e20
(0 .. N).each{|n| x = draw(n, 6) + draw(N - n, 9); res = x if x < res}
puts res

Measured memory_bytes: 1788
n=int(input());p=print;b=1<<(n.bit_length()-1)
if n==b:p("No");exit()
p("Yes");p(n+1,n+2)
for i in range(3,n+1,2):p(1,i);p(1,i-1);p(i,n+i-1);p(i-1,n+i)
if~n&1:p(b,n);p(n^1^b,n+n)

Measured memory_bytes: 5436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int p = sc.nextInt();
		char[] input = sc.next().toCharArray();

		int[] pCount = new int[10001];

		long tmp = 0;
		int times = 1;
		long result = 0;

		if(p == 2 || p == 5){
			for(int j = n - 1; j >= 0; j--){
				if((input[j] - '0') %p == 0){
					result += j + 1;
				}
			}
		}
		else {
			for(int j = n - 1; j >= 0; j--){
				tmp += (input[j] - '0') * times;

				//			System.out.println(tmp);

				int mod = (int)(tmp % p);
				//			System.out.println("% "+p+" = "+mod);

				result += pCount[mod];

				if(mod == 0){
					result++;
				}

				//			System.out.println("add "+pCount[mod]);

				pCount[mod]++;

				times *= 10;
				times %= p;
				//			System.out.println("count "+count);
			}
		}


		System.out.println(result);
	}
}


Measured memory_bytes: 27988
// Problem : B - Two Anagrams
// Contest : AtCoder - AtCoder Beginner Contest 082
// URL : https://atcoder.jp/contests/abc082/tasks/abc082_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	string s,t;cin>>s>>t;
	sort(all(s));
	sort(all(t),greater<char>());
	if(s<t)
	cout<<"Yes\n";
	else
	cout<<"No";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3600
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc =  np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
  cc += c
  av = s[d] - sum( cc ) + cc
  av2 = av + cc*min((D-d-1),13)
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      cc[t] = 0
      v += av[t]
      print(t+1)
      break
#
#print( v )


Measured memory_bytes: 27376
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)

var N, M int

func main() {
	sc.Split(bufio.ScanWords)
	N, M = nextInt(), nextInt()

	if N == M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
from itertools import accumulate

def solve(N: int, K: int, p: "List[int]"):
    accum_p = [0] + list(accumulate(p))
    max_index = 0
    max_value = 0

    for i in range(N-K+1):
        cur = accum_p[i+K]-accum_p[i]

        if cur > max_value:
            max_index = i
            max_value = cur
    

    ep = []
    for i in range(max_index,max_index+K):
        ep.append((1+p[i])/2)
    print(sum(ep))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38776
// 2017/12/10


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) throws Exception {
        String str = br.readLine();
        int count = 0;
        for(int i=0; i<str.length();i++){
            if(str.charAt(i) == '1') count++;
        }
        System.out.println(count);

    }
}

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

vec<int> pos[Sz];

void solve (vec <int> &p) {
  int mx = -1;
  int j = -1;
  for (int i = 0; i < sz(p); i++) {
    int val = p[i] - 2*i;
    if (val-1 < mx) {
      cout << p[j] << ' ' << p[i];
      exit (0);
    }
    if (mx < val) {
      mx = val;    
      j = i;
    }
  }
}      
                   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();             
  char s[Sz];
  cin >> s + 1;
  for (int i = 1; s[i]; i++) {
    pos[s[i]].pb (i);
  }       
  for (int i = 'a'; i <= 'z'; i++)
    solve (pos[i]);
           
  cout << "-1 -1";


  return 0;
}






// Coded by Z..



Measured memory_bytes: 27136
#include<cstdio>
#include<cstring>
using namespace std;
int a,b,a1,b1;
bool ok;
char s[55],ss[55];
int main(){
	scanf("%s%s",&s,&ss);
	a=strlen(s);b=strlen(ss);
	for(int i=0;i<a+b;++i){
		if(ok && b1<b){
			printf("%c",ss[b1]);
			b1++;
			ok=0;
		}
		else if(a1<a){
			printf("%c",s[a1]);
			a1++;
			ok=1;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;



int main(){
    int s;cin >> s;
    vector<bool> f(1000000,false);
    for (int i = 0; i <= 1000000; i++) {
        if(f[s]){
            cout << i+1 << endl;
            return 0;
        }
        f[s]=true;
        if(s%2) s=s*3+1;
        else s/=2;
    }
    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long double llf;
const int MN=1e5+4;
const llf INF=1e100,EPS=7e-12,GR=(1+sqrt(5))/2.0;
int N;
llf ans=INF;
struct pnt {
    llf x, y;
    llf ox,oy;
    char c;
}pnts[MN];
static inline void mov(pnt &p,llf dt) {
    switch(p.c) {
        case 'R':
            p.x=p.ox+dt;
            p.y=p.oy;
            break;
        case 'L':
            p.x=p.ox-dt;
            p.y=p.oy;
            break;
        case 'U':
            p.x=p.ox;
            p.y=p.oy+dt;
            break;
        case 'D':
            p.x=p.ox;
            p.y=p.oy-dt;
            break;
    }
}
static inline llf bb() {
    llf mxx=-INF,mxy=-INF,mnx=INF,mny=INF;
    for(int i=0;i<N;++i) {
        mxx=std::max(mxx,pnts[i].x);
        mnx=std::min(mnx,pnts[i].x);
        mxy=std::max(mxy,pnts[i].y);
        mny=std::min(mny,pnts[i].y);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main() {
    scanf("%d",&N);
    for(int i=0;i<N;++i) {
        scanf("%Lf %Lf %c",&pnts[i].ox,&pnts[i].oy,&pnts[i].c);
    }
    // do GSS
    llf lo=0,hi=1e9,mi1,mi2;
    for(int i=0;i<500;++i) {
        mi1=hi-(hi-lo)/GR;
        mi2=lo+(hi-lo)/GR;
        llf b1,b2;
        for(int i=0;i<N;++i)
            mov(pnts[i],mi1);
        b1=bb();
        for(int i=0;i<N;++i)
            mov(pnts[i],mi2);
        b2=bb();
        if(b1<b2) hi=mi2;
        else lo=mi1;
        ans=std::min(std::min(b1,b2),ans);
    }
    printf("%.9Lf\n",ans);
}


Measured memory_bytes: 8064
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=0
        while True:
            if n==1:
                print(a)
                break
            elif n%2==0:
                n/=2
                a+=1
            else:
                n*=3
                n+=1
                a+=1


Measured memory_bytes: 5596
S = input()

ans = [0] * (len(S)+1)

for i in range(len(S)):
    if S[i] == "<":
        ans[i+1] = ans[i]+1
# print(ans)

for i in range(len(S)):
    if S[len(S)-i-1] == ">":
        ans[len(S)-i-1] = max(ans[len(S)-i-1], ans[len(S)-i]+1)
# print(ans)

print(sum(ans))


Measured memory_bytes: 23376
n=int(input())
a=sorted(list(map(int,input().split())))
if a[-1]<=0:
  print(2*a[-1]-sum(a))
  s=a[-1]
  for i in a[:-1]:
    print(s,i)
    s-=i
elif a[0]>=0:
  print(sum(a)-2*a[0])
  s=a[0]
  for i in a[1:-1]:
    print(s,i)
    s-=i
  print(a[-1],s)
else:
  m=0
  for i in range(n):
    if a[i]>=0:
      k=i
      break
    m-=a[i]
  print(m+sum(a[k:]))
  s=a[0]
  for i in a[k:-1]:
    print(s,i)
    s-=i
  print(a[-1],s)
  s=a[-1]-s
  for i in a[1:k]:
    print(s,i)
    s-=i

Measured memory_bytes: 62172
import math

def read_values():
    return map(int, input().split())


def read_list():
    return list(map(int, input().split()))


def f():
    a, b, x = read_values()
    if x <= a * a * b / 2:
        t = 2 * x / (a * b * b)
        print(90 - math.degrees(math.atan(t)))
    else:
        t = 2 * (a * a * b - x) / a ** 3
        print(math.degrees(math.atan(t)))

if __name__ == '__main__':
    f()


Measured memory_bytes: 3060
N, M = map(int, input().split())
AB_list = [list(map(int, input().split())) for i in range(N)]
AB_list.sort()
ans, cnt = 0, 0
for a, b in AB_list:
    ans += a*b
    cnt += b
    if cnt > M:
        ans = ans-(a*(cnt-M))
        break
print(ans)

Measured memory_bytes: 27756
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll H,W,K;
    cin >> H >> W >> K;
    vector<vector<ll>> dp(H+1, vector<ll>(W, 0));
    dp[0][0] = 1;
    if(W==1){
        pr(1);
        return 0;
    }

    REP(h, H){
        REP(w, W){
            for (int i = 0; i < 1<<(W-1); i++) {
                bool flag = false;
                for (int j = 0; j < W-2; j++) {
                    if(i&(1<<j) && i&(1<<(j+1))){
                        flag = true;
                        break;
                    }
                }
                if(flag)continue;//正しい網くじでない

                flag = true;
                if(w != 0){
                    if(i&(1<<(w-1))){
                        (dp[h+1][w-1] += dp[h][w]) %= MOD; 
                        flag = false;
                    }
                }
                if(w != W-1){
                    if(i&(1<<(w))){
                        (dp[h+1][w+1] += dp[h][w]) %= MOD; 
                        flag = false;
                    }
                }
                if(flag){
                    (dp[h+1][w] += dp[h][w]) %= MOD; 
                }
            }
        }
    }
    pr(dp[H][K-1]);
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int a[100001], b[100001];
char c[4]={"WA"};
int main()
{
    int ac = 0, wa = 0;
    int n, m, i, num;
    char s[4];
    scanf("%d%d",&n, &m);
    for(i = 1; i <= m; i++)
    {
        scanf("%d",&num);
        scanf("%s",s), getchar();
        if(!a[num]){
            if(!strcmp(s,c)) b[num]++;
            else ac++, a[num]++;
        }
    }
    for(i=1;i<=n;i++) if(a[i] && b[i]) wa+=b[i];
    printf("%d %d\n",ac,wa);
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  for(int i =  0;i < s.size();i++){
    if(i%2 == 0){
      if(s.at(i) == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }
    if(i%2 == 1){
      if(s.at(i) == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def main2():
    N=int(input())
    #各交通機関の移動人数
    t=[int(input()) for _ in range(5)]
    MIN=min(t)
    if N%MIN==0:
        m=N//MIN+4
    else:
        m=N//MIN+1+4
    print(m)

if __name__=="__main__":
    main2()

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    ll t = 1;
    ll a = 1;
    rep (i, N) {
        ll T, A;
        cin >> T >> A;

        ll n = max((t+T-1)/T, (a+A-1)/A);
        t = n*T;
        a = n*A;
    }

    cout << t+a << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        long under = A-1;
        long ans1 = B/C + B/D;
        long ans2 = (A-1)/C + (A-1)/D;
        long c = C;
        long d = D;
        while (true) {
            long tmp = c%d;
            c = d;
            d = tmp;
            if (d == 0) {
                break;
            }
        }
        long sm = C*D/c;
        long ans3 = B - (ans1 - B/sm);
        long ans4 = (A-1) - (ans2 - (A-1)/sm);
        System.out.println(ans3-ans4);
    }
}

Measured memory_bytes: 25300
import math

n = int(input())

x = []
y = []

x_dis = 0
y_dis = 0
total_dis = 0

for i in range(n):
    x1, y1 = map(int, input().split())
    x.append(x1)
    y.append(y1)

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x_dis = (x[i] - x[j]) ** 2
        y_dis = (y[i] - y[j]) ** 2
        total_dis += math.sqrt(x_dis + y_dis)

print(total_dis / n)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) (v).begin() (v).end()
#define m 998244353
#define pb push_back
#define sz(v) (v).size()
#define ll long long

int main()
{
        ll n;
        cin>>n;
cout<<n*n*3;
}





Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val p = List(m) { readIntList() }

    val first = p.filter { it[0] == 1 }.map { it[1] }
    val second = p.filter { it[1] == n }.map { it[0] }
    if (first.intersect(second).isNotEmpty()) {
        println("POSSIBLE")
    } else {
        println("IMPOSSIBLE")
    }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 78208
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;


int main() {
    ll n,x,m;
    cin >> n >> x >> m;

    vector<ll> mark(m,-1);
    vector<ll> history;

    mark[x] = 0;
    history.push_back(x);

    ll prev = x;

    for(ll i = 1;i < n;++i){
        ll now = (prev * prev) % m;

        if(mark[now] >= 0){
            ll s = 0;
            ll siz = i - mark[now];
            
            for(ll j = mark[now];j < i;++j){
                s += history[j];
              //  cout << history[j] << endl;
            }

            ll first = 0;

            for(ll j = 0;j < mark[now];++j){
                first += history[j];
            }

            ll last = 0;

            ll lstart = mark[now] + ((n - mark[now]) / siz) * siz;

            for(ll j = lstart;j < n;++j){
                last += history[mark[now] + j - lstart];
            }

/*
            cout << "now = " << now << endl;
            cout << "mark[now] = " << mark[now] << endl;
            cout << "s = " << s << endl;
            cout << "siz = " << siz << endl;
            cout << "first = " << first << endl;
            cout << "last = " << last << endl;
            cout << "lstart = " << lstart << endl;
            */

            cout << (first + last + s * ((n - mark[now]) / siz)) << endl;
            return 0;
        }

        mark[now] = history.size();
        history.push_back(now);
        prev = now;
    }

    ll ans = 0;

    for(ll i = 0;i < n;++i){
        ans += history[i];
    }

    cout << ans << endl;
}





Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=998244353;

int main(){
	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000<<endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int F[45];

int fibonacci(int n)
{
  if(n == 0 || n == 1)
    {
      return F[n] = 1;
    }
  if(F[n] != 0)
    {
      return F[n];
    }
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}
int main()
{
  int n,anser;
  scanf("%d",&n);
  anser = fibonacci(n);
  printf("%d\n",anser);
  return 0;
}



Measured memory_bytes: 2104
# coding: utf-8
str_S = raw_input()

list_S = list(str_S)
list = list(str_S)

list_number = []

while list != []:
    number = 0
    for char in list:
        if char == 'A' or char == 'C' or char == 'G' or char == 'T':
            number += 1
        else:
            break
    list_number.append(number)

    for n in range(number + 1):
        if list != []:
            list.pop(0)

print max(list_number)


Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define P pair<long double,string>

int main(){
int n;
while(true){
cin>>n;
if(n==0)break;
vector<P>ans(0);
for(int iii=0;iii<n;iii++){
long double p,a,b,c,d,e,f,s,m;
string l;
long double tmp;
cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
int time=a+b+c+d+e;
for(int i=1;i<m;i++){
time+=d+e;
}
tmp=((f*m*s)-p)/time;
ans.push_back(P(tmp,l));
}

sort(ans.begin(),ans.end(),greater<P>());

for(int i=0;i<ans.size();i++){
for(int j=0;j<ans.size();j++){	
if(i==j)continue;
if(ans[i].first==ans[j].first&&ans[i].second<ans[j].second){
swap(ans[i],ans[j]);
}
}
}
for(int i=0;i<ans.size();i++){
cout<<ans[i].second<<endl;
}
cout<<"#"<<endl;
}
return 0;
}

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

using namespace std;

#define ll long long
#define MOD 1000000007

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<ll> x(n);
  vector<ll> y(m);
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < m; i++) cin >> y[i];
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  ll v = 0;
  ll h = 0;
  ll v_all = 0;
  ll h_all = 0;
  for(int i = 1; i < n; i++){
    v += (ll)i * (x[i] - x[i - 1]);
    v_all += v;
    v %= MOD;
    v_all %= MOD;
  }
  for(int i = 1; i < m; i++){
    h += (ll)i * (y[i] - y[i - 1]);
    h_all += h;
    h %= MOD;
    h_all %= MOD;
  }
  v_all %= MOD;
  h_all %= MOD;
  
  cout << (v_all * h_all) % MOD << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int N=1e5+5;
vector<int> ve[N];
priority_queue<int> qe;
int main()
{
	int n,m;cin>>n>>m;
	int a,b;
	for(int i=0;i<n;++i)
	{
		cin>>a>>b;
		if(m-a+1<1)continue;
		ve[m-a+1].push_back(b);
	}
	int ans=0;
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<ve[i].size();++j)
			qe.push(ve[i][j]);
		if(!qe.empty())
		{
			ans+=qe.top();qe.pop();
		}
	}
	cout<<ans;
}

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

using namespace std;
#define int long long

int k[102][100002];

int dp(int peso[], int valor[], int w, int n) {

    for(int i = 0; i<= n; i++) {
        for(int j=0; j<= w; j++) {
            if(i == 0 || j== 0)
                k[i][j] = 0;
            else if(peso[i-1] <= j)
                k[i][j] = max(valor[i-1] + k[i-1][j-peso[i-1]], k[i-1][j]);
            else 
                k[i][j] = k[i-1][j];
        }
    }
    return k[n][w];
}

signed main() {
    int n, w;
    cin>> n>> w;
    int valor[n], peso[n];
    for(int i = 0; i< n; i++) {
        cin>> peso[i]>> valor[i];
    }
    memset(k, 0, sizeof(k));
    int res = dp(peso, valor, w, n);

    cout<<res<<endl;

}

Measured memory_bytes: 79872
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        set<int> remains;
        for (int i = 1; i < n; i++) {
            int remain = (i * i) % n;
            remains.insert(remain);
        }
        int max = (n - 1) / 2;
        int* differences = new int [max + 1];
        fill_n(differences, max + 1, 0);
        for (set<int>::iterator it1 = remains.begin(); it1 != remains.end(); it1++) {
            for (set<int>::iterator it2 = it1; it2 != remains.end(); it2++) {
                if (it1 == it2) {
                    continue;
                }
                int diff = *it1 - *it2;
                if (diff < 0) {
                    diff += n;
                }
                if (diff > max) {
                    diff = n - diff;
                }
                differences[diff] += 2;
            }
        }
        for (int i = 1; i <= max; i++) {
            cout << differences[i] << endl;
        }
        delete[] differences;
    }
}

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

void solve() {
    string s;
    LL k;
    cin >> s >> k;
    for (char c : s) {
        if (c == '1') {
            k--;
            if (k == 0) {
                cout << c << "\n";
                return;
            }
        } else {
            cout << c << "\n";
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void ABD() {
	int N;
	cin >> N;
	cout << ((N < 1000) ? "ABC" : "ABD");
}
int main() {
	ABD();
	return 0;
}


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

long gcd(long C, long D){
  if(D==0) return C;
  return gcd(D,C%D);
}

int main(){
  long A,B,C,D;
  long count=0;
  long countC=0;
  long countD=0;
  long countCD=0;
  cin >> A >> B >> C >> D;
  long g = gcd(C, D);
  long cd = C*D/g;
  countC = B/C-(A-1)/C;
  countD = B/D-(A-1)/D;
  countCD = B/cd-(A-1)/cd;
  count = B-(A-1)-(countC+countD-countCD);
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

t1, t2 = list(map(int,input().split()))
a1, a2 = list(map(int,input().split()))
b1, b2 = list(map(int,input().split()))

da1 = a1*t1
da2 = da1 + a2*t2
db1 = b1*t1
db2 = db1 + b2*t2

if da2==db2:
	ans = 'infinity'
else:
	if (da1-db1)*(da2-db2)>0:
		ans = 0
	else:
		fdif = abs(da1-db1)
		sdif = abs(da2-db2)
		iteration = fdif//sdif
		mod = fdif%sdif
		if mod==0:
			ans = iteration*2
		else:
			ans = iteration*2+1

print(ans)

Measured memory_bytes: 38384
fun main(args: Array<String>) {
    val (n, c) = readLine()!!.split(' ').map { it.toInt() }
    val d = (0 until c)
            .map { readLine()!!.split(' ').map { it.toInt() }.toIntArray() }
            .toTypedArray()
    val t = Array(3) { IntArray(c) }
    repeat(n) { i ->
        readLine()!!
                .split(' ')
                .map { it.toInt() }
                .forEachIndexed { j, x ->
                    t[(i + j) % 3][x - 1]++
                }
    }

    var ans = Int.MAX_VALUE

    for (i in 0 until c) {
        for (j in 0 until c) {
            if (i == j) continue
            for (k in 0 until c) {
                if (i == k || j == k) continue

                var x = 0

                x += (0 until c).map { d[it][i] * t[0][it] }.sum()
                x += (0 until c).map { d[it][j] * t[1][it] }.sum()
                x += (0 until c).map { d[it][k] * t[2][it] }.sum()

                ans = Math.min(x, ans)
            }
        }
    }

    println(ans)
}


Measured memory_bytes: 71832
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>

#define err 1e-7
#define INF 2e9 

#define mp make_pair
#define pb push_back

#define tr(container, iterator) \
	for(typeof(container.begin()) iterator=container.begin(); \
		it != container.end(); it++)

using namespace std;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);	

	string s;
	cin >> s;

	long long ans = 0;
	long long n = s.length();

	vector<long long> cnt(26, 1);

	for (int i = 0; i < n; i++) {
		ans += cnt[s[i] - 'a'];
		cnt[s[i] - 'a']++;
	}

	cout << n * (n + 1) / 2 + 1 - ans;
	/*
	vector<int> d1 (n);
	int l=0, r=-1;
	for (int i=0; i<n; ++i) {
		int k = (i>r ? 0 : min (d1[l+r-i], r-i)) + 1;
		while (i+k < n && i-k >= 0 && s[i+k] == s[i-k])  ++k;
			d1[i] = k--;
		if (i+k > r)
			l = i-k,  r = i+k;
		ans += d1[i];	
	}	

	vector<int> d2 (n);
	l=0, r=-1;
	for (int i=0; i<n; ++i) {
		int k = (i>r ? 0 : min (d2[l+r-i+1], r-i+1)) + 1;
		while (i+k-1 < n && i-k >= 0 && s[i+k-1] == s[i-k])  ++k;
			d2[i] = --k;
		if (i+k-1 > r)
			l = i-k,  r = i+k-1;
		ans += d2[i];
	}	

	long long len = s.length();
	
	cout << (len * (len + 1) / 2 - ans) * 2	;
	*/
	return 0;
}

Measured memory_bytes: 640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=(input.trim()).split("\n");
while(true){
   var nm=arr.shift();
   if(nm=="0 0")break;
   nm=nm.split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   var ary=[];
   for(var i=0;i<=n;i++)ary[i]=true;
   var i=1;
   var j=0;
   var cnt=0;
   while(true){
      if(ary[i]){
         j++;
         if(j==m){
            ary[i]=false;
            j=0;
            cnt++;
            if(cnt==ary.length-2)break;
         }
      }
      i++;
      if(ary.length-1<i)i=1;
   }
   for(var i=1;i<=n;i++){
      if(ary[i])console.log(i);
   }
}

Measured memory_bytes: 16052
#include <stdio.h> 
 #include <ctype.h> 
 
 
 int main(){ 
     char ch; 
     while(1){ 
         scanf("%c", &ch); 
         if(ch=='\n'){ 
             printf("\n"); 
             break; 
         }else if(islower(ch)){ 
             printf("%c", toupper(ch)); 
         }else if(isupper(ch)){ 
             printf("%c", tolower(ch)); 
         }else{ 
             printf("%c", ch); 
         } 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2040
d = {
    (1,2): 3,
    (1,3): 5,
    (1,4): 2,
    (1,5): 4,
    (2,1): 4,
    (2,3): 1,
    (2,4): 6,
    (2,6): 3,
    (3,1): 2,
    (3,2): 6,
    (3,5): 1,
    (3,6): 5,
    (4,1): 5,
    (4,2): 1,
    (4,5): 6,
    (4,6): 2,
    (5,1): 3,
    (5,3): 6,
    (5,4): 1,
    (5,6): 4,
    (6,2): 4,
    (6,3): 2,
    (6,4): 5,
    (6,5): 3
}

v = list(map(int, input().split()))
q = int(input())
questions = []
for _ in range(q):
    x, y = map(int, input().split())
    questions.append((x,y))

vTod  = dict(zip(v,list(range(1,7))))
dTov  = {v:k for k, v in vTod.items()}

for top, face in questions:
    top = vTod[top]
    face = vTod[face]
    right = d[(top,face)]
    right = dTov[right]
    print(right)


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

int main(void)
{
    int n;
    int a[101];
    int i, j;
    int tmp;
    int cnt = 0;

    scanf("%d", &n);

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

    for (i = 0; i < n; i++){
        for (j = n - 1; j > i; j--){
            if (a[j - 1] > a[j]){
                tmp = a[j - 1];
                a[j - 1] = a[j];
                a[j] = tmp;
                cnt++;
            }
        }
    }

    for (i = 0; i < n - 1; i++){
        printf("%d ", a[i]);
    }
    printf ("%d\n", a[n - 1]);
    printf("%d\n", cnt);

    return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    REP(i, 0, n){
        ll a; cin >> a;
        mp[a]++;
    }

    ll ans = 0;

    for(auto p : mp){
        if(p.second % 2 == 1) ans++;
        //cout << p.first << " " << p.second << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int cost = 0;
  if (A > 2 * C) {
    cost = 2 * X * C;
    Y -= X;
    X = 0;
  }
  if (B > 2 * C && Y > 0) {
    cost += 2 * Y * C;
    X -= Y;
    Y = 0;
  }

  if (A + B > 2 * C) {
    int mn = std::max(std::min(X, Y), 0);
    cost += 2 * mn * C;
    X -= mn;
    Y -= mn;
  }

  if (X > 0) {
    cost += X * A;
  }
  if (Y > 0) {
    cost += Y * B;
  }

  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_158_StationandBus
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string result = "";
            if (s.Substring(0,1) == s.Substring(1,1) && s.Substring(1,1) == s.Substring(2,1))
            {
                result = "No";
            }
            else
            {
                result = "Yes";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25824
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void calc(vector<vector<int>>& c, int x, int y)
{
	auto H = (int)c.size();
	auto h = y;
	for (auto l = y; l < H - 1; ++l)
	{
		if (c[l][x] > 0)
		{
			continue;
		}
		if (h < l)
		{
			h = l;
		}
		for (; h < H && c[h][x] == 0; ++h);
		if (h >= H)
		{
			break;
		}
		c[l][x] = c[h][x];
		c[h][x] = 0;
	}
}

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> c(H, vector<int>(W));
	for (auto i = H - 1; i >= 0; --i)
	{
		string s;
		cin >> s;
		for (auto j = 0; j < W; ++j)
		{
			c[i][j] = s[j] - '0';
		}
	}

	auto ans = 0;
	for (auto y = 0; y < H; ++y)
	{
		for (auto x = 0; x < W; ++x)
		{
			auto result = 0;
			vector<vector<int>> temp(c);
			temp[y][x] = 0;
			calc(temp, x, y);

			auto mul = 1;
			while (true)
			{
				auto sum = 0;
				for (auto h = y; h < H; ++h)
				{
					auto num = 0;
					auto count = 0;
					for (auto w = 0; w < W; ++w)
					{
						if (num == 0)
						{
							num = temp[h][w];
							count = 1;
						}
						else if (num != temp[h][w])
						{
							if (count >= K)
							{
								sum += num * count;
								for (auto i = 0; i < count; ++i)
								{
									temp[h][w - 1 - i] = 0;
								}
							}
							num = temp[h][w];
							count = 1;
						}
						else
						{
							++count;
						}
					}

					if (count >= K)
					{
						sum += num * count;
						for (auto i = 0; i < count; ++i)
						{
							temp[h][W - 1 - i] = 0;
						}
					}
				}

				if (sum <= 0)
				{
					break;
				}

				for (auto i = 0; i < W; ++i)
				{
					calc(temp, i, y);
				}

				result += sum * mul;
				mul *= 2;
			}

			ans = max(ans, result);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int A, B; cin >> A >> B;
    if (abs(A-B)%2 == 0) cout << abs(A-B)/2 + min(A, B) << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
mother = A[0]
child = 1

for a in A[1::]:
    child = mother + a * child
    mother *= a
    if mother % child == 0:
        common = mother // child
        mother //= common
        child //= common

print(mother/child)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	const int kouka[6]={500,100,50,10,5,1};
	int kingaku;
	int i;
	int maisuu;
	int oturi;
	while(1) {
		scanf("%d",&kingaku);
		if(kingaku==0)break;
		oturi=1000-kingaku;
		maisuu=0;
		for(i=0;i<6;i++) {
			while(oturi>=kouka[i]) {
				oturi-=kouka[i];
				maisuu++;
			}
		}
		printf("%d\n",maisuu);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> x(N+1,0);
    vector<int> y(M+1,0);
    cin >> x[0] >> y[0];
    for(int i=0;i<N;i++){
        cin >> x[i+1];
    }
    for(int i=0;i<M;i++){
        cin >> y[i+1];
    }
    sort(x.rbegin(),x.rend());
    sort(y.begin(),y.end());
    /*for(int i=0;i<x.size();i++){
        cout << x[i] << " ";
    }
    cout << endl;
    for(int i=0;i<y.size();i++){
        cout << y[i] << " ";
    }
    cout << endl;*/
    if(x[0]>=y[0]){
        cout << "War" << endl;
    }
    else{
        cout << "No War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
 
const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };
 
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi v(n, 0);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v[a - 1]++;
		v[b - 1]++;
	}
	REP(i, n) {
		cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
class Route
#    rt: List, rt= [[x1, x2, y1], [x1, x3, y2],...]     x1->x2 cost y1
  def initialize(nMachi, rt)
    @nMachi=nMachi
    @rt = rt.dup
  end

  def solve(start, dest)
    goal =dest
    aux(start, [], 0, goal)
  end

  def aux(start, visit, sum, goal) # search route from start
    if start== goal then
      return sum
    else
      rt1=@rt.select{|from,to,cost| from==start and !visit.index(to)}
      rst= rt1.map{|from,to,cost|
        aux(to, visit+[start], sum+cost, goal)
      }
      return rst.select{|x| x}.min
    end
  end

end

def main()
  if true then
    fh=STDIN
  else
    fh=open("in1_0117.txt", "r")
  end

  nMachi=fh.gets.chomp.to_i
  nKaido=fh.gets.chomp.to_i

  rt = []
  0.upto(nKaido-1){|i|
    x1,x2,y1,y2=fh.gets.chomp.split(/,/).map{|x|x.to_i}
    rt.push [x1, x2, y1]
    rt.push [x2, x1, y2]
  }
  start,dest,moto,hashira=fh.gets.chomp.split(/,/).map{|x|x.to_i}

  r=Route.new(nMachi,rt)
  go=r.solve(start,dest)
  ret=r.solve(dest,start)
  reward = moto - go - ret - hashira
  puts reward
end

if __FILE__ == $0 then
  main
end

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

int main() {
    int ret = 0;
    int n;
    cin >> n;
    vector<int> a(n+1);

    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if((i % 2) == 0) {
            continue;
        }
        if((a[i] % 2)) {
            ret++;
        } 
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3548