akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
	int n;
	cin>>n;

	string s;
	cin>>s;

	vector<int> cr(n,0),cg(n,0),cb(n,0);

	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			cr[i]++;
		}
		else if(s[i]=='B')
		{
			cb[i]++;
		}
		else
		{
			cg[i]++;
		}
		if(i!=0)
		{
			cr[i]+=cr[i-1];
			cg[i]+=cg[i-1];
			cb[i]+=cb[i-1];
		}	
	}
	int ans=0;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='R' and s[j]=='G')
			{
				int count=cb[n-1]-cb[j-1];
				if(j+j-i<n and s[j+j-i]=='B')
					count--;

				ans+=count;
			}	
		}
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='B' and s[j]=='G')
			{
				int count=cr[n-1]-cr[j-1];
				if(j+j-i<n and s[j+(j-i)]=='R')
					count--;

				ans+=count;
			}	
		}
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='R' and s[j]=='B')
			{
				int count=cg[n-1]-cg[j-1];
				if(j+j-i<n and s[j+j-i]=='G')
					count--;

				ans+=count;
			}	
		}
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='B' and s[j]=='R')
			{
				int count=cg[n-1]-cg[j-1];
				if(j+j-i<n and s[j+j-i]=='G')
					count--;

				ans+=count;
			}	
		}
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='G' and s[j]=='R')
			{
				int count=cb[n-1]-cb[j-1];
				if(j+j-i<n and s[j+j-i]=='B')
					count--;

				ans+=count;
			}	
		}
	}
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]=='G' and s[j]=='B')
			{
				int count=cr[n-1]-cr[j-1];
				if(j+j-i<n and s[j+j-i]=='R')
					count--;

				ans+=count;
			}	
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<string.h>
int a[10000000];
int main()
{
	  int n,m,k;
	 int i,u,o;
	 scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<=n;i++)
	{
		a[i]=m-k; 
	}
	  for(i=0;i<k;i++)
	  {
	  	scanf("%d",&u);
	  	a[u]++;
	  }
	 for(i=1;i<=n;i++)
	 {
	 	if(a[i]>0)
	 	printf("Yes\n");
	 	else
	 	printf("No\n");
	 }
	 printf("\n");
	 
}

Measured memory_bytes: 896
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    s = input()
    da = {"S":1,"W":-1}
    dq = {"o":1,"x":-1}
    rda = {1:"S",-1:"W"}
    kh = ("SS","WW","SW","WS")

    for i in kh:
        anim = i
        for j in s:
            anim += rda[da[anim[-1]]*dq[j]*da[anim[-2]]]
        if anim[-1] == anim[1] and anim[-2] == anim[0]:
            print(anim[1:-1:])
            return None

    print(-1)

    return None

if __name__ == '__main__':
    main()


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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  priority_queue<int, vector<int>, less<int>> p;
  priority_queue<int, vector<int>, less<int>> q;
  priority_queue<int, vector<int>, less<int>> r;
  rep(i, a) {
    int v;
    cin >> v;
    p.push(v);
  }
  rep(i, b) {
    int v;
    cin >> v;
    q.push(v);
  }
  rep(i, c) {
    int v;
    cin >> v;
    r.push(v);
  }

  priority_queue<int, vector<int>, less<int>> apples;
  rep(i, x) {
    apples.push(p.top());
    p.pop();
  }
  rep(i, y) {
    apples.push(q.top());
    q.pop();
  }
  rep(i, c) {
    apples.push(r.top());
    r.pop();
  }

  long long sum = 0;
  rep(i, x + y) {
    sum += apples.top();
    apples.pop();
  }

  cout << sum << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(), x.end()
using namespace std;
ll power(ll x, ll y,ll  m) 
{ 
    if (y == 0) 
        return 1; 
    ll  p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
ll modInverse(ll a, ll m) 
{ 
    ll g = __gcd(a, m); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    
    
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
        
              return power(a, m-2, m); 
    
} 

ll fact[1000];
void fac(ll m)
{
	ll i;
	fact[0]=1;
	for(i=1;i<1000;i++)
	{
		fact[i]=(i*fact[i-1])%m;
	}
}

ll comb(ll n,ll k,ll m)
{
	return(fact[n]*modInverse(fact[k],m)%m *modInverse(fact[n-k],m)%m)%m;
}
bool cmp(pair<ll,ll> a,pair<ll,ll>b)
{
	if(a.second==b.second)
	return a.first<b.first;
	return a.second>b.second;
}
void SieveOfEratosthenes(ll n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
     bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
void dfs(ll i,vector<ll> &visited,vector<vector<ll>> &adj)
{
	visited[i]=1;
	for(auto x:adj[i])
	{
		if(!visited[x])
		dfs(x,visited,adj);
	}
}
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int t;
  //cin>>t;
  t=1;

  while(t-- > 0) {
  	ll n,m;
  	cin>>n>>m;
  	ll i;
  	vector<vector<ll>>adj(n);
  	vector<ll>visited(n,0);
  	
  	for(i=0;i<m;i++)
  	{
  		ll u,v;
  		cin>>u>>v;
  		u--;
  		v--;
  		adj[u].push_back(v);
  			adj[v].push_back(u);
	  }
	  ll ans=0;
	  for(i=0;i<n;i++)
	  {
	  	if(!visited[i])
	  	{
	  		
		  
	  	dfs(i,visited,adj);
	  	ans++;
	  }
	  }
	  cout<<ans-1;
	  
}
return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;



int r,c; 
int sx,sy,gx,gy;

char maze[21][21];
int  dist[21][21];

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int bfs(){
  queue<P> que;
  rep(i,r){
    rep(j,c){
      dist[i][j]=INF;
    }
  }
  que.push(P(sy,sx));
  dist[sy][sx]=0;
  
  while(que.size()){
    P p=que.front(); que.pop();
    if(p.first==gy && p.second== gx) break;
    
    rep(i,4){
      int ny=p.first+dy[i], nx=p.second+dx[i];
      if(0<=nx && nx<c && 0<=ny && ny<r && maze[ny][nx]!='#' &&dist[ny][nx]==INF){
        que.push(P(ny,nx));
        dist[ny][nx]=dist[p.first][p.second]+1;
      }
    }
  }
  return dist[gy][gx];
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  cin>>r>>c;
  
  rep(i,r){
    rep(j,c){
      cin>>maze[i][j];
    }
  }
  vector<int>ans;
  rep(i,r){
    rep(j,c){
      rep(k,r){
        rep(l,c){
          sx=j;
          gx=l;
          sy=i;
          gy=k;
          if(maze[sy][sx]!='#' && maze[gy][gx]!='#'){
            if(!(sx==gx && sy==gy)){
              int num =bfs();
              ans.push_back(num);
            }
          }
        }
      }
    }
  }
  sort(ans.begin(),ans.end(),greater<int>());
  cout << ans[0] << endl;
  
}
  



Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, N, P);
	map<ll, ll> cnt;
	for(ll i = 2; i*i <= P;){
		if(P % i == 0){
			P /= i;
			++cnt[i];
		}else ++i;
	}
	if(P>1)
		++cnt[P];
	ll ans = 1;
	for(auto c : cnt){
		ll s = c.second;
		while(s >= N){
			ans *= c.first;
			s -= N;
		}
	}
	out(ans);
}



Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

from itertools import permutations
from math import sqrt

paths = list(permutations(range(N), N))
l = len(paths)
total = 0
for path in paths:
    tmp = 0
    x, y = xy[path[0]][0], xy[path[0]][1]
    for p in path[1:]:
        px, py = xy[p][0], xy[p][1]
        tmp += sqrt((px-x)**2 + (py-y)**2)
    total += tmp
print(total / l)

Measured memory_bytes: 74428
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def ff(n,k,p):
    s = set()
    for i in range(n-k+1):
        t = tuple(p[:i] + sorted(p[i:i+k]) + p[i+k:])
        s.add(t)

    return len(s)

def main():
    n,k = LI()
    p = LI()
    qc = [None] * n
    for i in range(n-1):
        if p[i] > p[i+1]:
            qc[i+1] = True

    ec = -1
    iq = []
    aq = []
    for i in range(k):
        if qc[i]:
            ec = i
        heapq.heappush(iq,p[i])
        heapq.heappush(aq,-p[i])


    r = 0
    if ec > 0:
        r += 1
    s = set()
    for i in range(k,n):
        if qc[i]:
            ec = i
        t = p[i]
        u = p[i-k]
        heapq.heappush(iq,t)
        while iq[0] in s:
            heapq.heappop(iq)
        while -aq[0] in s:
            heapq.heappop(aq)
        heapq.heappush(aq,-t)
        if iq[0] != u or aq[0] != -t:
            if ec > i - k + 1:
                r += 1
        s.add(u)

    rr = 0
    c = 1
    for i in range(1,n):
        if p[i] > p[i-1]:
            c += 1
            if c >= k:
                rr = 1
                break
        else:
            c = 1

    return r + rr


print(main())



Measured memory_bytes: 38732
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  sort(data.begin(), data.end());
  long left = -1, right = data.size(), mid, sum = 0, flag;
  while(right - left > 1){
    mid = left + (right - left) / 2;
    sum = data.at(mid);
    flag = 1;
    for(int i = 0; i < N; i++){
      if(i == mid)continue;
      if(sum * 2 >= data.at(i))sum += data.at(i);
      else {
        flag = 0;
        break;
      }
    }
    if(flag)right = mid;
    else left = mid;
  }
  cout << N - right << endl;
  return 0;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1


H,W,M=map(int,input().split())
hw=[0]*M
mask=(1<<20)-1
H_bomb=[0]*H
W_bomb=[0]*W
for i in range(M):
    h,w=map(int1,input().split())
    H_bomb[h]+=1
    W_bomb[w]+=1
    hw[i]=(h<<20)+w
hw.sort(reverse=1)

MAX_W_bomb=[-INF,set()]

for i,x in enumerate(W_bomb):
    if x>MAX_W_bomb[0]:
        MAX_W_bomb[0]=x
        MAX_W_bomb[1]=set([i])
    elif x==MAX_W_bomb[0]:
        MAX_W_bomb[1].add(i)

ans=0
res=hw.pop()
next_y,next_x=res>>20,res&mask
for y in range(H):
    tmp=H_bomb[y]
    MAXcnt=0
    while next_y==y:
        if next_x in MAX_W_bomb[1]:
            MAXcnt+=1
        if hw:
            res=hw.pop()
            next_y,next_x=res>>20,res&mask
        else:
            next_y,next_x=-1,-1
    if MAXcnt==len(MAX_W_bomb[1]):
        tmp+=MAX_W_bomb[0]-1
    else:
        tmp+=MAX_W_bomb[0]
    ans=max(ans,tmp)

print(ans)
    

Measured memory_bytes: 134788
from collections import Counter

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

"""
まずは偶数番目、奇数番目をカウントする
次に数を調べる
2個目から先を足す
"""

#forループを回さなくても解ける方法があるよ。
#listの要素を取るときに[::2]とすると、２個おきにとってきてくれる
odd = Counter(v[1::2]).most_common()
even = Counter(v[0::2]).most_common()

#most_comon()は、（要素、出現回数）のリストを返してくれる

if odd[0][0] != even[0][0]:
	answer = n - odd[0][1] - even[0][1]

else:
	if len(odd) == 1 and len(even) >1:
		answer = n - even[0][1]
	elif len(even) == 1 and len(odd) >1:
		answer = n - odd[0][1]
	elif len(even) == 1 and len(odd) ==1:
		answer = n - even[0][1]
	else:		
		if odd[0][1] > even[0][1]:
			answer = n - odd[0][1] - even[1][1]
		elif odd[0][1] < even[0][1]:
			answer = n - even[0][1] - odd[1][1]
		else:
			if odd[1][1] > even[1][1]:
				answer = n - even[0][1] - odd[1][1]
			elif odd[1][1] < even[1][1]:
				answer = n - odd[0][1] - even[1][1]
			else:
				answer = n - odd[0][1] - even[1][1]
		
print(answer)

"""
半分waになってしまった...なにがいけなかったんだろう
"""





Measured memory_bytes: 20700
import numpy as np

A, B, C = (int(i) for i in input().split())

output=[]
output.append(A+B*10+C)
output.append(A+C*10+B)
output.append(B+A*10+C)
output.append(B+C*10+A)
output.append(C+A*10+B)
output.append(C+B*10+A)

print(np.max(np.array(output)))


Measured memory_bytes: 12496
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    int n, k;
    cin >> n >> k;
    double ans = 0.0;
    for(int i = 1; i <= n; i++){
        double tmp = 1.0 / (double)n;
        int now = i;
        while(now < k){
            now *= 2;
            tmp *= 0.5;
        }
        ans += tmp;
    }
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int a;
	string s;
	cin >> a >> s;
	
	if(a >= 3200){
		cout << s;
	}
	else
		cout << "red";

	return 0;
}




Measured memory_bytes: 256
D,G=map(int, input().split())
scoremap=[list(map(int, input().split())) for d in range(D)]
answer=float('inf')

for i in range(2**D):
  yet=[]
  score=count=0
  for j in range(D):
    if i>>j&1==0:
      yet.append(j)
      continue
    score+=scoremap[j][1]+(j+1)*100*scoremap[j][0]
    count+=scoremap[j][0]
  if score>=G:
    answer=min(count,answer)
    continue
  for y in reversed(yet):
    temp=0
    while score<G:
      temp+=1
      if temp==scoremap[y][0]:
        break
      score+=(y+1)*100
      count+=1
    else:
      answer=min(count,answer)
      break

print(answer)
    

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        char[] stmp = s.ToCharArray();
        char[] ttmp = t.ToCharArray();

        Array.Sort(stmp);
        Array.Sort(ttmp);
        Array.Reverse(ttmp);

        var ss = new String(stmp);
        var tt = new String(ttmp);

        var ans = "No";
        if(string.Compare(ss,tt) == -1) ans = "Yes";

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n,k;cin>>n>>k;
    vi v(100005);
    vi num(k);
    rep(i,n){
        ll a;cin>>a;v[a]++;num[a%k]++;
    }
    ll ans=0;
    REP(i,1,k){
        ll j=k-i;
        if(j<i)break;
        if(i!=j){
            ll t=min(num[i],num[j]);
            ans+=t;
            num[i]-=t;
            num[j]-=t;
        }
        else{
            ans+=num[i]/2;
            num[i]=0;
        }
    }
    ans+=num[0]/2;
    num[0]=0;
    rep(i,100001){
        if(v[i]){
            ll t=min(v[i]/2,num[i%k]/2);
            ans+=t;
            num[i%k]-=t*2;
        }
    }
    out(ans);
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int x=read(),y=read();
	if(x%y==0)
		cout<<-1<<endl;
	else
		cout<<x<<endl;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int Memo[31];

void recursion(int depth, int n, int m)
{
	if(n == 0)
	{
		cout << Memo[0];
		for(int i = 1; i < depth; ++i)
		{
			cout << " " << Memo[i];
		}
		cout << endl;
	}
	if(m > n)
	{
		m = n;
	}
	for(int i = m; i >= 1; --i)
	{
		Memo[depth] = i;
		recursion(depth + 1, n - i, i);
	}
}

void solve()
{
	int n;
	while(cin >> n, n)
	{
		recursion(0, n, n);
	}
}

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

Measured memory_bytes: 876
import sys

N, P = map(int, input().split())
A = input()

ans = 0

if 10 % P == 0:
    for r in range(len(A)):
        if int(A[r]) % P == 0:
            ans += r + 1
    print(ans)
    sys.exit()


A = "0" + A[::-1]

S = [0] * len(A)
cnt = [0] * P
cnt[0] = 1

for i in range(len(A) - 1):
    S[i + 1] = (S[i] + int(A[i + 1]) * pow(10, i, P)) % P
    cnt[S[i + 1] % P] += 1
# print(S, cnt)

# ans = cnt[0] * (cnt[0] - 1) // 2
for c in cnt:
    ans += c * (c - 1) // 2
print(ans)


Measured memory_bytes: 11096
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int ans = 0;
int N;

void dfs(vector<int> &a, vector<int> &b) {
    if (b.size() == N) {
        bool tmp = false;
        rep(i,0,N) {
            if (b[i]%2==0) {
                tmp = true;
                break;
            }
        }
        if (tmp) {
            ans++;
        }
    }
    else {
        
        rep(i,a[b.size()]-1,a[b.size()]+2) {
            b.push_back(i);
            dfs(a,b);
            b.pop_back();

        }
    }
}

int main (){
    cin >> N;
    vector<int> a(N);
    vector<int> b;

    rep(i,0,N) {
        cin >> a[i];
    }

    dfs(a,b);
    cout << ans << endl;
}





Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
//
#include <cstdio>
#include <cstdint>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }

//
class Init
{
public:
    Init()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
}init;

//
int main()
{
    //
    ll w, h, k;
    cin >> h;
    cin >> w;
    cin >> k;
    vector<bool> table;
    for (int32_t i = 0; i < h; ++i)
    {
        for (int32_t j = 0; j < w; ++j)
        {
            char ch;
            cin >> ch;
            table.push_back((ch == '#'));
        }
    }

    const auto checkTable = [&](ll xb, ll yb)
    {
        ll cnt = 0;
        rep(y,h)
            rep(x, w)
            {
                if (((xb >> x) % 2) && ((yb >> y) % 2))
                {
                    cnt += table[x + y * w] ? 1 : 0;
                }
            }
        return cnt == k;
    };

    // 全探索
    ll ybm = (1 << h);
    ll xbm = (1 << w);
    ll okay = 0;
    rep(yb, ybm)
    {
        rep(xb, xbm)
        {
            if (checkTable(xb, yb))
            {
                ++okay;
            }
        }
    }
    cout << okay;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> collect(n,0);
    rep(i,q){
        int a; cin >> a;
        a--;
        collect[a]++;
    }
    rep(i,n){
        cout << (k - q + collect[i] > 0 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val list = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    val foods = Array(m+1) {0}
    for (l in list) {
        for (i in 1 until l.size) {
            foods[l[i]]++
        }
    }

    val ans = foods.filter { it == n }.count()
    println(ans)
}

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String str2 = br.readLine();
    int[][] lcs = new int[str1.length()+1][str2.length()+1];
    int max = 0;
    StringBuilder res = new StringBuilder();
    for(int i=0;i<=str1.length();i++){
      for(int j=0;j<=str2.length();j++){
        if(i==0 || j==0)
          lcs[i][j] = 0;
        else if(str1.charAt(i-1) == str2.charAt(j-1)){
          lcs[i][j] = lcs[i-1][j-1]+1;
          //res += str1.charAt(i-1);
        }
        else
          lcs[i][j] = Math.max(lcs[i-1][j],lcs[i][j-1]);
        max = Math.max(max,lcs[i][j]);
      }
    }
    
    int i=str1.length(),j=str2.length();
    while(i>0 && j>0){
      char a = str1.charAt(i-1);
      char b = str2.charAt(j-1);
      if(a==b){
        res.append(a);
        i--;
        j--;
      }
      else{
        if(lcs[i][j] == lcs[i-1][j]) i--;
        else j--;
      }
    }
   System.out.println(res.reverse().toString());
  }
}


Measured memory_bytes: 84512
package main

import "fmt"

func main() {
	// Code for B - String Rotation
	var S, T string
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)
	var flag int = 0
	for i := 0; i < len(S); i++ {
		temp := S[len(S)-1:len(S)] + S[0:len(S)-1]
		if temp == T {
			flag = 1
			break
		} else {
			S = temp
		}
	}
	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int i,j;
	int counter=0;
	ll N;
	ll answer=0;

	cin >> N;
	vector<ll> given(N);

	for(i=0;i<N;i++)
		cin >> given[i];
	
	sort(given.begin(),given.end());
	ll max=given[N-1];
	vector<bool> flags(max+5,true);

	for(i=0;i<N;i++){
		if(i!=0 && given[i-1] == given[i]) flags[given[i]]=false;
		for(ll j=given[i]*2;j<=max;j+=given[i])
			flags[j]=false;
	}


	for(i=0;i<N;i++)
		if(flags[given[i]]) counter++;

	cout << counter << endl;
	return 0;
}



Measured memory_bytes: 4952
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

#define triplet pair<pair<int,int>,int>

using namespace std;
stack<char>st;

int main(){
    ios::sync_with_stdio(0);
    string s;
    int n;
    cin>>s;
    n = s.length();
    for(int i=0  ;i <n ; i++){
        while(!st.empty()){
            char x = st.top();
            st.pop();
            if(st.empty() || st.top()== s[i]){
                st.push(x);
                break;
            }
        }
        st.push(s[i]);
    }
    int r = n - st.size();
    if(r %2 == 0){
        cout<<"Second\n";
    }
    else{
        cout<<"First\n";
    }

    return 0;
}


Measured memory_bytes: 640
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;

	for (int i = 0; i * 4 <= N; ++i) {
		if ((N - i * 4) % 7 == 0) {
			std::cout << "Yes\n";
			return 0;
		}
	}
	std::cout << "No\n";
}


Measured memory_bytes: 256
P = 10 ** 9 + 7

N, M = map(int, input().split())
broken = set()

for _ in range(M):
  broken.add(int(input()))

# N番目に到達する組み合わせの数を保持するテーブル  
table = [0] * (N + 1)
table[0] = 1

for i in range(N):
  if i in broken:
    continue
    
  for step in (1, 2):
    if i + step <= N:
      table[i + step] += table[i]
      table[i + step] %= P

print(table[N])  

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define MOD1 1000000007
#define MOD2 998244353

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	IOS

	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	int tot = a + b + c + d + e;
	cout << 15 - tot << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

const int N = 11;
int h, w, k;
string s[N];

int m, breaks[10], sms[10];

int get_cand() {
    int ret = m;
    int prevBreak = 0;
    for(int i = 0; i < w; ++i) {
        int section = 0;
        for(int row = 0; row < h; ++row) {
            if(breaks[section] == row) section++;
            if(s[row][i] == '1') sms[section]++;
            
            if(sms[section] > k) {
                if(i == prevBreak) {
                    return (h-1) + (w-1);
                }
                prevBreak = i;
                i--;
                memset(sms, 0, sizeof(sms));
                ret++;
                break;
            }
        }
    }
    return ret;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> h >> w >> k;
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    int ans = (h-1) + (w-1);

    for(int mask = 0; mask < 1<<(h-1); ++mask) {
        m = 0;
        for(int i = 0; i < h-1; ++i) {
            if(1<<i & mask) {
                breaks[m++] = i+1;
            }
        }
        memset(sms, 0, sizeof(sms));
        breaks[m] = h;

        int cand = get_cand();

        ans = min(ans, cand);
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
float ans;
vector<float> a;

void input(void){
   cin>>n;
   rep(i,n){
       cin>>ans;
       a.push_back(ans);
   }
}
void solve(void){
    ans=0;
    sort(all(a));
    rep(i,n){
        if(i==0)ans+=a[0];
        else ans=(ans+a[i])/2;
    }
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;


int arr[200005];
vector<int> ans;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n,k;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	for(int i=n;i>=1;i--){
		if(arr[i]){
			ans.push_back(i);
			if(i>1){
				for(int j=1;j*j<=i;j++){
					if(j==1||j*j==i){
						arr[j]=!arr[j];
					}
					else if(i%j==0){
						arr[j]=!arr[j];
						arr[i/j]=!arr[i/j];
					}
				}
			}
		}
	}
	cout<<ans.size()<<endl;
	for(auto i:ans)
		cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 2424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	 	Scanner scanner = new Scanner(System.in);
	 	long N = scanner.nextLong();
	 	long x = 0;
	 	long y = 0;
	 	long sum = 0;
	 	x = N / 15;
	 	y = N % 15;
	 	sum = (60 + 60 + 120 * (x - 1)) * x / 2;
	 	if (y == 1) {
	 		sum += 1 + 15 * x;
	 	} else if (y == 2 || y == 3) {
	 		sum += 3 + 15 * x * 2;
	 	} else if (y == 4 || y == 5 || y == 6) {
	 		sum += 7 + 15 * x * 3;
	 	} else if (y == 7) {
	 		sum += 14 + 15 * x * 4;
	 	} else if (y == 8 || y == 9 || y == 10) {
	 		sum += 22 + 15 * x * 5;
	 	} else if (y == 11 || y == 12) {
	 		sum += 33 + 15 * x * 6;
	 	} else if (y == 13) {
	 		sum += 46 + 15 * x * 7;
	 	} else if (y == 14) {
	 		sum += 60 + 15 * x * 8;
	 	}
	 	//System.out.println(x);
	 	//System.out.println(y);
	 	System.out.println(sum);
 	}
}


Measured memory_bytes: 35808
N = int(input())
A_list = []
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))

ans = 0
for n in range(N+1):
    total = sum(A_list[0][:n+1]) + sum(A_list[1][n:])
    if total > ans:
        ans = total
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        -- a[i];
    }

    vector<int> x(m, 0);
    vector<int> y(m, 0);
    vector<long long> z(m);
    int cnt = 0;
    long long sum = 0;
    for(int i=0; i<n-1; ++i){
        ++ x[a[i]];
        ++ y[a[i+1]];
        if(a[i] < a[i+1]){
            z[a[i+1]] += a[i+1] - a[i];
            sum += a[i+1] - a[i];
        }
        else{
            z[a[i+1]] += m - a[i] + a[i+1];
            sum += a[i+1];
            ++ cnt;
        }
    }

    long long ans = sum + cnt;
    for(int i=0; i<m-1; ++i){
        cnt += x[i] - y[i];
        sum += z[i] - cnt;
        ans = min(ans, sum+cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2176
h,w,k = map(int, input().split())

s = [list(map(str,list(input()))) for i in range(h)]
ans =0
for ii in range(1<<h):
    for jj in range(1<<w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (ii >> i & 1):
                    continue
                if (jj >> j & 1):
                    continue
                if (s[i][j] == '#'):
                    cnt += 1

        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)
#define N 1000010
using namespace std;
ll n,ans[N];
int main(){
	ll i,j,k;
	fast;itt;now;
	memset(ans,0,sizeof(ans));
	cin>>n;
	for(i=1;i<=100;i++)
	{
		for(j=1;j<=100;j++)
		{
			for(k=1;k<=100;k++)
			{
				if(((i+j)*(i+j)+(i+k)*(i+k)+(j+k)*(j+k))%2==0)
				{
					ans[((i+j)*(i+j)+(i+k)*(i+k)+(j+k)*(j+k))/2]++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int n;
    cin >> n;
    vector<int> a(26, INF);
    rep(i, n) {
        string s;
        cin >> s;
        vector<int> t(26, 0);
        rep(j, s.length()) {
            t[s[j] - 'a']++;
        }
        rep(i, 26) {
            chmin(a[i], t[i]);
        }
    }

    rep(i, 26) {
        if (a[i] == INF) continue;
        rep(j, a[i]) {
            cout << (char)('a' + i);
        }
    }

    cout << endl;

    return 0;
}

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

int main() {
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  int dx=gx-sx;
  int dy=gy-sy;
  for(int i=0;i<dx;i++) {
    cout << "R";
  }
  for(int i=0;i<dy;i++) {
    cout << "U";
  }
  for(int i=0;i<dx;i++) {
    cout << "L";
  }
  for(int i=0;i<dy+1;i++) {
    cout << "D";
  }
  for(int i=0;i<dx+1;i++) {
    cout << "R";
  }
  for(int i=0;i<dy+1;i++) {
    cout << "U";
  }
  cout << "LU";
  for(int i=0;i<dx+1;i++) {
    cout << "L";
  }
  for(int i=0;i<dy+1;i++) {
    cout << "D";
  }
  cout << "R" << endl;
}

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

template<int MAX>
struct Combination {
    vector<long long> _inv, _fac, _ifac;
    const long long MOD;
    Combination(long long mod) : _inv(MAX+1), _fac(MAX+1), _ifac(MAX+1), MOD(mod) { init(); }
    inline void init(long long mod = 0) { init_inv(), init_fac(); }

    inline void init_inv() {
        _inv[0] = 0;
        for (int i = 1; i <= MAX; i++) {
            if (i == 1) _inv[i] = 1;
            else {
                _inv[i] = (MOD - (MOD / i) * _inv[MOD % i]) % MOD;
                if (_inv[i] < 0) _inv[i] += MOD;
            }
        }
    }
    inline void init_fac() {
        _fac[0] = _ifac[0] = 1;
        for (int i = 1; i <= MAX; i++) {
            _fac[i] = _fac[i-1] * i % MOD;
            _ifac[i] = _ifac[i-1] * _inv[i] % MOD;
        }
    }

    inline long long modpow(long long n, long long r) {
        n %= MOD, r %= (MOD-1);
        if (!n) return 0;
        long long ret = 1; long long tmp = n;
        while (r != 0) {
            if (r % 2) ret *= tmp;
            tmp *= tmp; tmp %= MOD; ret %= MOD;
            r /= 2;
        }
        return ret;
    }
    inline long long invb(int i) { return (i <= MAX) ? _inv[i] : this->modpow(i, MOD-2); }
    inline long long inv(int i) { return _inv[i]; }
    inline long long fac(int i) { return _fac[i]; }
    inline long long ifac(int i) { return _ifac[i]; }

    const long long operator()(int n, int r) {
        if (n < r) return 0;
        return fac(n) * ifac(r) % MOD * ifac(n-r) % MOD;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    constexpr int mod = 998244353;
    long long n, m, k; cin >> n >> m >> k;
    Combination<500010> C(mod);
    long long ans = 0;
    if (m == 1) {
        if (k == n-1) cout << 1 << "\n";
        else cout << 0 << "\n";
        return 0; 
    }
    for (int i = 0; i <= k; i++) {
        ans += C(n-1, i) * C.modpow(m-1, n-i-1) % mod * m % mod;
    }
    cout << ans % mod << "\n";
    return 0;
}

Measured memory_bytes: 15080
n = gets.to_i
room = []
4.times do |i|
  room[i] = []
  3.times do |j|
    room[i][j] = [0]*10
  end
end

n.times do
  b, f, r, v = gets.split.map(&:to_i)
  room[b-1][f-1][r-1] += v
end

4.times do |i|
  3.times do |j|
    puts " " + room[i][j].join(' ')
  end
  puts '#'*20 if i < 3
end

Measured memory_bytes: 6116
N ,M= input().split()
a=[]
N=int(N)
M=int(M)
for i in range(N):
    a.append(list(map(int,input().split())))
b=[int(input()) for i in range(M)]
x=[0 for i in range(N)]
for i in range(N):
    for j in range(M):
        x[i]+=a[i][j]*b[j]
print("\n".join(map(str,x)))

Measured memory_bytes: 7868
N, Q = [int(_) for _ in input().split()]
S = input()
LR = [[int(_) for _ in input().split()] for i in range(Q)]

cs = [0] * N

r = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        r += 1
    cs[i] = r

for l, r in LR:
    result = cs[r - 1] - cs[l -1]
    print(result)



Measured memory_bytes: 24476
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	if (s.size() < 26)
	{
		for (char c = 'a'; c <= 'z'; ++c)
		{
			if (s.find(c) == std::string::npos)
			{
				cout << s << c << endl;
				return 0;
			}
		}
	}

	char last = '\0';
	for (auto it = s.rbegin(); it != s.rend(); ++it)
	{
		if (*it < last)
		{
			last = *it;
			s.erase(s.rend() - it - 1);
			for (char c = last + 1; c <= 'z'; ++c)
			{
				if (s.find(c) == std::string::npos)
				{
					cout << s << c << endl;
					return 0;
				}
			}
		}
		last = *it;
	}

	cout << -1 << endl;

	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> a;
  while(N>0){
    a.push_back(N%10);
    N/=10;
  }
  reverse(a.begin(),a.end());
  int n=a.size();
  int dp[n][2][2][2][2][2];
  for(int i=0;i<n;i++){
    for(int smaller=0;smaller<2;smaller++){
      for(int nonzero=0;nonzero<2;nonzero++){
        for(int three=0;three<2;three++){
          for(int five=0;five<2;five++){
            for(int seven=0;seven<2;seven++){
              dp[i][smaller][nonzero][three][five][seven]=0;
            }
          }
        }
      }
    }
  }

  dp[0][1][0][0][0][0]=1;
  if(a.at(0)==3){
    dp[0][0][1][1][0][0]=1;
  }
  if(a.at(0)>3){
    dp[0][1][1][1][0][0]=1;
  }
  if(a.at(0)==5){
    dp[0][0][1][0][1][0]=1;
  }
  if(a.at(0)>5){
    dp[0][1][1][0][1][0]=1;
  }
  if(a.at(0)==7){
    dp[0][0][1][0][0][1]=1;
  }
  if(a.at(0)>7){
    dp[0][1][1][0][0][1]=1;
  }
  for(int i=1;i<n;i++){
    for(int three=0;three<2;three++){
      for(int five=0;five<2;five++){
        for(int nonzero=0;nonzero<2;nonzero++){
          for(int seven=0;seven<2;seven++){
            dp[i][1][1][1][five][seven]+=dp[i-1][1][nonzero][three][five][seven];
            dp[i][1][1][three][1][seven]+=dp[i-1][1][nonzero][three][five][seven];
            dp[i][1][1][three][five][1]+=dp[i-1][1][nonzero][three][five][seven];
          }
        }
      }
    }
    dp[i][1][0][0][0][0]+=dp[i-1][1][0][0][0][0];
    if(a.at(i)==3){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][0][1][1][five][seven]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
    if(a.at(i)>3){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][1][1][1][five][seven]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
    if(a.at(i)==5){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][0][1][three][1][seven]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
    if(a.at(i)>5){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][1][1][three][1][seven]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
    if(a.at(i)==7){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][0][1][three][five][1]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
    if(a.at(i)>7){
      for(int three=0;three<2;three++){
        for(int five=0;five<2;five++){
          for(int seven=0;seven<2;seven++){
            dp[i][1][1][three][five][1]+=dp[i-1][0][1][three][five][seven];
          }
        }
      }
    }
  }
  cout<<dp[n-1][0][1][1][1][1]+dp[n-1][1][1][1][1][1]<<endl;
}


Measured memory_bytes: 256
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

ans = 0
for i in count:
    ans = (ans + count[i]*pow(2,i)) % MOD

print ans


Measured memory_bytes: 38628