akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)
int n,k;
char s[200005];
int h,flip=0;
deque<int> d;
int get() {
	return (h^flip);
}
void put(int x) {
	h=x^flip;
}
void pad() {
	if (sz(d)%2) {
		if (get()==0) d[sz(d)-1]++;
		else d.pb(1);
	} else {
		if (get()==1) d[sz(d)-1]++;
		else d.pb(1);
	}
}
void output() {
	int sum=0;
	int let=get();
	for (int i=0;i<sz(d);i++) {
		sum+=d[i];
		for (int j=0;j<d[i];j++) {
			printf("%c", let?'B':'A');
		}
		let^=1;
	}
	printf("\n");
	assert(sum==n);
}
int main() {
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	if (n==1) {
		if (k%2) {
			if (s[0]=='A') printf("B\n");
			else printf("A\n");
		} else {
			if (s[0]=='A') printf("A\n");
			else printf("B\n");
		}
		return 0;
	}

	
	int cur=1;
	char v=s[0];
	for (int i=1;i<n;i++) {
		if (s[i]==v) cur++;
		else {
			d.pb(cur);
			cur=1;
			v=s[i];
		}
	}
	d.pb(cur);
	h=(s[0]=='B');
	for (int kk=0;kk<min(k,1000000);kk++) {
		if (get()==0) {
			if (d[0]==1) {
				if (sz(d)==1) {
					put(1);
				} else {
					d.pop_front();
					++d[0];
					put(1);
				}
			} else {
				--d[0];
				d.push_front(1);
				put(1);
			}
		} else {
			if (d[0]==1) {
				if (sz(d)==1) {
					put(0);
				} else {
					d.pop_front();
					put(0);
					flip^=1;
					pad();
				}
			} else {
				--d[0];
				flip^=1;
				pad();
			}
		}
	}
	if (k>1000000) {
		if (sz(d)==n) {
			if (get()==1) {
				for (int i=0;i<n;i++) {
					printf("%c", (i%2)?'A':'B');
				}
				printf("\n");
			} else {
				if (k%2) {
					for (int i=0;i<n;i++) {
						if (i==0) printf("B");
						else printf("%c", (i%2)?'B':'A');
					}
					printf("\n");
				} else {
					for (int i=0;i<n;i++) {
						 printf("%c", (i%2)?'B':'A');
					}
					printf("\n");
				}
			}
		} else {
			if (k%2) {
				for (int i=0;i<n;i++) {
					 printf("%c", (i%2)?'B':'A');
				}
				printf("\n");
			} else {
				for (int i=0;i<n;i++) {
						if (i==0) printf("B");
						else printf("%c", (i%2)?'B':'A');
					}
					printf("\n");
			}
			
		}
	} else output();
}

Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
	int money;
	int coin_500;
	int coin_5;
	int happiness = 0;

	scanf("%d",&money);
	coin_500 = (int)(money / 500);
	coin_5 = (int)((money - coin_500 * 500) / 5);
	happiness = coin_500 * 1000 + coin_5 * 5;
	printf("%d\n",happiness);
}


Measured memory_bytes: 128
// AOJ 1335 "Equal Sum Sets" (ICPCアジア地区予選 2013 会津大会 Problem A)
import java.util.Scanner;

public class Main {
    static int n;
    static int k;
    static int s;
    static int count;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            n = sc.nextInt();
            k = sc.nextInt();
            s = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            count = 0;
            dfs(0, 0, 1);
            System.out.println(count);
        }
    }
    
    public static void dfs(int sum, int c, int i) {
        if (c == k) {
            if (sum == s) {
                count++;
            }
            return;
        }
        if (i > n || sum > s) {
            return;
        }
        
        dfs(sum, c, i + 1);
        dfs(sum + i, c + 1, i + 1);
    }
}

Measured memory_bytes: 20600
use std::cmp;
use std::io;

fn main() {
    let n = read_one::<usize>();
    let mut vec = Vec::new();
    for _ in 0..n {
        let (x, y, h) = {
            let i = read::<isize>();
            (i[0], i[1], i[2])
        };
        vec.push((x, y, h));
    }

    // avoid x == y == 0
    vec.sort_by_key(|v| v.2);
    vec.reverse();

    for x in 0..101 { for y in 0..101 {
        let h = (x - vec[0].0).abs() + (y - vec[0].1).abs() + vec[0].2;
        if vec.iter()
            .all(|&(a, b, c)| c == cmp::max(h - (x - a).abs() - (y - b).abs(), 0))
        {
            println!("{} {} {}", x, y, h);
            return;
        }
    }}
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define n1 4
#define n2 16
#define LIMIT 46
struct puzzle{
  int row[n2];
  int x,y;
  int MD;
};
int MDS[n2][n2];
 int dx[4]={0,-1,0,1};
 int dy[4]={1,0,-1,0};
int limit,path[LIMIT];
puzzle pstate;
int getallmd(puzzle p){
  int sum=0;
  for(int i=0;i<n2;i++)
    if(p.row[i]!=n2)sum+=MDS[i][p.row[i]-1];
  return sum;
}

bool dfs(int depth, int prev){
  if(pstate.MD==0)return true;
  if(depth+pstate.MD>limit)return false;
  int sx=pstate.x,sy=pstate.y;
  puzzle tmp;
  for(int i=0;i<4;i++){
    int tx=sx+dx[i];
    int ty=sy+dy[i];
    if(tx<0||ty<0||tx>=n1||ty>=n1)continue;
    if((int)(max(prev,i)-min(prev,i))==2)continue;
    tmp=pstate;
    pstate.MD-=MDS[tx*n1+ty][pstate.row[tx*n1+ty]-1];
    pstate.MD+=MDS[sx*n1+sy][pstate.row[tx*n1+ty]-1];
    swap(pstate.row[tx*n1+ty],pstate.row[sx*n1+sy]);
    pstate.x=tx;
    pstate.y=ty;
    //cout<<"finish; " <<i<<endl;
    if(dfs(depth+1,i))return true;
    pstate=tmp;
  }
  return false;
}
void findans(puzzle fp){
  fp.MD=getallmd(fp);
  for(limit=fp.MD;limit<=LIMIT;limit++){
    pstate=fp;
    if(dfs(0,-100))return;
  }
}

int main(){
  puzzle p;
  for(int i=0;i<n2;i++){
    cin>>p.row[i];
    if(p.row[i]==0){
      p.row[i]=n2;
      p.x=i/n1;
      p.y=i%n1;
    }
    for(int j=0;j<n2;j++)
      MDS[i][j]=abs(i/n1-j/n1)+abs(i%n1-j%n1);
  }
  findans(p);
  cout<<limit<<endl;


  return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>

#define MAX_M 100
#define MAX_N 1000000
#define min(a,b) (a < b ? a : b)

void insertionSort(int*,int,int,int*);
void shellSort(int*,int);
void print(int*,int*,int,int,int);

int main(){
  int n,A[MAX_N],i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  shellSort(A,n);
  return 0;
}

void insertionSort(int *A,int n,int g,int *cnt){
  int i,j,v;
  for(i = g ; i < n ; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      (*cnt)++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A,int n){
  int G[MAX_M],i,m = 1,cnt = 0;
  
  while(m*4+1 < n){ m = m*4+1; }
  for(i = 0 ; m > 0 ; m /= 4,i++){
    G[i] = m;
  }
  m = min(i,MAX_M);
  for(i = 0 ; i < m ; i++){
    insertionSort(A,n,G[i],&cnt);
  }
  print(A,G,n,m,cnt);
}

void print(int *A,int *G,int n,int m,int cnt){
  int i;
  printf("%d\n",m);
  for(i = 0 ; i < m ; i++){
    printf("%d%c",G[i],(i < m-1 ? ' ' : '\n'));
  }
  printf("%d\n",cnt);
  for(i = 0 ; i < n ; i++){
    printf("%d\n",A[i]);
  }
}

Measured memory_bytes: 4504
from itertools import groupby

R = lambda: map(int, input().split())
n, k = R()
a = list(R())
w = [0] * n

def merge(b, e):
    mid = b + (e - b) // 2
    in1, in2 = b, mid
    out = 0
    r = 0
    while in1 < mid and in2 < e:
        if a[in1] <= a[in2]:
            w[out] = a[in1]
            in1 += 1
        else:
            r += mid - in1
            w[out] = a[in2]
            in2 += 1
        out += 1
    a[e - mid + in1: e] = a[in1: mid]
    a[b: b + out] = w[:out]
    return r        
    
def mergesort(b, e):
    if e - b < 2:
        return 0
    mid = b + (e - b) // 2
    return mergesort(b, mid) + mergesort(mid, e) + merge(b, e)


r = k * mergesort(0, n)
c = n * (n - 1) // 2
for _, g in groupby(a):
    x = sum(1 for _ in g)
    c -= x * (x - 1) // 2
print((r + c * k * (k - 1) // 2) % (10**9 + 7))


Measured memory_bytes: 3188
#include <stdio.h>

int x = 1;
int y = 1;

int main() {
    while(x != 0 || y != 0){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0){
            exit(0);
        } else {
            if(x > y){
                printf("%d %d\n", y, x);
            } else {
                printf("%d %d\n", x, y);
            }
        }

    }
}


Measured memory_bytes: 2128
N = int(input())
L = [input() for i in range(N)]
for l in L:
  t, x, y = map(int, l.split(" "))
  flag_t = t %2 == 0
  flag_xy = (x+y) % 2 == 0
  if flag_t == flag_xy and (x+y) <= t:
    continue
  else:
    print("No")
    exit(0)
print("Yes")


Measured memory_bytes: 10268
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using pll = pair<long long, long long>;

int main() {
    int N, M; cin >> N >> M;
    vector<pll> v;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        v.push_back({a, 1});
    }
    for (int i = 0; i < M; ++i) {
        int b, c; cin >> b >> c;
        v.push_back({c, b});
    }
    sort(v.begin(), v.end(), greater<pll>());

    long long num = 0;
    long long res = 0;
    for (auto p : v) {
        if (num + p.second <= N) {
            res += p.first * p.second;
            num += p.second;
        }
        else {
            res += p.first * (N - num);
            num = N;
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int n,d;
	cin >> n >> d;
	double X[n][d];
	int cnt=0;
	double ans=0;
	rep(i,0,n)rep(j,0,d) cin >> X[i][j];
	rep(i,0,n){
		rep(j,i+1,n){
			ans = 0;
			rep(k,0,d){
				ans += pow(X[i][k]-X[j][k],2);
			}
			ans = sqrt(ans);
			if(ceil(ans) == floor(ans)) cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  int i,j,l,m,z[1000],a,b;
 
  while(1){
      scanf("%d%d",&l,&m);
      if(l==0&&m==0) break;
      for(i=0;i<=l-1;i++){
      scanf("%d",&z[i]);
      }
      b=0;
      for(i=0;i<=l-1;i++){
	for(j=i+1;j<=l-1;j++){
          a=z[i]+z[j];
          if(a<=m && b<a) b=a;
	}
      }
      if(b==0) printf("NONE\n");
      else printf("%d\n",b);
  }
  return 0;
}




Measured memory_bytes: 2044
MOD = 10 ** 9 + 7
 
N = int(input())
a = list(map(int,input().split()))
 
ans = 0
ans = sum(a) * sum(a) % MOD
ans -= sum(map(lambda x:x * x,a)) % MOD
ans %= MOD
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + MOD) // 2)

Measured memory_bytes: 94236
#include <stdio.h>
int main(void)
{
	int a,b,n,s,f,i,j;
	j=0;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&s,&f);
		if(s+1<=a && f-1>=a || s+1<=b && f-1>=b){
			j=j+1;
		}
		if(a+1<=s && b-1>=s || a+1<=f && b-1>=f){
			j=j+1;
		}
		if(s==a && f==b){
			j=j+1;
		}
	}
	if(j==0){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    ll ans=0,g=0,a=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R'&&g==0)
        {
            a++;
            ans=max(ans,a);
            g=1;
        }
        else if(s[i]=='R'&&g==1)
        {
            a++;
            ans=max(ans,a);
        }
        else if(s[i]=='S'&&g==1)
        {
            g=0;
            ans=max(ans,a);
            a=0;
        }
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

ll S;

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

  cin>>S;
  if(S==1e18){
    printf("0 0 1000000000 0 0 1000000000\n");
    return 0;
  }
  ll lb=0,ub=1e9;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(mid*mid<=S) lb=mid;
    else ub=mid;
  }
  ll bd=ub*ub-S;
  vector<ll> ds=divisor(bd);

  rep(i,ds.size()){
    if(ds[i]<=1e9&&bd/ds[i]<=1e9){
      printf("0 0 %lld %lld %lld %lld\n", ub,ds[i],bd/ds[i],ub);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll n,m=100;

int main() {
	qr(n);
	for(int i=0;	;i++) {
		if(m>=n) {pr2(i),exit(0);}
		m=m*1.01;
	}
	return 0;
}


Measured memory_bytes: 3652
def manageHotel(l, b, f, r, v):
	l[b-1][f-1][r-1] += v
	return l

build = list()
for i in range(4):
	floor = list()
	for j in range(3):
		room = list()
		for k in range(10):
			room.append(0)
		floor.append(room)
	build.append(floor)
i = int(input())
while i > 0:
	data = [int(x) for x in input().split()]
	build = manageHotel(build, data[0], data[1], data[2], data[3])
	i -= 1
for b in range(len(build)):
	for f in range(len(build[b])):
		for r in range(len(build[b][f])):
			print(' %d' % (build[b][f][r]), end='')
		print()
	if b < len(build) - 1:
		print('#' * 20)


Measured memory_bytes: 5632
// abc.151.C - Welcome to AtCoder

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

int main( void ) {

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

    int  wa[ 100005 ];
    bool ac[ 100005 ];

    for( int i = 1; i <= n; i++ ) {
        wa[ i ] = 0;
        ac[ i ] = false;
    }
    int ans_ac = 0, ans_wa = 0;

    while(m>0){
        int p;
        string s;
        cin >> p >> s;

        if( s == "WA" ) wa[ p ]++;

		if(s == "AC"){
            //すでにacならば次へ
			if( ac[ p ] ) continue;
            //p番目をtrueに
			ac[ p ] = true;
            ans_ac++;
            ans_wa += wa[ p ];
        }
        m--;
    }
    cout << ans_ac << " " << ans_wa << endl;
    return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  vector<string> wday = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string S;
  cin >> S;
  auto it = find(wday.begin(), wday.end(), S);
  int d = distance(wday.begin(), it);
  cout << 7 - d << endl;

  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,D,X;
int A[101];
int main() {

	int total=0;
	cin>>N>>D>>X;
	for(int i=0;i<N;i++){
		cin>>A[i];
		int S=A[i];
		for(int j=0;j<D;j++){
			if(S*j+1<=D)total++;
		}
	}



	cout<<total+X<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())
    AB = A+B
    cost = 0
    if 2*C <= AB:
        if X <= Y:
            return X * 2 * C + (Y-X) * min(2*C, B)
        else:
            return Y * 2 * C + (X-Y) * min(2*C, A)
    else:
        return X * A + Y * B

if __name__ == '__main__':
    print(main())


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

int main(){
    int h,w;
    char a[100][100];
    cin>>h>>w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<h+2;++i){
        if(i==0||i==h+1){
            for(int j=0;j<w+2;++j){
                cout<<'#';
            }
        }
        else{
            for(int j=0;j<w+2;++j){
                if(j==0||j==w+1){
                    cout<<'#';
                }
                else{
                    cout<<a[i-1][j-1];
                }
            }
        }
    cout<<endl;
    }
}


Measured memory_bytes: 3080
from sys import stdin
n = int(stdin.readline().rstrip())

data = [stdin.readline().rstrip() for _ in range(n)]

ac, wa, tle, re = 0,0,0,0

for i in data:
    if i =='AC':
        ac += 1
    elif i == 'WA':
        wa += 1
    elif i == 'TLE':
        tle += 1
    else:
        re += 1

print("AC x "+ str(ac))
print("WA x "+ str(wa))
print("TLE x "+ str(tle))
print("RE x "+ str(re))

Measured memory_bytes: 16244
#pragma GCC optimize("O3") 

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

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  string s;
  cin >> s;
  ll ans = 0, cnt = 0;
  f(i, 0, s.length())
  {
    while(s[i] == 'S')
      i += 1;
    while(s[i] == 'R')
    	cnt += 1, i += 1;
    
    ans = max(cnt, ans);
    cnt = 0;
  }
  cout << ans << endl;
}

int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    vector<int> A(1, X);
    vector<int> B(1, Y);
    vector<int> C(1, Z);
    
    swap(A, B);
    swap(A, C);

    cout << A.at(0) << " "<< B.at(0) << " "<< C.at(0) << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	int x[N],y[M];
	for(int i = 0; i < N; i++)cin >> x[i];
	for(int i = 0; i < M; i++)cin >> y[i];
	sort(x, x + N);
	sort(y, y + M);
	if(X < Y && x[N - 1] < y[0] && X < y[0] && x[N - 1] < Y)cout << "No War" << endl;
	else cout << "War" << endl;
}

Measured memory_bytes: 256
N,C=map(int, input().split())
D=[list(map(int, input().split())) for _ in range(C)]
c=[list(map(int, input().split())) for _ in range(N)]

from collections import Counter
t=[Counter([c[i][j] for i in range(N) for j in range(N) if (i+j)%3==m]) for m in range(3)]

ans = 10**9
for i in range(C):
    for j in range(C):
        if i==j: continue
        for k in range(C):
            if i==k or j==k: continue
            d = 0
            for before in range(C):
                d += D[before][i] * t[0][before+1]
                d += D[before][j] * t[1][before+1]
                d += D[before][k] * t[2][before+1]
            ans = min(ans, d)
print(ans)

Measured memory_bytes: 56028
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A % 2 != 0 && B % 2 != 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N, K, d, x, ans;
    cin >> N >> K;
    int s[N];
    ans = 0;
    for(int i = 0; i < N; i++){
        s[i] = 0;
    }
    
    for(int i = 0; i < K; i++){
        cin >> d;
        for(int z = 0; z < d; z++){
            cin >> x;
            s[x - 1] += 1;
        }
        
    }

    for(int i = 0; i < N; i++){
        //cout << s[i] << endl;
        if(s[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;

int main()
{
    int N, t;
    double Y, b, r;
    while (cin >> N, N) {
        cin >> Y;
        int mx_n = -1;
        double maxi = 0;
        while (N--) {
            cin >> b >> r >> t;
            
            double c = (t == 1 ? 1 + Y * r / 100 : pow(1 + r / 100, Y));        
            if (maxi < c) {
                maxi = c;
                mx_n = b;
            }
        }
        cout << mx_n << endl;
    }
    return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;
            var time = int.Parse(Console.ReadLine());
            var data = Console.ReadLine().Split(' ');
            var nums = new int[time];
            for(int i = 0; i < time; i++)
            {
                nums[i] = int.Parse(data[i]);
            }
            var tmp = nums.Average();
            int ave = (int)Math.Round(tmp, MidpointRounding.AwayFromZero);
            for(int i = 0; i < time; i++)
            {
                result += (ave - nums[i]) * (ave - nums[i]);
            }
            Console.WriteLine(result);
            Console.ReadKey();
        }
    }
}


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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    int n,k;
    cin>>n>>k;
    vector<int> v;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<n-k;i++)
    {
        sum+=v[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2420
from collections import deque


def main():
    from sys import stdin
    readline = stdin.readline

    from builtins import max, min, range

    INF = 10 ** 6

    H, W = map(int, readline().split())
    Ch, Cw = map(lambda x: int(x) - 1, readline().split())
    Dh, Dw = map(lambda x: int(x) - 1, readline().split())
    S = [readline()[:-1] for _ in range(H)]

    t = [[INF] * W for _ in range(H)]
    for h in range(H):
        th = t[h]
        Sh = S[h]
        for w in range(W):
            if Sh[w] == '#':
                th[w] = -1

    t[Ch][Cw] = 0
    q = deque([(Ch, Cw)])
    a = 0
    while q:
        warpq = []
        while q:
            h, w = q.popleft()
            warpq.append((h, w))
            if h - 1 >= 0 and t[h - 1][w] > a:
                q.append((h - 1, w))
                t[h - 1][w] = a
            if h + 1 < H and t[h + 1][w] > a:
                q.append((h + 1, w))
                t[h + 1][w] = a
            if w - 1 >= 0 and t[h][w - 1] > a:
                q.append((h, w - 1))
                t[h][w - 1] = a
            if w + 1 < W and t[h][w + 1] > a:
                q.append((h, w + 1))
                t[h][w + 1] = a

        if t[Dh][Dw] != INF:
            break

        a += 1
        for h, w in warpq:
            for i in range(max(0, h - 2), min(H, h + 3)):
                ti = t[i]
                for j in range(max(0, w - 2), min(W, w + 3)):
                    if ti[j] > a:
                        ti[j] = a
                        q.append((i, j))

    if t[Dh][Dw] == INF:
        print(-1)
    else:
        print(t[Dh][Dw])


main()

Measured memory_bytes: 23452
# -*- coding: utf-8 -*-

N = int(input())
S = input()

x = 0
max_x = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    elif S[i] == "D":
        x -= 1
    max_x = max(x, max_x)
print(max_x)

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

int main(){
	int a,b,sum=0;
	cin >> a >> b;
	int ar[a];
	for(int i=0; i<a; i++){
		cin >> ar[i];
	}
	sort(ar,ar+a);
	for(int i=a-1; b>0; i--){
		sum+=ar[i];
		b--;
	}
	cout << sum <<endl;
	return 0;
}

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

int main(){
  long long W,H,x,y; cin>>W>>H>>x>>y;
  
  double S=W/2.0*H;
  
  cout<<S<<" ";
  
  if(x==W/2.0 && y==H/2.0)
    cout<<1;
  else
    cout<<0;
}

Measured memory_bytes: 256
import java.util.*;

class Item {
    int value;
    int weight;

    public Item(int value, int weight) {
        this.value = value;
        this.weight = weight;
    }
}

class Main {
    private static final int DIAGONAL = 1; // i is selected
    private static final int TOP = 0; // i is NOT selected

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nw = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nw[0]);
        int w = Integer.parseInt(nw[1]);

        Item[] items = new Item[n+1];
        for (int i = 1; i <= n; i++) {
            String[] vw = scanner.nextLine().split(" ", 2);
            int value = Integer.parseInt(vw[0]);
            int weight = Integer.parseInt(vw[1]);
            items[i] = new Item(value, weight);
        }

        int maxValue = knapsackMaxValue(n, w, items);
        System.out.println(maxValue);
    }

    private static int knapsackMaxValue(int n, int weight, Item[] items) {
        int[][] maxValueC = new int[n+1][weight+1];
        int[][] selectedG = new int[n+1][weight+1];

        for (int w = 0; w <= weight; w++) {
            maxValueC[0][w] = 0;
            selectedG[0][w] = DIAGONAL;
        }
        for (int i = 1; i <= n; i++) maxValueC[i][0] = 0;

        for (int i = 1; i <= n; i++) {
            for (int w = 1; w <= weight; w++) {
                maxValueC[i][w] = maxValueC[i - 1][w];
                selectedG[i][w] = TOP;
                if (items[i].weight > w) continue;

                if (items[i].value + maxValueC[i - 1][w - items[i].weight] > maxValueC[i - 1][w]) {
                    maxValueC[i][w] = items[i].value + maxValueC[i - 1][w - items[i].weight];
                    selectedG[i][w] = DIAGONAL;
                }
            }
        }

        return maxValueC[n][weight];
    }
}



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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin >> n;
  vector<int> x(n);
  uset<int> se;
  arep(i, x) cin >> i;
  int cnt = x[0];
  rep(i, 0, n) cnt = gcd(cnt, x[i]);
  if (cnt != 1) {
    cout << "not coprime\n";
    return 0;
  }

  bool jud = true;
  rep(i, 0, n) {
    for (int j = 2; j * j <= x[i] && jud == true; ++j) {
      if (x[i] % j == 0) {
        while (x[i] % j == 0) x[i] /= j;
        if (se.find(j) != se.end())
          jud = false;
        else
          se.insert(j);
      }
    }
    if (x[i] != 1) {
      if (se.find(x[i]) != se.end())
        jud = false;
      else
        se.insert(x[i]);
    }
  }

  if (jud == true)
    cout << "pairwise coprime\n";
  else
    cout << "setwise coprime\n";
  return 0;
}

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

using namespace std;
vector<int>v[100009];
int n,m,x,y,dp[100009];
int bt(int s)
{
    if(dp[s]!=-1)return dp[s];
    int &ret=dp[s]=0;
    for(int i=0;i<v[s].size();i++)
    {
        ret=max(ret,bt(v[s][i])+1);
    }
    return ret;
}
int main()
{
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        v[x].push_back(y);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans=max(ans,bt(i));
    }
    cout<<ans;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

int gcd(int a, int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (a < b) swap(a,b);
    if (b == 0) return a;
    return a%b == 0 ? b : gcd(b, a%b);
}
int lcm(int a, int b) { return a*b/gcd(a,b);}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    vector<int> left(N+1);
    vector<int> right(N+1);
    left[0] = A[0];
    for (int i=0;i<N;i++){
        left[i+1] = gcd(left[i],A[i]);
    }
    right[N] = A[N-1];
    for (int i=N;i>=1;i--){
        right[i-1] = gcd(right[i],A[i-1]);
    }
    int ans = -1;
    for (int i=0;i<N;i++){
        int res;
        if (i==0){
            res = right[i+1];
        } else if (i==N-1){
            res = left[i];
        } else {
            res = gcd(left[i],right[i+1]);
        }
        if (ans < res) ans = res;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4492
#include <stdio.h>

int main(){
	int a,b,c,d,e,f;
	float x,y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
		x = (float)(c * e - b * f) / (float)(a * e - b * d);
		y = (float)(a * f - c * d) / (float)(a * e - b * d);
		if(x == -0.0) x = 0.0;
		if(y == -0.0) y = 0.0;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int n;
vector<int> a,b,c;

int main(){
  cin >> n;
  a.resize(n); b.resize(n); c.resize(n);
  
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  
  ll ans = 0;
  
  for(auto i:b){
    ll num_a = lower_bound(a.begin(),a.end(),i) - a.begin();
    ll num_c = n - (upper_bound(c.begin(),c.end(),i) - c.begin());
    ans += num_a * num_c;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // 入力
    int x, n;
    cin >> x >> n;
    vector<int> d(102);
    rep (i, n) {
        int p;
        cin >> p;
        d[p] = 1;
    }
    P ans(99999, -1); //(差分、その数字)
    for (int i = 0; i <= 101; ++i) {
        if (d[i] == 1) continue;
        int dif = abs(x-i);
        ans = min(ans, P(dif, i)); // pairの比較
    }

    cout << ans.second << endl;

    return 0;
}

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

using namespace std;

#define int long long

int N, W;
int w[101], v[101];

signed main()
{
	cin >> N >> W;

	for (int i = 1; i <= N; ++i) {
		cin >> w[i] >> v[i];
	}

	vector<int> dp(W+5), tmp;

	for (int i = 1; i <= N; ++i) {
		tmp = vector<int>(W+5);
		
		for (int j = W; j >= 0; --j) {
			tmp[j] = dp[j];
			if (j + w[i] <= W) {
				tmp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
			}
		}

		dp = tmp;
	}

	int ans = 0;
	for (int i = 0; i <= W; ++i) ans = max(ans, dp[i]);

	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int n;
int dp[(1 << 21)];
int a[21][21];
int solve(int msk){
  if(msk == (1 << n) - 1)
    return 1;
  int in = __builtin_popcount(msk);
//  cout << msk << ' ' << in << endl;
  int& res = dp[msk];
  if(res != -1)
    return res;
  res = 0;
  for(int i = 0;i < n;i++){
    if(!((1 << i) & msk) && a[in][i]){
      res = (1ll * res + solve(msk | (1 << i))) % MOD;
    }
  }
  return res;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      cin >> a[i][j];
  cout << solve(0);
  return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <algorithm>
#include <functional>
#define MOD 1000000007
using namespace std;
int main() {
    int n, k, Minus[200000], mSize = 0, Plus[200000], pSize = 0;
    scanf("%i%i", &n, &k);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%i", &a);
        if (a < 0) Minus[mSize++] = -a;
        else Plus[pSize++] = a;
    }
    sort(Plus, Plus + pSize, greater<int>());
    sort(Minus, Minus + mSize, greater<int>());

    int curK = k, i_m = 0, i_p = 0;
    long long prod = 1;
    if (k & 1) {
        if (pSize) {
            prod = Plus[i_p++];
            curK--;
        }
        else {
            /// choose the least k Minuses

            for (int i = mSize - 1; i >= mSize - k; i--) {
                prod = (prod * (-Minus[i]) % MOD + MOD) % MOD;
            }
            printf("%lli", prod);
            return 0;
        }
    }
    while (curK) {
        long long loc1 = -1, loc2 = -1;
        if (pSize - i_p > 1)
            loc1 = Plus[i_p] * 1ll * Plus[i_p + 1];
        if (mSize - i_m > 1)
            loc2 = Minus[i_m] * 1ll * Minus[i_m + 1];

        if (loc1 == -1 && loc2 == -1) {
            /// 1 plus and 1 minus and curK == 2 ==> k == n
            prod = (((prod * Plus[i_p++]) % MOD * (-Minus[i_m++])) % MOD + MOD) % MOD;
        }
        else if (loc1 < loc2) {
            prod = (prod * (loc2 % MOD)) % MOD;
            i_m += 2;
        }
        else {
            prod = (prod * (loc1 % MOD)) % MOD;
            i_p += 2;
        }
        curK -= 2;
    }
    printf("%lli", prod);
}


Measured memory_bytes: 2496
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair

using namespace std;
const int N = 100000;
const ll MOD = 1e9 + 7;

ll binPow(ll a, ll n) {
    if (n == 1) return a;
    if (n % 2 == 1) return (a * binPow(a, n - 1)) % MOD;
    ll c = binPow(a, n / 2) % MOD;
    return (c * c)%MOD;
}

ll nCr(ll n, ll r) {
    ll Y = 1ll; ll X = 1ll;
    for (ll i = 1; i <= r; i++) {
        Y = (Y * i) % MOD;
        X = (X * (n - i + 1)) % MOD;
    }
    return (X * binPow(Y, MOD - 2)) % MOD;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll total = binPow(2, n) - 1ll;
    total = (total - nCr(n, a) + MOD) % MOD;
    total = (total - nCr(n, b) + MOD) % MOD;
    cout << total;
}



Measured memory_bytes: 256
A,B,C=map(int,input().split())
K=int(input())
while A>=B:
    K-=1
    B*=2
    if K<0:
        print("No")
        exit()
while B>=C:
    K-=1
    C*=2
    if K<0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n;
  cin >> n;
  cout << (n%2==0?n:2*n) << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3636
/*  4_3
    Y_Aizaki    */

#include <stdio.h>

/* プロトタイプ宣言 */
int snow(int west_over, int east_over);

int main(void){
    int west, east;
    scanf("%d%d", &west, &east);
    // 西側の塔の露出している高さ、東側の塔の露出している高さ

    int snowfall = snow(west, east);
    // 積雪量
    printf("%d\n", snowfall);

    return 0;
}

int snow(int west_over, int east_over){
    // 露出している高さを引数にとる
    int east_index = east_over - west_over;
    // 東側の塔のindexを割り出す

    int snowfall = (1 + east_index) * east_index / 2 - east_over;

    return snowfall;
}

Measured memory_bytes: 128
implicit none
integer,dimension(5)::a
integer i
integer:: min1=10
integer:: sum=0

do i=1,5
read(5,*) a(i)

if(mod(a(i),10).eq.0) then
sum=sum+a(i)
else
sum=sum+(a(i)/10+1)*10
if(mod(a(i),10).lt.min1) then
min1=mod(a(i),10)
endif
endif

enddo

if(min1.eq.10) then
write(6,*)sum
else
write(6,*)sum-10+min1
endif

end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n, m;
    cin >> n >> m;
    forn (i, n)
        forn (j, m) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << char('A' + j) << i + 1 << '\n';
            }
        }
}


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

int main()
{
    int n;
    vector<char> tf;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        char c;
        cin >> c;
        tf.push_back(c);
    }

    //bool clear = false;
    vector< vector<char> > zoo;
    vector<char> ss(n);
    ss.at(0) = 'S';
    ss.at(1) = 'S';
    zoo.push_back(ss);
    vector<char> sw(n);
    sw.at(0) = 'S';
    sw.at(1) = 'W';
    zoo.push_back(sw);
    vector<char> ws(n);
    ws.at(0) = 'W';
    ws.at(1) = 'S';
    zoo.push_back(ws);
    vector<char> ww(n);
    ww.at(0) = 'W';
    ww.at(1) = 'W';
    zoo.push_back(ww);
    int res = -1;
    
    for(int i = 0; i < 4; ++i)
    {
        vector<char> now = zoo.at(i);
        for(int j = 1; j < n - 1; ++j)
        {
            char ani = now.at(j);
            char pre = now.at(j-1);
            int a = ani == 'S'? 1 :-1;
            int b = tf.at(j) == 'o'? 1 :-1;
            //cout << a << " " << b << endl;

            if(a * b < 0)
            {
                if(pre == 'S')
                {
                    pre = 'W';
                }
                else
                {
                    pre = 'S';
                }
            }
            now.at(j+1) = pre;
        }

        int a = now.at(n-1) == 'S'? 1 :-1;
        int b = tf.at(n-1) == 'o'? 1 :-1;
        int c = now.at(0) == 'S'? 1 :-1;
        int d = tf.at(0) == 'o'? 1 :-1;

        bool clear = false;
        if((a * b > 0 && now.at(n-2) == now.at(0)) || (a * b < 0 && now.at(n-2) != now.at(0)))
        {
            clear = true;
        }
        
        if( (c * d > 0 && now.at(n-1) == now.at(1)) || (c * d < 0 && now.at(n-1) != now.at(1)) )
        {
            clear &= true;
        }
        else
        {
            clear = false;
        }

        if( clear )
        {
            res = 1;
            for(int j = 0; j < n; ++j)
            {
                cout << now.at(j);
            }
            cout << endl;
            break;
        }
    }

    if(res == -1)
    {
        cout << res << endl;
    }
}

Measured memory_bytes: 1280
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :x, :y, :s ,:t, :k

  def initialize
    @n = gets.to_s.to_i
    @a = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    ans = 0
    0.upto(n-2) do |i|
      (i+1).upto(n-1) do |j|
        ans += a[i] * a[j]
      end
    end
    ans
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14368
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long n, s;
    cin>>n>>s;

    for (long long b=2; b*b<=n; b++)
    {
        long long t = n;
        long long a = 0LL;
        while (t>0)
            a += t%b,
            t /= b;
        if (a==s)
        {
            cout<<b<<endl;
            return 0;
        }
    }

    long long inf = 1000000000000LL;
    long long ans = inf;

    if (n==s)
        ans = s+1;

    for (long long d=1; d*d<=n; d++)
    {
        long long r = s - d;
        long long b = (n-r)/d;
        if (0<=r && r<b && 2<=b && n/b+n%b==s && n/b<b)
            ans = min(ans, b);
    }

    cout<<(ans<inf ? ans : -1)<<endl;
}


Measured memory_bytes: 256
/* ----------------------------
 * ABC 90 C
 * ---------------------------- */
#include <iostream>
using namespace std;

int main(){
	// 10^9 までだから int だとダメ(最大 n*m <= 10^18)
	// INT_MAX = 2'147'483'647
//	int n, m;
	long n, m;
	cin >> n >> m;
	if(n == 1 && m == 1) cout << 1 << endl;
	else if(n == 1) cout << m - 2 << endl;
	else if(m == 1) cout << n - 2 << endl;
	else cout << (n - 2) * (m - 2) << endl;
//	int ans = (n == 1)?
//					(m == 1)? 1
//					: m - 2
//				: (m == 1)? n - 2
//				: (n-2)*(m-2);
//	cout << ans << endl;
	return 0;
}
// それ自身、上下左右斜めの９マスに範囲内のマスが偶数個あれば最初の状態
// 角や辺にあるマスは表のまま
//
// o o o
// o x o
// o o o
//
// 幅や高さが 3 未満のとき
//
// o x o // 幅か高さが 1 のとき 両端だけが表のまま -> m-2
// o o   // 幅 2 高さ 1 のとき m-2 をそのまま使える
// x     // 両方 1 のとき 固定値 1
//
// o o o // 幅か高さが 2 のとき 0
// o o o // -> (m-2)*(n-2) のままでよい
//
//


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, a[200009], b[200009], ans = 0; vector<int>p[30];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i <= 29; i++) {
		p[i].resize(N);
		for (int j = 0; j < N; j++) { p[i][j] = b[j] % (1 << i); }
		sort(p[i].begin(), p[i].end());
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j <= 28; j++) {
			sum = (a[i] & ((2 << j) - 1));
			int LL = (3 << j) - sum; LL %= (2 << j);
			int RR = LL + (1 << j);
			if (RR < (2 << j)) {
				int pos1 = lower_bound(p[j + 1].begin(), p[j + 1].end(), LL) - p[j + 1].begin();
				int pos2 = lower_bound(p[j + 1].begin(), p[j + 1].end(), RR) - p[j + 1].begin();
				if ((pos2 - pos1) % 2 == 1) {
					ans ^= (1 << j);
				}
			}
			else {
				int pos1 = lower_bound(p[j + 1].begin(), p[j + 1].end(), RR - (2 << j)) - p[j + 1].begin();
				int pos2 = lower_bound(p[j + 1].begin(), p[j + 1].end(), LL) - p[j + 1].begin();
				if ((N - (pos2 - pos1)) % 2 == 1) {
					ans ^= (1 << j);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b;cin>>a>>b;
    int n=b-a;//n-1本目とn本目の間とわかる
    int ans=-b;
    for(int i=1;i<=n;i++) ans+=i;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

int N, x, y, ans = 0;
vector<int> g[1<<20];
vector<pair<int,int> > vi;
map<pair<int,int>, int> uma;

void dfs(int s, int p, int c) {
  ans = max(ans, c);
  int mi = min(s, p);
  int mx = s + p - mi;
  uma[make_pair(mi, mx)] = c;

  int color = 1;
  for(auto x : g[s]) {
    if(x == p) continue;
    if(color == c) color++;
    dfs(x, s, color);
    color++;
  }
}

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

  cin >> N;
  for(int i = 0;i < N-1;i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    vi.push_back({x, y});
    uma[vi[i]] = 0;
  }

  dfs(1, -1, -1);

  cout << ans << endl;
  for(auto pi : vi) {
    cout << uma[pi] << endl;
  }

  return 0;
}


Measured memory_bytes: 35448