akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int S = 999999999ll, G = 9999999990ll;//[S,G)
	while (G - S > 1) {
		int T = (S + G) / 2;
		string K = to_string(T);
		K += "555";
		cout << "?" << " " << K << endl;
		char i; cin >> i;
		if (i == 'N')S = T;
		else G = T;
	}
	string x = to_string(G);
	while (1) {
		if (x[x.size() - 1] != '0') { cout << "! " << x << endl; break; }
		int y = stoll(x);
		x.erase(--x.end());
		string u;
		for (int i = 0; i < x.size(); i++) {
			u += '9';
		}
		cout << "?" << " " << u << endl;
		char i; cin >> i;
		if (i == 'N') { cout << "! "<< x << "0" << endl; break; }
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,i;
	cin >> n >> k;
	for(i=0;pow(k,i)<=n;i++){}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    long L =sc.nextLong();
	    long R = sc.nextLong();
	    int min = Integer.MAX_VALUE;

	    for(int i=0;i<2018;i++) {
	    	long num1 = L+i;
	    	if(num1>R)break;
	    	for(int j=i+1;j<2019;j++) {
		    	long num2 = L+j;
		    	if(num2>R)break;
		    	int a = (int)(((num1%2019)*(num2%2019))%2019);
		    	min = Math.min(a,min);
	    	}
	    }
	    System.out.println(min);
	}



}

Measured memory_bytes: 21844
n, x = (int(i) for i in input().split())
l = [int(_) for _ in input().split()] 

if n==1 and sum(l)<=x:
  print(2)
elif sum(l) <= x:
  print(n+1)
else:
  for i in range(n+1):
    ll = l[:i]
    if sum(ll)>x:
      break
  print(len(ll))

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, m, x, y, e;
int a[101], b[101];

int main()
{
	IOS;
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(a, a+n);
	sort(b, b+m);
	for (int i = x+1; i <= y; i++) {
		if (a[n-1] < i && i <= b[0]) {
			printf("No War\n");
			return 0;;
		}
	}
	printf("War\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int a=0;
  int w=0;
  int t=0;
  int r=0;
  string str;
  for(int i=0;i<N;i++){
  cin >> str;
  if(str.at(0)=='A'){
    a++;
  }else if(str.at(0)=='W'){
    w++;
  }else if (str.at(0)=='T'){
    t++;
  }else if(str.at(0)=='R'){
    r++;
  }
  }
  cout <<"AC x "<< a <<endl;
    cout <<"WA x "<< w <<endl;
      cout <<"TLE x "<< t <<endl;
    cout <<"RE x "<< r <<endl;

}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
#define pb push_back


int main()
{
    int tst=1;
    /*scanf("%d",&tst);*/
    while(tst--) 
	{
		string s,t;
		cin >> s >> t;
		for(int i=0;i<(int)s.size();i++)
		{
			if(s[i]!=t[i])
			{
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	if (abs(a - b) >= 2)cout << "0\n";
	else{
		long long ans = 1, mod = 1000000007;
		if (a == b) 
			ans = 2;
		for (int i = 1; i <= a; i++){
			ans = ans*i%mod;
		}
		for (int i = 1; i <= b; i++){
			ans = ans*i%mod;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] list = str.toCharArray();
		char b = list[0];
		boolean ch = false;
		for(int i = 1; i<4; i++) {
			if(b == list[i]) {
				ch = true;
				break;
			}else {
				b = list[i];
			}
		}
		if(ch) System.out.println("Bad");
		else System.out.println("Good");
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)

char buf[114514];

int main() {
    scanf("%s", buf);
    string s = buf;
    int n = s.size();

    int ans = n;
    rep(i, n - 1) {
        if (s[i] != s[i + 1])
            ans = min(ans, max(i + 1, n - i - 1));
    }

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

Measured memory_bytes: 384
#include <cstdio>

#define MAX_N 100000
#define MAX_W 10000
typedef long long llong;

int check(int *W, llong &P, int &n,int &k) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + W[i] <= P) {
			s += W[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

llong solve(int *W, int &n, int &k) {
	llong left = 0;
	llong right = MAX_N * MAX_W;
	llong mid = 0;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(W,mid,n,k);
		if (v >= n) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	return right;
}

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

	llong ans = solve(W,n,k);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3088
n=int(input())
lists=[[] for _ in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        lists[i].append([x,y])
ans=0
for k in range(2**n):
    subans=0
    flag=True
    string=format(k,"0%ib"%n)
    listss=["unknown" for i in range(n)]
    for i in range(n):
        if string[i]=="1":
            #正直者だとした場合の全探索
            subans+=1
            for some in lists[i]:
                if listss[some[0]-1]=="unknown":
                    listss[some[0]-1]=some[1]
                elif listss[some[0]-1]!="unknown":
                    if listss[some[0]-1]!=some[1]:
                        flag=False
                        break

    if flag:
        flags=True
        for i in range(n):
            if  listss[i]!="unknown" and listss[i]!=int(string[i]):
                flags=False
        if flags:
            ans=max(ans,subans)

print(ans)        


Measured memory_bytes: 48732
using System;
using System.Linq;

class Challenge
{
  static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    
    int Count = 0;
    bool CanDivide = true;
    
    do
    {
      for (int j=0; j<N; j++)
      {
        if (A[j]%2 == 1) CanDivide=false;
        A[j] /= 2;
      }
      if (CanDivide) Count++;
    }while(CanDivide);
    Console.WriteLine(Count);
  }
}


Measured memory_bytes: 13268
h,w=map(int,input().split())
s=[[c for c in input()] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            continue
        c=0
        for a,b in [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]:
            if i+a<0 or i+a>h-1 or j+b<0 or j+b>w-1:
                continue
            if s[i+a][j+b]=='#':
                c+=1
        s[i][j]=str(c)
for i in s:
    print(''.join(i))


Measured memory_bytes: 9064
(defun func (x y)
  (if y
	(if x
	  (if (eq (car x) (car y))
		(func (cdr x) (cdr y))
		(func (cdr x) y))
	  "No")
	"Yes"))

(princ (func (concatenate 'list (read-line)) (concatenate 'list "CF")))


Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int k;
    cin >> k;
    rep(i, k) cout << "ACL";
    cout << '\n';
}

Measured memory_bytes: 3524
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def bfs(x, y):
    d = [[-1] * w for _ in range(h)]
    q = deque()
    q.append([x, y])
    d[x][y] = 0
    while q:
        p = q.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != '#' and d[nx][
                    ny] == -1:
                q.append([nx, ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    cnt = 0
    for i in range(h):
        for j in range(w):
            cnt = max(cnt, d[i][j])
    return cnt


ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            ans = max(ans, bfs(i, j))
print(ans)


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

data.sort(key=lambda x: x[1])

now = 0

for i in range(N) :
  if now + data[i][0] > data[i][1] :
    print("No")
    break
  else :
    now = now + data[i][0]
  
  if i == N-1 :
    print("Yes")


Measured memory_bytes: 53596
#include<stdio.h>

main(){

int a, b, c, d=0;

scanf("%d %d %d",&a,&b,&c);


if( a < b){
 d = d +1;
}

else{}

if( b < c){
 d = d + 1;
}

else{}

if( d ==2){

 printf("Yes\n"); 
}

else{

 printf("No\n");
}


 return 0;
}


  




Measured memory_bytes: 2048
import math

n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    p = math.ceil(math.log2(k/i))
    if p >= 0:
        ans += (1/n) * ((1/2)**p)
    else:
        ans += (1/n) * 1

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main (void)
{
	int A,B,C,D,E,g;
	scanf("%d%d%d%d%d",&A,&B,&C,&D,&E);
	if(A<0){
		g=-A*C+D+E*B;
	}
	else if(A==0){
		g=D+E*B;
	}
	else{
		g=(B-A)*E;
	}
	printf("%d\n",g);
	return 0;
}


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

int main() {
    int k,x; scanf("%d %d", &k, &x);
    for (int i=x-k+1; i<=x+k-1; i++) {
        printf("%d%c", i, " \n"[i==k+x-1]);
    }
    return 0;
}


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

using LL = long long int;

using namespace std;

#define MAX_N 100005
#define MAX_M 100005

LL N, M;
LL A[MAX_M];

void input()
{
  cin >> N >> M;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i]; A[i]--;
  }
}

class Event{
public:
  LL in, out;
  LL outDeg;
  Event()
  {
    in = out = 0;
    outDeg = 0;
  }

  string getString()
  {
    return "in:" + to_string(in) + " out:" + to_string(out) + " outDeg:" + to_string(outDeg);
  }

  bool notNull()
  {
    return in != 0 || out!=0 || outDeg!=0;
  }
};

Event events[MAX_M];

int main()
{
  input();

  LL ans = 0;
  for (size_t i = 0; i < N-1; i++) {
    ans += (A[i+1] + M - A[i]) % M;
    if(A[i] == A[i+1]) {
      continue;
    }
    events[(A[i+1]+1) % M].out++;
    events[(A[i+1]+1) % M].outDeg += (A[i+1] + M - A[i]) % M - 1;
    events[(A[i]+1) % M].in++;
  }
/*
  cerr << ans << endl;
  for (size_t i = 0; i < M; i++) {
    if(events[i].notNull())
    cerr << i << " " << events[i].getString() << endl;
  }
*/
  LL tmp = 0;
  LL cnt = 0;
  //0スタート
  LL tmp2 = 0;
  for (size_t i = 0; i < N-1; i++) {
    if(0 < A[i] && 0 <= A[i+1] && A[i+1] < A[i]) {
      cnt++;
      tmp2 += (M - (A[i] + 1));
    }
  }

  //cerr << ans - tmp2 << " " << cnt << endl;

  tmp = tmp2;
  for (size_t i = 1; i < M; i++) {
    cnt += events[i].in - events[i].out;
    tmp2 += cnt - events[i].outDeg - events[i].in;
    tmp = max(tmp, tmp2);
/*
    if(events[i].notNull())
    cerr << i << " outDeg;" << events[i].outDeg << " cnt:" << cnt << " " << ans - tmp2 << endl;
    */
  }

  cout << ans - tmp << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int m;
    if(n%2==0){
        m=2;
    }
    else{
        m=3;
    }
    vector<vector<ll>> dp(n+1,vector<ll>(m,-INF));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        vector<ll> tmp(m,-INF);
        for(int j=0;j<m;j++){
            if(dp[i][j]==-INF){
                continue;
            }
            if((i+j)%2==0){
                chmax(tmp[j],dp[i][j]+a[i]);
            }
            else{
                chmax(tmp[j],dp[i][j]);
            }
            if(j<m-1){
                chmax(tmp[j+1],dp[i][j]);
            }
        }
        for(int j=0;j<m;j++){
            dp[i+1][j]=tmp[j];
        }
    }
    cout << dp[n][m-1] << endl;
}

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

//ofstream out("debug.txt");

const int MxN = 1e5, md = 1e9 + 7;

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

    int n;
    cin >> n;
    cout << (n == 0);
}

Measured memory_bytes: 3632
#include<iostream>
#include<cctype>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
    int a[26];
    for(int i=0;i<26;i++){a[i]=0;}

    char ch;

    while( (ch = getchar()) != EOF ){
        int num = tolower(ch) - 'a';
        if(num < 0 || num >= 26){continue;}
        a[num]++;
    }
    
    int achar = 'a';
    for(int i=0;i<26;i++){
        printf("%c : %d\n", i + achar, a[i]);
    }
    
    return 0;
}


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

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

  vector<int> P(N);
  rep(i,N) cin >> P[i];

  vector<int> Q(N);
  rep(i,N) cin >> Q[i];

  vector<int> A(N);
  rep(i,N) A[i] = i+1;
  
  int a = 0;
  int b = 0;
  int No = 1;

  do{
    bool a_match = true;
    bool b_match = true;

    rep(i,N){
      if(A[i] != P[i]) a_match = false;
      if(A[i] != Q[i]) b_match = false;
    }

    if(a_match == true) a = No;
    if(b_match == true) b = No;
    No++;

    if((a != 0) && (b != 0)) break;
  }while(next_permutation(A.begin(),A.end()));

  int ans = abs(b-a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

const int MOD = 1e9+7;
const int INF = 1001001001;
const ll llINF = 1e18+9;
vector<pii> edge[100010];


int main(){
    int N;
    cin >> N;
    rep(i, 0, N-1){
        int a, b, c;
        cin >> a >> b >> c;
        edge[a-1].push_back(mp(b-1, c));
        edge[b-1].push_back(mp(a-1, c));
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    vector<ll> dist(N, llINF);
    dist[K] = 0;
    queue<pair<int, ll>> q;
    q.push(mp(K, 0));
    while (!q.empty()){
        int now = q.front().first;
        ll nowd = q.front().second;
        q.pop();
        for (auto x:edge[now]){
            int fol = x.first;
            ll d = x.second;
            ll nextd = nowd+d;
            if (dist[fol] < nextd) continue;
            dist[fol] = nextd;
            q.push({fol, nextd});
        }
    }
    rep(i ,0 , Q){
        int x, y;
        cin >> x >> y;
        --x, --y;
        ll ans = dist[x] + dist[y];
        cout << ans << endl;
    }
}

Measured memory_bytes: 12004
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int count = 1;

    
    for(int i = 0 ; i < n-1 ; ++i){
      if(s.charAt(i) != s.charAt(i+1)){
        count++;
      }
    }
    
    System.out.println(count);
    
  }
}


Measured memory_bytes: 39532
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll>num(k,0);
  for(int i=1;i<=n;i++) num[i%k]++;
  ll ans=0;
  for(int i=0;i<k;i++){
    ll b=(k-i)%k;
    ll c=(k-i)%k;
    if((b+c)%k==0) ans+=num[i]*num[b]*num[c];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

bool isPrime(int a) {
  for (int i = 2; i*i <= a; ++i) {
    if (a%i == 0) return false;
  }
  return a != 1;
}

int main () {
  int n = in();
  int ans = 0;
  rep(i,n) {
    int a;
    cin >> a;
    if (isPrime(a)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3168
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  auto d = new int[](n+1);
  auto c = new int[](n+1);
  d[0] = a[0];
  c[0] = abs(d[0]);
  d[$-1] = 0 - a[$-1];
  c[$-1] = abs(d[$-1]);
  auto sum = c[0] + c[$-1];
  foreach (i; 1..n) {
    d[i] = a[i] - a[i-1];
    c[i] = abs(d[i]);
    sum += c[i];
  }

  foreach (i; 0..n) {
    writeln(sum - c[i] - c[i+1] + abs((d[i+1] + d[i])));
  }
}


Measured memory_bytes: 4744
NM=list(map(int,input().split()))
ac_count=0
wa_count=0

dic={}
ac_flag={}
for i in range(NM[0]+1):
    s=str(i)
    dic[s]=0
    ac_flag[s]=False

for i in range(NM[1]):
    ps=list(input().split())
    p=ps[0]
    S=ps[1]
    if S=="WA" and ac_flag[p]==False:
        dic[p]+=1
    elif S=="AC" and ac_flag[p]==False:
        ac_count+=1
        wa_count+=dic[p]
        ac_flag[p]=True
    else:pass
    
print(str(ac_count)+" "+str(wa_count))    

Measured memory_bytes: 67804
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, k;
	cin >> n >> k;
	VI d(k);
	VI2D a(k);
	VI count(n, 0);
	REP(i, k) {
		cin >> d[i];
		a[i].reserve(d[i]);
		REP(j, d[i]) {
			cin >> a[i][j];
			count[a[i][j] - 1]++;
		}
	}
	int result = 0;
	REP(i, n) { result += (count[i] == 0 ? 1 : 0); }
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int a[3];
  for (int i = 0; i < 3; ++i) {
    cin >> a[i];
  }
  sort(a, a + 3, greater<int>());
  cout << a[0] * 10 + a[1] + a[2] << endl;
  return 0;
}

Measured memory_bytes: 256
s = list(input())
k = int(input())
for i in range(len(s)):
  if ord("z")<ord(s[i])+k and s[i]!="a":
    k =k-(ord("z")-ord(s[i])+1)
    s[i]="a"
  if i==len(s)-1 and 0<k:
    k=k%26
    s[i]=chr(ord(s[i])+k)
print("".join(s))

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


int H,W;

int main(){
	cin >> H >> W;
	int row[101]={0};
	int col[101]={0};
	char field[W][H];
	// fieldにいれながら判定
	for(int i=0;i<H;i++){
		for (int j=0;j<W;j++){
			cin >> field[j][i];
			if(field[j][i] == '#') {
				row[i]=1;
				col[j]=1;
			}
		}
	}
	// どっちもひっかからなかったIndexのみ出力
	for(int i=0;i<H;i++){
		if(row[i] == 1){
			for (int j=0;j<W;j++){
				if(col[j] == 1)cout << field[j][i];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<int> d,e;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        if(a[i]-b[i]>=0) e.push_back(a[i]-b[i]);
        else d.push_back(b[i]-a[i]); //足りてない
    }
    sort(e.begin(),e.end(),greater<int>());
    ll s = 0;
    for(auto dx: d) s+= dx;
    if(s==0){
        cout << 0 << endl;
        return 0;
    }
    ll es = 0;
    for(auto ex : e) es+= ex;
    if(es<s){
        cout << -1 << endl;
        return 0;
    }
    ll now = 0;
    int ans = d.size();
    rep(i, (int)e.size()){
        ans++;
        now+=e[i];
        if(now>=s)break;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int k;
	cin >> k;
	if (k % 2)
		cout << (k / 2 + 1)*(k / 2) << endl;
	else
		cout << (k / 2)*(k / 2) << endl;
}


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

using namespace std;

int n;
string s;

int main(){
	cin>>s;int now=0;
	if(s[0]=='S') {
		if(s[1]=='U') now=0;
		else now=6;
	}
	if(s[0]=='M') now=1;
	if(s[0]=='T'){
		if(s[1]=='U') now=2;
		else now=4;
	}
	if(s[0]=='W') now=3;
	if(s[0]=='F') now=5;
	printf("%d\n",7-now);
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
fn main() {
    input! {
        n: i64,
    }
    println!(
        "{}",
        (1..n + 1)
            .filter(|&x| x % 3 != 0 && x % 5 != 0)
            .fold(0, |sum, a| sum + a)
    );
}

Measured memory_bytes: 2144
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc =  new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int p = sc.nextInt();
		int x, y;
		x = a * p;
		if(p <= c) y = b;
		else y = b + (p - c) * d;
		if(x <= y) System.out.println(x);
		else System.out.println(y);
	}
}

Measured memory_bytes: 26156
// 2017-02-03
#include <iostream>
using namespace std;

int main() {
	int n;
	int a[100001 + 1] = {};
	int b[100001 + 1] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[x]++; b[y]++;
	}
	int p = 1;
	int r = 1;
	for (int i = 2; i <= 100001; i++) {
		p = p + a[i] - b[i - 1];
		if (i <= p) r = i;
	}
	cout << r - 1 << endl;
	return 0;
}

Measured memory_bytes: 3868
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main (void) {

    vector<unsigned int> ns;
    vector<unsigned int> ps;

    unsigned int tn, tp;
    unsigned int dataset_size = 0;
    unsigned int count = 0;
    do {
        cin >> tn >> tp;
        ns.push_back(tn);
        ps.push_back(tp);
        dataset_size++;
    } while (tn != 0 || tp !=0);

    for (int x=0; x<dataset_size-1; x++) {
        count = 0;
        tn = ns[x];
        tp = ps[x];

        int has_p[tn];
        for (unsigned int i=0; i<tn; i++)
            has_p[i] = 0;

        unsigned int i = 0;
        do {
            if (tp == 0) {
                tp = has_p[i];
                has_p[i] = 0;
            } else {
                tp--;
                if ((++has_p[i]) == ps[x]) { break; }
            }
            i = (++i % tn);
            count++;
        } while (true);
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){

	int cnt = 0;
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1')cnt++;
	}
	
	cout << cnt << endl;

	
	return 0;
}

Measured memory_bytes: 764
(
    (stdin.ReadLine() |> int),
    (stdin.ReadLine() |> Seq.map string |> Seq.toArray)
)
|> fun (n, s) ->
  s.[1..(n - 1)]
  |> Seq.fold (fun (prev, prevRet, ret) cur ->
    (
        (if prev = "E" then  0 else 1),
        (if cur  = "E" then -1 else 0)
    )
    |> (fun (a, b) -> prevRet + a + b)
    |> (fun newPrevRet ->
        (cur, newPrevRet, min ret newPrevRet)
    )
  ) (
    s.[1..(n - 1)]
    |> Seq.filter (fun x -> x = "E") 
    |> Seq.length
    |> fun x -> (s.[0], x, x)
  )
  |> (fun (_, _, ret) -> ret)
  |> printfn "%d"

Measured memory_bytes: 37948
n = int(input())
F = [list(map(int,input().split())) for i in range(n)]
P = [list(map(int,input().split())) for i in range(n)]
ans = - 10 ** 15

for i in range(1,2**10):
    tmplist = [0] * n
    tmp = 0
    for j in range(10):
        if (i >> j) & 1:
            for k in range(n):
                if F[k][j] == 1:
                    tmplist[k] += 1
    for j in range(n):
        #print(j, tmplist[j])
        tmp += P[j][tmplist[j]]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	int i,x,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}else if(x%10==3){
			printf(" %d",i);
		}else{
			while(x!=0){
				x=x/10;
				if(x%10==3){
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    int X = N/min(min(min(min(A,B),C),D),E);
    if(N%min(min(min(min(A,B),C),D),E) == 0) {
        X--;
    }
    cout << 5+X << endl;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var np = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long n = np[0];
			long p = np[1];

			var primes = Primes(p);
			var values = primes.Where(x => x.Value >= n).ToArray();
			long ans = 1;
			for (long i = 0; i < values.Length; i++) {
				long num = values[i].Value / n;
				for (int j = 0; j < num; j++) {
					ans *= values[i].Key;
				}
			}

			Console.WriteLine(ans);
		}
		static Dictionary<long, long> Primes(long n)
		{
			long max = (long)Math.Ceiling(Math.Sqrt(n)) + 1;
			var dic = new Dictionary<long, long>();
			for (long i = 2; i < max; i++) {
				while (n % i == 0) {
					if (dic.ContainsKey(i) == false) {
						dic[i] = 1;
					} else {
						dic[i] += 1;
					}

					n /= i;
				}
			}

			if (n != 1) {
				dic[n] = 1;
			}

			return dic;
		}
	}
}


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



typedef vector<vector<int> > Matrix;
int w,h,xs,ys,xg,yg,n,color;
string res = "NG";
Matrix board(101, vector<int>(101,0));

void write(Matrix &board,int c, int d, int x, int y){
  int width,length;
  if(d == 0){ width = 4; length =2; }
  if(d == 1){ width = 2; length =4; }
  for(int i=0; i<width; ++i){
    for(int j=0; j<length; ++j)
      board[x+i][y+j]=c;
  }
}
void func(Matrix &board,int nx,int ny){
  if(board[nx][ny] == 0){
    res = "NG";
    return;
  }
  if( nx==xg && ny==yg){
    res = "OK";
    return;
  }
  board[nx][ny] = 0;
  if( 0<=nx-1 && color==board[nx-1][ny])
    func(board,nx-1,ny);
  if( 0<=ny-1 && color==board[nx][ny-1])
    func(board,nx,ny-1);
  if( nx+1<=w && color==board[nx+1][ny])
    func(board,nx+1,ny);
  if( ny+1<=h && color==board[nx][ny+1])
    func(board,nx,ny+1);
}


int main(void){
  int c,d,x,y;
  while(cin >> w >> h,w||h){
    if( w==0 && h==0) return 0;
    res = "NG";
    cin >> xs >> ys >> xg >> yg >> n;
    xs--; ys--; xg--; yg--;
    //    Matrix board(w, vector<int>(h,0));
    for(int i=0; i<n; ++i){
      cin >> c >> d >> x >> y;
      --x; --y;
      write(board,c,d,x,y);
    }
    color = board[xs][ys];
    func(board,xs,ys);
    cout << res << endl;
    //    board.clear();
  }
  return 0;
}
  

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2;
  int y = y2;
  int dx = x2 - x1;
  int dy = y2 - y1;

  swap(dx, dy);
  dx = -dx;
  x += dx;
  y += dy;

  int x3 = x;
  int y3 = y;

  swap(dx, dy);
  dx = -dx;
  x += dx;
  y += dy;

  int x4 = x;
  int y4 = y;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	const ll mod = 998244353;
	ll n, k;
	cin >> n >> k;

	vll t(n + 1, 0);
	vector<pair<ll, ll>> vp(k);
	rep(i, 0, k) {
		cin >> vp[i].first >> vp[i].second;
	}

	t[1] = 1;
	repeq(i, 2, n) {
		t[i] = t[i - 1];
		rep(j, 0, k) {
			ll tmp = t[max(0LL, i - vp[j].first)] - t[max(0LL, i - vp[j].second - 1)];
			if (tmp < 0) {
				tmp += mod;
			}
			t[i] += tmp;
			t[i] %= mod;
		}
	}

	ll ans = t[n] - t[n - 1];
	if (ans < 0) {
		ans += mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846

using namespace std;

void test_case()
{
    double a;
    cin>>a;
    cout<<a*M_PI*2<<"\n";

}

int main()
{
    ios::sync_with_stdio(false);
    test_case();

    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int n;

void rfl(vector< int >& card) {
	vector< int > nxt;
	for_(i,0,n) {
		nxt.push_back(card[i]);
		nxt.push_back(card[n + i]);
	}
	card = nxt;
}

void cut(vector< int >& card, int k) {
	vector< int > nxt;
	for_(i,k,2*n) nxt.push_back(card[i]);
	for_(i,0,k) nxt.push_back(card[i]);
	card = nxt;
}

int main() {
	cin >> n;
	vector< int > card(2*n);
	for_(i,0,2*n) card[i] = i + 1;
	int m; cin >> m;
	for_(i,0,m) {
		int k; cin >> k;
		if (k) cut(card, k);
		else rfl(card);
	}
	for_(i,0,2*n) cout << card[i] << endl;
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

char s[1000];

int main() {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    int flag = 0;
    for (int i = 1; i <= len; i++) {
        if ((i % 2 == 1 && s[i] == 'L') || (i % 2 == 0 && s[i] == 'R')) {
            flag = 1;
            break;
        }
    }

    if (flag) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <set>
#include <iostream>
#include <unordered_map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;

ll f(int x) {
    int res = 0;
    while(x) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    int x;
    cin >> x;
    ll sum = 1e18;
    int left = 1, right = x - 1;
    while(left <= right) {
        sum = min(sum, f(left) + f(right)); left++; right--;
    }
    
    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k;
ll dfs(ll n,ll k){
    if(n%k>=n){
        return min(n,k-n);
    }
    return dfs(n%k,k);
}
int main(void){
    cin>>n>>k;
    cout<<dfs(n,k)<<endl;
}


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

using namespace std;

int main()
{
    using ll = long long;
    
    int n;
    cin >> n;
    
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<ll> b(n), c(n);
    b[0] = a[0];
    c[n - 1] = a[n - 1];
    
    for (int i = 1; i < n; i++) {
        b[i] = __gcd(b[i - 1], a[i]);
        c[n - i - 1] = __gcd(c[n - i], a[n - i - 1]);
    }
    
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = max(ans, c[i + 1]);
        } else if (i == n - 1) {
            ans = max(ans, b[i - 1]);  
        } else {
            ans = max(ans, __gcd(b[i - 1], c[i + 1]));   
        }
    }
    
    cout << ans << endl;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    vector<int> paint;
    for (int i=0; i<n; i++){
        for(int j=0; j<a.at(i); j++){
            paint.push_back(i+1);
        }
    }

    int k = 0;
    for(int i=0; i<h; i++){
        if(i%2 == 0){
            for(int j=0; j<w; j++){
                cout << paint.at(i*w+j) << ' ';
            }
            cout << endl;
        }else{
            for(int j=w-1; j>=0; j--){
                cout << paint.at(i*w+j) << ' ';
            }
            cout << endl;

        }
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
main(){
  int a,b,x,sum,y;
  while(scanf("%d %d",&a,&b)!=EOF){
    sum=a+b;
    x=1;
    for(y=0;x!=0;y++){
      x=sum/10;
      sum=sum/10;
    }
    printf("%d\n",y);
  }
  return(0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

void print_count(long long n) {
    int n_1000, n_500, n_100;
    n_1000 = n / 1000;
    n -= n_1000 * 1000;
    n_500 = n / 500;
    n -= n_500 * 500;
    n_100 = n / 100;
    cout << n_100 << ' ' << n_500 << ' ' << n_1000 << endl;
}

int main() {
    long long A, B;
    while (cin >> A >> B) {
        if (A == 0 && B == 0) break;
        print_count(B-A);
    }
    return 0;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


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

template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const ld eps=0.0000000000001;

ll flr(ld a)
{
	ll A=(ll)a;
	ll B=A+1;
	
	if(B+eps<=a) return B;
	return A;
}

void solve()
{
	ll a;
	cin>>a;
	ld b;
	cin>>b;
	
	cout<<flr(b*a);
}	

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
int main(void){
    // Your code here!
   int A,B,C,D;
   
   scanf("%d %d %d %d",&A,&B,&C,&D);
   
   if(A+B>C+D)
   {
       printf("Left");
       
   }
   if(A+B<C+D)
   {
       printf("Right");
   }
   
   if(A==C+D-B)
   {
       printf("Balanced");
   }
   return 0;
}
   

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n;
	cin>>n;
	long long h[n];
	int ans=0,k=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(i==0){
			continue;
		}
		else{
			if(h[i]<=h[i-1]){
				k++;
			}
			else{
				ans=max(ans,k);
				k=0;
			}
		}
	}
	ans=max(ans,k);
	cout<<ans<<endl;
}


Measured memory_bytes: 4392
#include<stdio.h>
using namespace std;

int main() {
	int m[10], t[3]={0,0,0};
	for (int n = 0; n < 10; n++) {
		scanf("%d",&m[n]);
	}
	for (int n = 0; n < 10; n++) {
		if (t[0] < m[n]) {
			t[2] = t[1];
			t[1] = t[0];
			t[0] = m[n];
		}else if(t[1] < m[n]) {
			t[2] = t[1];
			t[1] = m[n];
		}
		else if(t[2] <m[n]) {
			t[2] = m[n];
		}
	}
	for (int n = 0; n < 3; n++) {
		printf("%d\n",t[n]);
	}
	return 0;
}


Measured memory_bytes: 2612
import sys
input = sys.stdin.readline

# 逆再生
# 連結成分がくっつくときに加点

N,M = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]

root = list(range(N+1))
comp_size = [1] * (N+1)

def find_root(x):
  y = root[x]
  if x == y:
    return x
  z = find_root(y)
  root[x] = z
  return z

def merge(x,y):
  rx = find_root(x)
  ry = find_root(y)
  if rx == ry:
    return 0
  sx = comp_size[rx]
  sy = comp_size[ry]
  if sx > sy:
    root[ry] = rx
    comp_size[rx] += sy
  else:
    root[rx] = ry
    comp_size[ry] += sx
  return sx * sy

answer = []
x = N*(N-1)//2
for a,b in AB[::-1]:
  answer.append(x)
  x -= merge(a,b)

for a in answer[::-1]:
  print(a)

Measured memory_bytes: 28720
#include<cstdio>
typedef long long LL;
int n;
LL a[55],ans,s,b[55];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",a+i);
	for(;;s=0){
		for(int i=1;i<=n;++i)s+=b[i]=a[i]/n,a[i]%=n;
		if(!s)break;
		ans+=s;
		for(int i=1;i<=n;++i)a[i]+=s-b[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;

namespace AtCoder 
{
    class Program
    {
        static void Main()
        {
            long answer = 1;
            int divNum = (int)Math.Pow(10.0, 9.0) + 7;

            int n = int.Parse(Console.ReadLine());
            
            for (var i = 2; i <= n; i++)
            {
                answer *= i;

                if (divNum < answer)
                {
                    answer %= divNum;
                }
            }


            Console.WriteLine(answer);
        }
    }
} 

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,j,k[6],f=0;
  for(i = 0; i < 6; i++) scanf("%d",&k[i]);
  //一番遠いところからループを回す。
  //全探索
  for(i = 4; i > 0; i--)
  {
    if(f==1) break;
    for(j = i-1; j >= 0; j--)
    {
      if(f==1) break;
      if(k[i]-k[j]>k[5]) 
      {
        f++;
        printf(":(");
        break;
      }
      
    }
    
  }
  if(f==0) printf("Yay!");

  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
    	string[] param = Console.ReadLine().Split(' ');
      	int p = int.Parse(param[0]);
        int q = int.Parse(param[1]);
        int r = int.Parse(param[2]);
      	
      	int answer = 0;
      	if ((p + q) > (q + r)) {
        	answer = ((q + r) > (p + r)) ? (p + r) : (q + r);
        }
      	else {
        	answer = ((p + q) > (p + r)) ? (p + r) : (p + q);
        }
      
      	Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092