akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;
const int N=200010,mod=1000000007;

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

int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) sum[i]=(sum[i-1]+a[i])%mod;
	for(int i=1;i<=n-1;i++){
		ans+=a[i]*(sum[n]-sum[i]);
		ans%=mod;
	}
	cout<<(ans%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 5976
import java.io.*;
public class Main{
    static void scan()throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String str=br.readLine();
	turn(str);
    }

    static void turn(String str){
	int l = str.length();
	for(int i=l-1;i>0;i--)
	    System.out.print(str.charAt(i));
System.out.println(str.charAt(0));
    }
    
    public static void main(String[] args)throws IOException{
	scan();
    }
}

Measured memory_bytes: 16876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int sum=0,cnt=0;
  int i=0;
  while(sum<=x){
    cnt++;
    sum+=a[i];
    i++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

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

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

    int flag = 0;
    int cou = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i]){
            cou++;
            if(cou >= 3){
                flag = 1;
                break;
            }
        }else{
            cou = 0;
        }
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int f[200005];
bool rec[200005];
vector<int> togive;
int main() {
    ios::sync_with_stdio(false);
//    cin.tie(0);

    int n;
    cin >> n;
    vector<int> p, q;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        p.push_back(x);
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        q.push_back(x);
    }
    if (p > q) swap (p, q);
    int ans = 0;
    while (p != q) {
        next_permutation(p.begin(), p.end());
        ans++;
    }
    cout << ans << '\n';

    return 0;
}

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

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define forn2(i, n) for(int i=0; i<=(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define x first
#define y second
#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)
#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
#define salfinal(x) cout<<x<<endl;
using namespace std;
const int MAX =1e5+1;
int v[MAX];
int memo[MAX];
int c;

int f(int i)
{

    if(memo[i]!=-1)
        return memo[i];

    if(i == 0)
        return memo[0] = 0;

    if(i == 1)
        return memo[1] = abs(v[0] - v[1]);

    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));
}

int main()
{
    ios_base::sync_with_stdio(false);
    memset(memo, -1, sizeof(memo));
    cin>>c;

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

    cout<<f(c-1)<<endl;

    return 0;
}


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

map <int, int> c;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, aux;
  cin >> n;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (c[aux] == 1) ans = false;
    else c[aux] = 1;
  }
  cout << (ans? "YES\n" : "NO\n");
  return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main(void)
{
    ll n, m;

    cin >> n >> m;

    vector<ll> a = divisor(m);

    ll ans;

    for (auto x : a)
    {
        if (x <= m / n)
        {
            ans = x;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<Integer> set = new HashSet<Integer>();
    for(int i = 0;i<n;i++){
      set.add(sc.nextInt());
    }
    if(set.size() == n){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 69524
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int cx[] = {0, w};
        int cy[] = {0, h};
        for(int i = 0; i < n; i++){
        	int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();
            if(a == 1 && cx[0] < x){
            	cx[0] = x;
            }else if(a == 2 && cx[1] > x){
            	cx[1] = x;
            }else if(a == 3 && cy[0] < y){
            	cy[0] = y;
            }else if(a == 4 && cy[1] > y){
            	cy[1] = y;
            }
            if(cx[0] >= cx[1] || cy[0] >= cy[1]){
            	System.out.println(0);
                return;
            }
        }
        int yoko = cx[1] - cx[0];
        int tate = cy[1] - cy[0];
        System.out.println(yoko * tate);
	}
}


Measured memory_bytes: 36192
use proconio::input;

const MOD: i64 = 998_244_353;

fn main() {
    input! {
        n: usize,
        k: usize,
        lr: [(usize, usize); k]
    }
    let mut dp = vec![0; n];
    dp[0] = 1;
    dp[1] = -1;

    for i in 0..n {
        if i > 0 {
            dp[i] += dp[i - 1];
            dp[i] %= MOD;
        }

        for &(l, r) in lr.iter() {
            let r = r + 1;
            if i + l < n {
                dp[i + l] += dp[i];
                dp[i + l] %= MOD;
            }
            if i + r < n {
                dp[i + r] -= dp[i];
                dp[i + r] %= MOD;
            }
        }
    }

    let mut ans = dp[n - 1];
    if ans < 0 {
        ans += MOD;
        ans %= MOD;
    }
    

    println!("{}", ans);
}


Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> l(n);
	for (auto &t : l) {
		cin >> t;
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int f = 0; f < n; f++) {
		for (int s = f + 1; s + 1 < n; s++) {
			int val = l[f] + l[s];
			int cnt = lower_bound(l.begin() + s + 1, l.end(), val) - (l.begin() + s + 1);
			ans += cnt;
		}
	}
	cout << ans << endl;
}


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

int main()
{
    int a;
    scanf("%d", &a);
    int a1 = a % 10;
    int a2 = a / 10 % 10;
    int a3 = a / 100;
    puts(a1 == a3 ? "Yes" : "No");
    return 0;
}


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

using namespace std;

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

    int a,b;
    cin>>a>>b;
    
    int res=a-2*b;
    
    if(res<=0)
        cout<<"0";
    else
        cout<<res;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
  bs := map[byte]int{
    'A': 0,
    'C': 1,
    'G': 2,
    'T': 3,
  }
  var s string
  fmt.Scan(&s)
  max := 0
  for i := range s {
    count := 0
    for j := i; j < len(s); j++ {
      if _, ok := bs[s[j]]; ok {
        count++
      } else {
        i = j
        break
      }
    }
    if max < count {
      max = count
    }
  }
  fmt.Println(max)
}


Measured memory_bytes: 512
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const int big=1e9-10;
const llint red=0xE869120;
const llint pro=1002001;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
static llint fla[100010];
llint gya(llint in){
	llint ans=1,now=in,i=1;
	while(i<mod-2){
		if(((mod-2)&i)!=0){ans*=now;ans%=mod;}
		i*=2;
		now=now*now;now%=mod;
	}
	return ans;
}
llint nCr(llint n,llint r){if(r==0){return 1;}if(n<r){return 0;}return (((fla[n]*gya(fla[r]))%mod)*gya(fla[n-r]))%mod;}
int main(void){
	llint n,i,r,q,p;cin>>n;
	vector<int> ki(n+2);
	for(i=0;i<=n;i++){cin>>q;if(ki[q]==0){ki[q]=i+1;}else{r=ki[q]-1+n-i;}}
	fla[0]=1;
	for(i=1;i<100010;i++){fla[i]=fla[i-1]*i;fla[i]%=mod;}
	for(i=1;i<=n+1;i++){cout<<(mod+nCr(n+1,i)-nCr(r,i-1))%mod<<endl;}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;

  int smaller = min(a, b);
  int bigger = max(a, b);

  for (int _ = 0; _ < bigger; _++) {
    cout << smaller;
  }
  cout << endl;
}


Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,k = ma()
Pt = lma()
P = [p-1 for p in Pt]
C = lma()
class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self,x,y):
        return self.root(x) == self.root(y)

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:return
        else:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] == self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x]
uf = unionfind(n)
for i in range(n):
    uf.unite(i,P[i])

def score(x):#xからスタートしたスコア
    l = uf.get_size(x)
    p,r = divmod(k,l)
    tmp = [0 for i in range(l)]#一回の累積gain
    gain_cycle = 0
    tval = 0
    for i in range(l):
        nex = P[x]
        gain_cycle +=C[nex]
        tval+=C[nex]
        tmp[i] = tval
        x = nex

    ### below::return part
    ret = -10**10
    tval = 0
    if p==0:
        for i in range(r):
            ret = max(ret,tmp[i])

    elif gain_cycle>=0:
        for i in range(l):
            if i<=r-1:
                tval=tmp[i] + gain_cycle*p
            else:
                tval=tmp[i] + gain_cycle*(p-1)
            ret = max(ret,tval)
    else:
        for i in range(l):
            ret = max(tmp[i],ret)

    return ret

        #print(ret,"ret")

ans = -10**15
for i in range(n):
    ans = max(ans,score(i))
print(ans)


Measured memory_bytes: 81312
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	return scanInt(sc)
}

func resolve(n int) int {
	_, z := nextComulative(sc, n, 0, nil)
	sums := map[int]int{}
	num := 0
	for i := 1; i < n+1; i++ {
		sums[z[i]]++
		num += sums[z[i]] - 1
	}
	// ranges include only 0 are acceptable
	num += sums[0]
	return num
}

func getComulative(a []int) (z []int) {
	z = make([]int, len(a)+1)
	(&reducer{}).reduce(&z, a)
	return
}

func nextComulative(sc *bufio.Scanner, n int, init int, op func(v, acc int) int) (a, z []int) {
	a = make([]int, n)
	z = make([]int, n+1)
	r := &reducer{init: init, op: op}
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
		r.update(&z, a, i)
	}
	return a, z
}

type reducer struct {
	init, tmp int
	op        func(v, acc int) int
}

func (r *reducer) update(z *[]int, a []int, idx int) {
	if r.op != nil {
		r.tmp = r.op(r.tmp, a[idx])
	} else {
		r.tmp += a[idx]
	}
	(*z)[idx+1] = r.tmp
}

func (r *reducer) reduce(z *[]int, a []int) {
	for i := 0; i < len(a); i++ {
		r.update(z, a, i)
	}
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 14848
p_list=[]
ans=[]
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(prime_factorize(int(input())))
p_list=c.values()
for i in p_list:
    m=1
    while 1/2*(m+1)*(m+2)<=i:
        m+=1
    ans.append(m)
print(sum(ans))      
   

Measured memory_bytes: 66000
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int[] n = IO.INT(' ');
        int[] t = IO.INT(' ');
        int max = t.Max();
        int[] maxt = t.Where(x => x == max).ToArray();
        int[] notmaxt = t.Where(x => x != max).ToArray();
        int o = Math.Max(0, maxt.Max() - notmaxt.Sum() - maxt.Max() * (maxt.Count() - 1) - 1);
        IO.WRITE(o);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

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

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N];
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextLong();
		}
		Arrays.sort(A);
		int count = 0;
		long buf = 0;
		long a = 0,b = 0;
		for(int i = N-1;i > -1;i--) {
			if(buf == A[i]) {
				count ++;
			}else {
				buf = A[i];
				count = 1;
			}

			if(count == 2) {
				if(a!=0) {
					b = buf;
					break;
				}else {
					a = buf;
					count = 0;
				}
			}
		}
		System.out.println(a*b);
	}

}


Measured memory_bytes: 49448
n = int(input())
from collections import Counter
c = Counter()
for i in range(1,n+1):
    for j in range(2, i+1):
        while i % j == 0:
            c[j] += 1
            i //= j

def num(a):
    ret = 0
    for key, value in c.items():
        if value >= a:
            ret += 1
    return ret

ans = num(74) + num(24) * (num(2)-1) + num(14)*(num(4)-1) + num(4)*(num(4)-1)//2*(num(2) - 2)
print(ans)

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(m)]

V = [0] * (n)
# P = [-1] * (n+1)

M = [[] for i in range(n)]
for i in range(m):
    M[C[i][0]].append(C[i][1])
    M[C[i][1]].append(C[i][0])

# 1始まりの場合
BB = []
one = 0
for ii in range(n):
    B = []
    if V[ii] == 0:
        Q = [ii]
        s = 0
        V[ii] = 1
        onef = 1
        B.append([ii,A[ii]])
        while s < len(Q):
            i = Q[s]
            for x in M[i]:
                if V[x] == 0:
                    V[x] = 1
                    onef = 0
                    B.append([x,A[x]])
                    # P[x] = i
                    Q.append(x)
            s += 1
        if onef == 1:
            one += 1
        B.sort(key=lambda x:x[1])
        BB.append(B[0])

if len(BB) == 1:
    print(0)
elif (len(BB)-1)*2 > n:
    print("Impossible")
else:
    ans = sum([i[1] for i in BB])
    # print(ans)
    anoBind = [0] * n
    anoB = []
    for i in range(len(BB)):
        anoBind[BB[i][0]] = 1
    for i in range(n):
        if anoBind[i] == 0:
            anoB.append(A[i])
    anoB.sort()
    # print(anoB)
    ans += sum(anoB[:len(BB)-2])
    print(ans)

Measured memory_bytes: 105368
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
 
int main()
{
 int N;
 int ans=10000000;
 scanf("%d",&N);
 for(int i=0;i<N;i++)
 {
	int a;
 	int nw=0;
	scanf("%d",&a);
	for(;;)
	{
		if(a%2==0){nw++; a/=2;}
		else{break;}
	}
	ans=min(ans,nw);
 }
 printf("%d",ans);
} 

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

using namespace std;
typedef long long ll;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<ll> dp(n + 3);
		dp[0] = 1;
		for(int i = 0; i < n; ++i){
			dp[i + 1] += dp[i];
			dp[i + 2] += dp[i];
			dp[i + 3] += dp[i];
		}
		cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;

main(){
	int f = 0;
	while(cin >> n, n){
		if(f++)cout << endl;
		map<int, int> p;
		map<int, int> ans;
		cin >> p[10] >> p[50] >> p[100] >> p[500];
		int sum = p[10]*10 + p[50]*50 + p[100]*100 + p[500]*500;
		int d;
		d = min((sum - n)/500, p[500]);
		p[500] -= d;
		sum -= 500*d;
		d = min(((sum - n)/100)%5, p[100]);
		p[100] -= d;
		sum -= 100*d;
		d = min(((sum - n)/50)%2, p[50]);
		p[50] -= d;
		sum -= 50*d;
		d = min(((sum - n)/10)%5, p[10]);
		p[10] -= d;
		sum -= 10*d;
		FOR(it, p) if(it->second) cout << it->first << " " << it->second << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N;
	cin >> N;
	int A[200100];
	REP(i, N)cin >> A[i];
	if (A[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N - 1; ++i) {
		if (A[i+1] - A[i] > 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	ll sum = 0;
	for (int i = N - 1; i > 0; --i) {
		if (A[i] > A[i - 1]) {
			sum++;
		}
		else if (A[i] == A[i - 1]) {
			sum += A[i];
		}
		else {
			sum += A[i];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
import math
a,b,h,m=[int(x) for x in input().rstrip().split()]
now_h=h*60*0.5+m*0.5
now_m=m*6
# if h==0:
#   now_h=360
# if m==0:
#   now_m=360

kakudo=(abs(now_h-now_m))
kakudo=math.cos(math.radians(kakudo))

print((a**2+b**2-2*a*b*kakudo)**0.5)
  

Measured memory_bytes: 9532
import sys

def solve():
    a, b, c = map(int, input().split())

    if a & 1 or b & 1 or c & 1:
        print(0)
        return

    if a == b and b == c:
        print(-1)
        return

    cnt = 0

    while True:
        if a & 1 or b & 1 or c & 1:
            print(cnt)
            return

        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        cnt += 1

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
char maze[3][100];
int n;
bool vis[3][maxn];

void solve(){
	bool flag = false;
	ll ans = 1;
	int i = 0, j = 0;
	if(maze[0][0] == maze[1][0]) {
		ans *= 3; j = 1;
		flag = true; 
	}
	else {
		ans *= 6;
		j = 2;
	}
	for(j; j < n;){
		if(maze[i][j] == maze[i + 1][j]){
			if(flag) ans = ans * 2 % mod;
			flag = true;
			j += 1;
		}
		else{
			if(flag) ans = ans * 2 % mod;
			else ans = ans * 3 % mod;
			flag = false;
			j += 2;
		}
	}
	printf("%lld\n", ans);
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < 2; i++) scanf("%s", maze[i]);
	solve();
}



Measured memory_bytes: 256
n,m = map(int, input().split())
ans = 0
lst = [0] * (m+1)
for _ in range(n):
	temp = list(map(int, input().split()))
	for i in range(1, temp[0] +1):
		lst[temp[i]] += 1
for i in range(m+1):
	if lst[i] == n:
		ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll a[n], b[n], c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    ll tot = 0;
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    for (int i = 0; i < n; i++) {
        ll curr = b[i];
        ll res2 = -1, res1 = -1;
        ll l = 0, r = n - 1, mid;
        while (l <= r) {
            mid = (l + r) / 2;
            if (c[mid] > curr) {
                res2 = mid;
                r = mid - 1;
            }
            else {
                l = mid + 1;
            }
        }
        l = 0, r = n - 1;
        while (l <= r) {
            mid = (l + r) / 2;
            if (a[mid] < curr) {
                res1 = mid;
                l = mid + 1;
            }
            else {
                r = mid - 1;
            }
        }
        if (res1 == -1 || res2 == -1)
            continue;
        tot += (res1 + 1) * (n - res2);
    }
    cout << tot;
    return  0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

int x[10010];

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

	int n, k, m;
	while(cin >> n >> k >> m, n + k + m) {
		m = (m - k + 1 + n) % n;
		x[1] = 0;
		for(int i = 2; i <= n; i++) {
			x[i] = (x[i - 1] + k) % i;
		}
		cout << (x[n] + m - 1 + n) % n + 1 << endl;
	}
}

Measured memory_bytes: 3112
#include <stdio.h>

int main(){

    int h, A[251];

    scanf("%d",&h);

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

    for(i=1;i<=h;i++){
        printf("node %d: key = %d, ", i, A[i]);
        if(i != 1) printf("parent key = %d, ", A[(int)i/2]);
        if((i*2) <= h) printf("left key = %d, ", A[(i*2)]);
        if((i*2)+1 <= h) printf("right key = %d, ", A[(i*2)+1]);
        printf("\n");
    }

    return 0;

}

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

string A,B;

string rec(string S1,string S2){
    if(S1=="" || S2=="") return "";
    int c = 0;
    int N1 = S1.size(),N2 = S2.size();
    string left1,right1;
    string num1;
    for(int i=0;i<N1;i++){
        if(S1[i]=='(') c++;
        if(S1[i]==')') c--;
        if(c==0){
            left1 = S1.substr(1,i-1);
            int id = i+2;
            while(S1[id]!=']'){
                num1 += S1[id];
                id++;
            }
            break;
        }
    }
    for(int i=N1-1;i>=0;i--){
        if(S1[i]=='(') c++;
        if(S1[i]==')') c--;
        if(c==0){
            right1 = S1.substr(i+1,N1-i-2);
            break;
        }
    }
    c = 0;
    string left2,right2;
    string num2;
    for(int i=0;i<N2;i++){
        if(S2[i]=='(') c++;
        if(S2[i]==')') c--;
        if(c==0){
            left2 = S2.substr(1,i-1);
            int id = i+2;
            while(S2[id]!=']'){
                num2 += S2[id];
                id++;
            }
            break;
        }
    }
    for(int i=N2-1;i>=0;i--){
        if(S2[i]=='(') c++;
        if(S2[i]==')') c--;
        if(c==0){
            right2 = S2.substr(i+1,N2-i-2);
            break;
        }
    }
    int n = stoi(num1)+stoi(num2);
    string center = to_string(n);
    return '(' + rec(left1,left2) + ')' + '[' + center + ']' + '(' + rec(right1,right2) + ')';
}

int main(){
    cin >> A >> B;
    cout << rec(A,B) << endl;
}


Measured memory_bytes: 3400
#include <iostream>
using namespace std;
const int N=2e5+10;
int n, a[N], s;
int main(){
	cin>>n;
	cin>>a[1];
	s=a[1];
	for(int i=2;i<=n;i++){
		cin>>a[i];
		s^=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		int x=a[i]^s;
		cout<<x<<' ';
	}	
	return 0;
}


Measured memory_bytes: 4304
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int n,m,ans=0;
	string s[200],t[200];
	cin>>n;
	for (int i=0;i<n;i++) cin>>s[i];
	cin>>m;
	for (int i=0;i<m;i++) cin>>t[i];
	for (int i=0;i<n;i++)
		if (s[i]!=""){
			int a=1,b=0;
			for (int j=i+1;j<n;j++) if (s[i]==s[j]) a++,s[j]="";
			for (int j=0;j<m;j++) if (s[i]==t[j]) b++,t[j]="";
			if (a>b) ans=max(ans,a-b);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n=pI(readline())
  t=pM(split(readline()))
  m=pI(readline())
  T=sum(t)
  for i=1:m
    p,x=pM(split(readline()))
    println(T-(t[p]-x))
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 169928
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    string S,T;
    T="";
    cin>>S;
    ll count=0;
    rep(i,S.size()){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
            T.pb(S[i]);
        }else{
            ll A=T.size();
            chmax(count,A);
            T="";
        }
    }
    ll A=T.size();
    chmax(count,A);
    cout<<count<<endl;
}


Measured memory_bytes: 256
//	Totally unrelated and not AT ALL stolen from hohohaha's, generic_placeholder_name's or katoriyuu's template
#include <bits/stdc++.h>

using namespace std;

// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define rep(i,s,end) for(int i = (s); i <  (end); ++i)
#define rep0(i, end) for(int i =   0; i <= (end); ++i)
#define rep1(i, end) for(int i =   1; i <= (end); ++i)
#define lb lower_bound
#define ub upper_bound

#define vt vector
#define endl "\n"

#define fileopen(filename, in_type, out_type) if (fopen(filename in_type, "r")) {freopen(filename in_type, "r", stdin);freopen(filename out_type, "w", stdout);}
#define local_input(x) if (x && fopen("input.txt","r")) freopen("input.txt","r",stdin);
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fscan(x)   scanf("%d",  &x)
#define fscandb(x) scanf("%lf", &x)
#define fscanll(x) scanf("%lld",&x)
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

#define db double
#define ll long long
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work?
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);

#define mn 1 << 18
int n;
int id1[mn],id2[mn],dp1[mn],dp2[mn];
signed main()
{
	cin >> n; rep(i,0,1 << n){
		cin >> dp1[i]; id1[i] = i, dp2[i] = id2[i] = -1;
	}
	rep(i,1,1 << n){
		rep(j,0,n) if(i & (1 << j)){
			int jj = i ^ (1 << j);
			if(jj){
				if(id1[i] == id1[jj]) continue;
				else if(dp1[i] <= dp1[jj]){
					dp2[i] = dp1[i],  id2[i] = id1[i];
					dp1[i] = dp1[jj], id1[i] = id1[jj];
					if(dp2[i] <= dp2[jj] && id2[i] != id2[jj]){
						dp2[i] = dp2[jj], id2[i] = id2[jj];
					}
				}
				else if(dp2[i] <= dp1[jj] && id2[i] != id1[jj]){
					dp2[i] = dp1[jj], id2[i] = id1[jj];
				}
			}
			else{
				if(dp1[0] > dp1[i]){
					dp2[i] = dp1[i], id2[i] = id1[i];
					dp1[i] = dp1[0], id1[i] = id1[0];
				}
				else if(dp1[0] > dp2[i]){
					dp2[i] = dp1[0], id2[i] = id1[0];
				}
			}
		}
	}
	int ans = 0;
	rep(i,1,1 << n){
		cout << (ans = max(ans, dp1[i] + dp2[i])) << endl;
	}
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there a one in my row of exclamation marks?
 

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

int f(int n){
	int sum = 0;
	while(n) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main(){
	int n;
	cin >> n;
	if(n % f(n))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


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

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;

    int ans = 0;
    for (size_t i = 0; i < n; i++) {
        int h;
        cin >> h;

        if (h >= k) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=1e9+7;

int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b;
  cin>>a>>b;
  if(a==b)
  {
  	cout<<"Yes"<<endl;
  }
  else
  {
  	cout<<"No"<<endl;
  }
  






  
}


Measured memory_bytes: 256
S = gets.chomp

chars = S.chars
line = ''
ans = []
index1, index2 = 0, 0

chars.each_with_index do |c, i|
  case c
  when 'R'
    line += c
    if chars[i+1] == 'L'
      index1 = line.size - 1
      index2 = line.size
    end
  when 'L'
    if i == chars.size - 1 or chars[i+1] == 'R'
      line += c
      c1, c2 = 0, 0
      line.chars.each_with_index do |l, j|
        case l
        when 'R'
          if (index2 - j) % 2 == 0
            c1 += 1
          else
            c2 += 1
          end
        when 'L'
          if (j - index2) % 2 == 0
            c1 += 1
          else
            c2 += 1
          end
        end
      end
      tmp = [0] * line.size
      tmp[index1] = c2
      tmp[index2] = c1
      ans << tmp
      line = ''
    else
      line += c
    end
  end
end

puts ans.join(' ')

Measured memory_bytes: 94992
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	string s;

	string t;
	cin >> t;

	for (int i = 0; i < 20; i++) {
		s += "hi";
		if (t == s) {
			cout << "Yes" << endl;
			return 0;		
		}

	}
	cout << "No" << endl;
	return 0;

}

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

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

    int n, l;
    cin >> n >> l;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += l + i - 1;
    }
    int dif = 1e9;
    int hoge;
    for (int i = 1; i <= n; i++) {
        if (abs(l + i - 1) < dif) {
            dif = abs(l + i - 1);
            hoge = l + i - 1;
        }
    }
    cout << sum - hoge << endl;
}

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


int main()
{int a,b;
while(1)
{
    cin>>a>>b;
    if(a==0&&b==0) break;
    if(a>b)
    {
        int what=a;
        a=b;
        b=what;
    }
    cout<<a<<" "<<b<<endl;
}
    
    return 0;
    }

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <cmath>
#define ll long long
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int result=c-(a-b);
    if(result <=0){
        result =0;
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int H , W , A = 0;
    cin >> H >> W;
    char B;
    vector<vector<string>> S(H , vector<string>(W));
    for(int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> S.at(i).at(j);
            if(S.at(i).at(j) == "snuke"){
                A = i;
                B = j;
            }
        }
    }
    cout << char(B + 65)  << A + 1 << endl;
}


Measured memory_bytes: 3588
/*  ex9_1 Stack (Keyboard)
    pandacodeb  */

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

#define SIZE 10

typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
}stack;

void init_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
void push(stack *stk, char key){
    if (stk->count >= stk->size)
        exit(1);
    else{
        stk->top--;
        *(stk->top) = key;
        stk->count++;
    }
}

char pop(stack *stk){
    char latest;
    if (stk->count <= 0){
        return ' ';
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

void print_s(stack *stk){
    char *ptr;
    ptr = (stk->top)+(stk->count)-1;
    for (int i = 0; i < stk->count; i++)
        printf("%c", *ptr--);
    printf("\n");
}

int main(void){
    int i;
    char del;
    char* text;
    text = (char*) malloc(sizeof(char)*10);
    scanf("%s", text);

    stack stk;
    init_stack(&stk);

    for (i = 0; i < strlen(text); i++){
        if (text[i] == '0' || text[i] == '1')
            push(&stk, text[i]);
        else if (text[i] == 'B')
            del = pop(&stk);
    }

    print_s(&stk);
    
    return 0;
}

Measured memory_bytes: 1656
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using vvpii = vector<vpii>;

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vvpii dp(m, vpii(m));
    rep(i, m) rep(j, m) dp[i][j] = i == j ? mp(0LL, 0LL) : mp(INF, INF);
    while (n--) {
      int a, b, cost, time;
      cin >> a >> b >> cost >> time;
      a--, b--;
      dp[a][b] = dp[b][a] = mp(cost, time);
    }
    rep(k, m) rep(i, m) rep(j, m) {
      cmin(dp[i][j].fi, dp[i][k].fi + dp[k][j].fi);
      cmin(dp[i][j].se, dp[i][k].se + dp[k][j].se);
    }
    int k;
    cin >> k;
    while (k--) {
      int p, q, r;
      cin >> p >> q >> r;
      p--;
      q--;
      cout << (r ? dp[p][q].se : dp[p][q].fi) << endl;
    }
  }
}

Measured memory_bytes: 3120
n,m = map(int,input().split())
dic = {}
ac = 0
wa = 0
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if p not in dic:
        if s =='AC':
            ac += 1
            dic[p] = s
        else:
            dic[p] = 1
    elif dic[p]=='AC':
        continue
    else:
        if s =='AC':
            ac += 1
            wa +=dic[p]
            dic[p] = s
        else:
            dic[p] += 1

print(str(ac) + ' ' + str(wa))


Measured memory_bytes: 92252
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int N = fs.nextInt();
		int K = fs.nextInt();
		int res = 0;
		int[] vs = fs.nextIntArray(N);
		for(int left = 0; left <= N; left++) {
			for(int right = 0; right <= N; right++) {
				if(left+right > N || left+right > K) break;
				int sum = 0;
				ArrayList<Integer> neg = new ArrayList<>();
				int moves = K;
				for(int i = 0; i < left; i++) {
					sum += vs[i];
					if(vs[i] < 0) neg.add(vs[i]);
					moves--;
				}
				for(int i = N-1, cnt = 0; cnt < right; i--, cnt++) {
					sum += vs[i];
					if(vs[i] < 0) neg.add(vs[i]);
					moves--;
				}
				Collections.sort(neg);
				while(!neg.isEmpty() && moves > 0) {
					moves--;
					sum -= neg.remove(0);
				}
				res = Math.max(res, sum);
				
			}
		}
		
		out.println(res);
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

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

signed main(void){
    int n; cin >> n;
    string s; cin >> s;
    s += '$';
    int ans = 1;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
T, A = map(int, input().split())
hights = [int(i) for i in input().split()]

temperatures =[]
for hight in hights:
    temperature = T - hight*0.006
    temperatures.append(temperature)

ans = 10**9
for temp in temperatures:
    sub = abs(temp-A)
    if sub < ans:
        ans = sub
        ans_number = temperatures.index(temp)

print(ans_number+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;
const int N=1e5+10;
int ar[N];
string str[100];
int main()
{
    ios::sync_with_stdio(false);
    ll a,b,c,k;

    cin>>a>>b>>c>>k;
    if(k%2){
        cout<<b-a<<endl;
    }
    else
        cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 256