akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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




int main(){
    string S;
    cin >> S;
    int N = S.size();
    int ans = 0;
    int streak = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'A'){
            streak++;
        }
        else if(S[i] == 'T'){
            streak++;
        }
        else if(S[i] == 'C'){
            streak++;
        }
        else if(S[i] == 'G'){
            streak++;
        }
        else{
            ans = max(ans, streak);
            streak = 0;
        }
    }
    ans = max(ans, streak);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace AtCoder0614
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);

            //鶴の数T　亀の数Kとして
            int cnt = 0; //個数判定

            for (var t = 0; t <= X; t++)
            {
                for (var k = 0; k <= X - t; k++)
                {
                    if (t + k == X && 2 * t + 4 * k == Y)
                    {
                        cnt++;
                    }
                }
            }

            if (cnt == 0)
            {
                Console.WriteLine("No");
            }
            else {
                Console.WriteLine("Yes");
            }


        }
    }
}



Measured memory_bytes: 27468
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n;
    cin>>n;
    unordered_map<string,int> m1;
    string a[] = {"AC","WA","TLE","RE"};
    for (int i = 0; i < n; i++)
    {
        string x;
        cin>>x;
        m1[x]++;
    }
    for (int i = 0; i < 4; i++)
    {
        string s = a[i];
        cout<<s<<" x "<<m1[s]<<"\n";        
    }
    


    return 0;
}

Measured memory_bytes: 3660
/*                        
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/     

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {
    
    FASTIO;
    
    ll n, x, t, tm=0;
    cin >> n >> x >> t;
    while(n>0){
        tm += t;
        n -= x;
    }
    
    cout << tm << endl;
    
    
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,a,b,c,d;
    cin >>n>>a>>b>>c>>d;
    string s;cin >>s;
    a--;b--;c--;d--;
    bool sunuke=true;
    bool hunuke=true;
    int now=0;
    for (int i = 0; i < n; ++i) {
        if(i<a)continue;
        if(i>c)break;
        if(s[i]=='#')now++;
        else {
            if(now>=2)sunuke=false;
            now=0;
        }
    }
    if(now>=2)sunuke=false;
    swap(a,b);
    swap(c,d);
    now=0;
    for (int i = 0; i < n; ++i) {
        if(i<a)continue;
        if(i>c)break;
        if(s[i]=='#')now++;
        else {
            if(now>=2)hunuke=false;
            now=0;
        }
    }
    swap(a,b);
    swap(c,d);
    now=0;
    bool flg=false;
    if(c>d){
        for (int i = b-1; i <=d+1; ++i) {
            if(s[i]=='.')now++;
            else {
                if(now>=3)flg=true;
                now=0;
            }
        }
        if(now>=3)flg=true;
    }
    if(c<d){
        if(sunuke&&hunuke)puts("Yes");
        else puts("No");
    }
    else {
        if(sunuke&&hunuke&&flg)puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3760
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define pf psuh_front
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

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

const ll N = 2 * 1e5 + 7;
const ld pi = 3.14159265359;
const int INF = 1e20 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n, a[N], x, ans;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> x;

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

  for(int i = 1; i <= n; i++){

    ll sum = a[i] + a[i + 1];

    if(sum > x){
      ans += sum - x;
      a[i + 1] = a[i + 1] - (a[i] + a[i + 1] - x);
    }
  }

  cout << ans;
}


Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<LL> A,B,C;

LL ans = 0;

void solve(){
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	//Bのi番目の数と組めるAの要素の数をB_cand[i]とおく
	vector<LL> B_cand(N);
	for(int i=0;i<N;i++){
		B_cand[i] = upper_bound(A.begin(),A.end(),B[i]-1) - A.begin();
	}

	//B[0]~B[i-1]の和をaccum[i]とおく
	vector<LL> accum(N+1);
	for(int i=0;i<N;i++){
		accum[i+1] = accum[i] + B_cand[i];
	}

	for(int i=0;i<N;i++){
		int B_index = upper_bound(B.begin(),B.end(),C[i]-1) - B.begin();
		if(B_index==-1) continue;
		ans += (accum[B_index]);
	}
}
 
int main(){
    cin >> N;
    A = vector<LL>(N);
    B = vector<LL>(N);
    C = vector<LL>(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N;i++) cin >> C[i];
 
    solve();

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

Measured memory_bytes: 4096
import math


def isprime(x):
    for i in range(2,int(math.sqrt(x)) + 1):
        if x % i == 0:
            return 0
    return 1


n = int(input())
cnt = 0
for i in range(n):
    x = int(input())
    if isprime(x):
        cnt += 1
print(cnt)


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

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

ans = [0] * N

max_y = 10000+1
max_z = 10000+1

for x in range(1, 10000+1):
    if x >= max_y:
        break
    for y in range(x, 10000+1):
        if y >= max_z:
            max_y = y
            break
        for z in range(y, 10000+1):
            thr = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if thr > N:
                max_z = z
                break
            if x==y and y==z:
                ans[thr-1] += 1
            elif x==y or y==z:
                ans[thr-1] += 3
            else:
                ans[thr-1] += 6

for a in ans:
    print(a)


Measured memory_bytes: 9308
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	array := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Println(array[k-1])
}


Measured memory_bytes: 512
from collections import defaultdict


def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out


def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

if __name__ == "__main__":
    main()

Measured memory_bytes: 197240
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)

N = int(input())
graph = [[] for _ in range(N)]
numOfEdges = [0 for _ in range(N)]
visited = [0 for _ in range(N)]
edges = defaultdict(int)

for i in range(1, N):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    numOfEdges[a] += 1
    numOfEdges[b] += 1
    edges[(a, b)] = 0
    graph[a].append(b)
    graph[b].append(a)

def dfs(prev, now, col):
    if visited[now]:
        return
    visited[now] = 1
    i = 1
    for adj in graph[now]:
        if adj == prev:
            continue
        if now < adj:
            edges[(now, adj)] = col + i
        else:
            edges[(adj, now)] = col + i
        dfs(now, adj, col+i)
        i += 1

dfs(-1, 0, 1)
maxColor = max(numOfEdges)
print(maxColor)

for k, i in edges.items():
    e = i % maxColor
    if e:
        print(e)
    else:
        print(maxColor)


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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int N;
  cin >> N;
  //   vector<string> vec(N);
  map<string, bool> mp;
  rep(i, N) {
    string tmp;
    cin >> tmp;
    if (mp.count(tmp) == 0) {
      mp[tmp] = true;
    }
  };
  cout << mp.size() << endl;
}

Measured memory_bytes: 19256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}



int n, arr[3][100];
char str[3][100];


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

    cin>>n;
    cin>>(str[1]+1)>>(str[2]+1);

    if(n == 1){
    	cout<<"3";
    	return 0;
    }

    ll ans = 0;
    int i = -1;
    if(str[1][1] == str[2][1]){
    	ans = 3;
    	i = 2;
    }
    else{
    	ans = 6;
    	i = 3;
    }

    while(i <= n){

    	if(str[1][i] == str[2][i]){
    		if(str[1][i-1] == str[2][i-1]){
    			ans = (ans * 2) % MOD;
    		}
    		else{
    			ans = (ans * 1) % MOD;
    		}
    		i += 1;
    	}
    	else{
    		if(str[1][i-1] == str[2][i-1]){
    			ans = (ans * 2) % MOD;
    		}
    		else{
    			ans = (ans * 3) % MOD;
    		}
    		i += 2;
    	}
    }

    cout<<ans;
    return 0;
}







 




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

#define debug(x) cerr << #x << ": " << x << "\n"
#define all(a) a.begin() ,a.end()
#define rall(a) a.rbegin() ,a.rend()
#define _sort(a) sort(a.begin() ,a.end())

using namespace std;

using ll = long long;
using vi = vector<int>;
using vii = vector<int ,int>;

int main(){
    ios::sync_with_stdio(false) ,cin.tie(0);
    long long int n ,k,d,mn = 1e18;
    cin >> n >> k;
    mn = n = n % k;
    while(true){
        d = abs(n-k);
        if(d < mn)mn = d;
        else break;
        n = mn;
    }
    cout << mn;
}
/*
*   created: 2020-04-04 17:24:49
*/

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d){
		cout << "Left" << endl;
	}else if(a+b == c+d){
		cout << "Balanced" << endl;
	}else{
		cout << "Right" << endl;
	}
}

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

using namespace std;

bool check_a(vector<int> &va, int m) {
  int max_n = *max_element(va.begin(), va.end());
  if (max_n > m) {
    return false;
  }

  for (int i = 1; i < va.size(); ++i) {
    if (va[i] < va[i - 1]) {
      return false;
    }
  }

  return true;
}

bool next_va(vector<int> &va, int m) {
  int i = va.size() - 1;
  while (i >= 0 && va[i] >= m) {
    i--;
  }

  if (i < 0) {
    return false;
  }

  va[i]++;

  fill(va.begin() + i, va.end(), va[i]);
  return true;
}

long long calc_rank(vector<int> &va, vector<array<int, 4>> &abcd) {
  long long ans = 0;
  for (auto [a, b, c, d] : abcd) {
    if (va[b] - va[a] == c) {
      ans += d;
    }
  }

  return ans;
}

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

  vector<array<int, 4>> abcd(q);
  for (int i = 0; i < q; ++i) {
    cin >> abcd[i][0];
    cin >> abcd[i][1];
    cin >> abcd[i][2];
    cin >> abcd[i][3];
    abcd[i][0]--;
    abcd[i][1]--;
  }

  sort(abcd.begin(), abcd.end(),
       [](auto &p1, auto &p2) { return p1[3] > p2[3]; });
  vector<int> va(n, 1);
  long long ans = 0;
  do {
    ans = max(ans, calc_rank(va, abcd));
  } while (next_va(va, m));

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

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right

if __name__ == '__main__':

    P = [tuple(map(int, input().split())) + (i,)
         for i in range(int(input()))]  # (x,y,i)
    P.sort()
    root = int(math.sqrt(len(P)))
    low = [x for x, y, i in P[::root]]
    high = [x for x, y, i in P[root - 1::root]] + [float('inf')]

    # disjoint subsets (ordered by y) of P
    P = [sorted(P[i:i + root], key=itemgetter(1))
         for i in range(0, len(P), root)]
    P = [([y for x, y, i in Pi], Pi)
         for Pi in P]  # ([y in subsets], [subsets])
    q = int(input())
    Q = [list(map(int, input().split(" "))) for _ in range(q)]

    for sx, tx, sy, ty in Q:
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = P[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <= tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str, ret)))
        print()



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

    boolean j = false;
    int ans = 0;
    
    int a[] = new int[n];
    for(int i = 0; i < n; ++i){
      a[i] = sc.nextInt();
    }

    Arrays.sort(a);
    
    for(int i = 0; i < n; ++i){
	  if(a[i] <= x ){
        x -= a[i];
        ans++;
        
      }else{
        j = true;
        break;
      }
    }
    
    if(x > 0 && j==false){
      System.out.println(ans-1);
    }else{
      System.out.println(ans);
    }

        
  }
}

Measured memory_bytes: 35904
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        k: usize,
        mut s: String,
    }
    let result = if s.len() <= k { s } else { 
        s.truncate(k);
        s.push('.');
        s.push('.');
        s.push('.');
        s
     };
    println!("{}", result);
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n,i,j;
  cin >> n;
  vector<int> v(n);
  for(i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.rbegin(),v.rend());
  long long r = 1;
  for(i=0;i<n&&(j=v[i]-i/4)>0;i++)r+=j;
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if (a == b && b == c || a != b && b != c && c != a) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23124
n=int(input())

N=[0]*(n+1)

def f(n):
    M=[]
    while n%2==0:
        n//=2
        M.append(2)
    i=3
    while n>=i:
        while n%i==0:
            n//=i
            M.append(i)
        i+=2
    return M

for i in range(2,n+1):
    for j in f(i):
        N[j]+=1

ANS=[0]*5

for i in range(1,n+1):
    if N[i]>=74:
        ANS[0]+=1
    elif N[i]>=24:
        ANS[1]+=1
    elif N[i]>=14:
        ANS[2]+=1
    elif N[i]>=4:
        ANS[3]+=1
    elif N[i]>=2:
        ANS[4]+=1

ANS[1]+=ANS[0]
ANS[2]+=ANS[1]
ANS[3]+=ANS[2]
ANS[4]+=ANS[3]

print(ANS[0]+ANS[1]*(ANS[4]-1)+ANS[2]*(ANS[3]-1)+(ANS[3]*(ANS[3]-1)//2)*(ANS[4]-2))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

void dfs(vector<vi>& c, vector<vi>& d, int i, int j, int cnt) {
	stack<pii> st;
	st.push(pii(i, j));
	int di[] = {0, 1, 1, 1, 0, -1, -1, -1};
	int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};
	while(!st.empty()) {
		pii p = st.top();
		st.pop();
		int si = p.first;
		int sj = p.second;
		rep(k, 8) {
			if(c[si+di[k]][sj+dj[k]] == 0) continue;
			if(d[si+di[k]][sj+dj[k]] != 0) continue;
			d[si+di[k]][sj+dj[k]] = cnt;
			st.push(pii(si+di[k], sj+dj[k]));
		}
	}
}

int cnt(vector<vi>& c) {
	int h = c.size();
	int w = c[0].size();
	vector<vi> d(h, vi(w, 0));
	int cnt = 0;
	rep(i, h) rep(j, w) if(c[i][j] && d[i][j] == 0) dfs(c, d, i, j, ++cnt);
	return cnt;
}

int main() {
//	cout << fixed << setprecision(15);
	int w, h;
	vi ans;
	while(true) {
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		vector<vi> c(h + 2, vi(w + 2, 0));
		rep(i, h) rep(j, w) cin >> c[i+1][j+1];
		ans.push_back(cnt(c));
	}
	for(auto i : ans) cout << i << endl;
}



Measured memory_bytes: 3196
#include <iostream>
#include <string>

using namespace std;



int n;
string S;
long int anan = 0;




void susu(int i, int start, int num,  long int an){
    
   
    if (i == n-1) {
        an += atol(S.substr(start, num).c_str());

        
        anan += an;
      
        return;
        
    }else{
        
        susu(i+1, start, num+1, an);
        susu(i+1, start+num, 1, an + atoi(S.substr(start, num).c_str()));
        
    }
    
}




int main(){

    cin >> S;
    
    n = S.length();
    
    susu(0, 0, 1, 0);
    
    cout << anan << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	for j in range(n-i-1, -1, -1):
		if a[j] == j+1:
			ans.append(j+1)
			a.pop(j)
			break
	else:
		print(-1)
		sys.exit()
print(*ans[::-1], sep="\n")

Measured memory_bytes: 3064
program main
  implicit none
  integer(8) :: n, i, j, cnt(26), res
  integer(8), parameter :: m = 10 ** 9 + 7
  character(100000) :: s

  read (*, *) n
  read (*, *) s

  cnt(:) = 1
  do i = 1, n
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j) = cnt(j) + 1
  end do

  res = 1
  do i = 1, 26
    res = res * cnt(i)
    res = mod(res, m)
  end do
  write (*, "(i0)") mod(res - 1, m)

end program main


Measured memory_bytes: 700
H,W = map(int,input().split())
ans = float('inf')
for i in range(1,H):
    a = i*W
    if H-i % 2 == 0 or W % 2 == 0:
        b = (H-i)*W//2
        c = b
    else:
        b = ((H-i)*W - min(H-i,W))//2
        c = ((H-i)*W + min(H-i,W))//2
    ans = min(ans,max(a,b,c)-min(a,b,c))
H,W = W,H
for i in range(1,H):
    a = i*W
    if H-i % 2 == 0 or W % 2 == 0:
        b = (H-i)*W//2
        c = b
    else:
        b = ((H-i)*W - min(H-i,W))//2
        c = ((H-i)*W + min(H-i,W))//2
    ans = min(ans,max(a,b,c)-min(a,b,c))
if H%3 == 0 or W%3 == 0:
    ans = 0
print(ans)

Measured memory_bytes: 3064
import itertools

def check(targets):
    if targets[1] > targets[0] and targets[2] > targets[1]:
        return True
    else:
        return False


if __name__ == "__main__":
    A, B, C = map(int, input().split())
    K = int(input())
    targets = [A, B, C]
    answer = 'No'

    cases = itertools.product([0, 1, 2], repeat=K)
    for case in cases:
        copy_targets = targets.copy()
        for i in case:
            copy_targets[i] = copy_targets[i] * 2
        if check(copy_targets):
            answer = 'Yes'
            break

    print(answer)

Measured memory_bytes: 9208
import sys;input=sys.stdin.readline
S=input().strip()
n=len(S)
Qs = []
for c in S:
    Qs.append((1,1,c))
for q in range(int(input())):
    x = input().strip().split()
    if len(x) == 1:
        Qs.append((0,0,0))
    else:
        n+=1
        Qs.append((1,int(x[1])-1,x[2]))

rs = [0]*n
i,j=0,n-1
f=1
for t, tt, c in Qs[::-1]:
    if t==0:
        f=1-f
    else:
        if (tt+f)%2:
            rs[i] = c
            i+=1
        else:
            rs[j] = c
            j -= 1
print("".join(rs))


Measured memory_bytes: 114632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b;cin>>a>>b;
    for(int i=1;i<10000;i++){
        ll c=i*0.08;ll d=i*0.1;
        if(a==c&&b==d){
            cout<<i<<"\n";return 0;
        }
    }
    cout<<"-1\n";
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int count = 0;
		for(int i = 0; i < N; i++){
			count += (isPrime(scan.nextInt()) ? 1 : 0);
		}
		System.out.println(count);
	}
	public static boolean isPrime(int a){
		for(int i = 2; i * i <= a; i++){
			if(a % i == 0){
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 31260
#include <bits/stdc++.h>
using namespace std;
int n,now,ans=0;
int main()
{
    scanf("%d",&n);
    now=n;
    for (int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        now=min(now,x);
        if (x<=now) ++ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <functional>
#include <numeric>
#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    int n,ans;
    ans = 0;
    cin >> n ;
    if(n==0){
        ans = 1;
    }
    
    cout << (ans) << endl;
}

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

template<typename T>
class Stack{
 public:
    Stack(const int capacity){
        data_.resize(capacity);
        top_ = 0;
    }
    void Initialize(){
        top_ = 0;
    }
    inline bool IsFull(){
        return top_ >= data_.size();
    }
    inline bool IsEmpty(){
        return top_ == 0;
    }
    T Pop(){
        if(IsEmpty())
            exit(1);
        return data_.at(top_--);
    }
    void Push(const T &d){
        if(IsFull())
            exit(1);
        top_ += 1;
        data_.at(top_) = d;
    }
    int Size(){
        return top_;
    }

 private:
    int top_;
    std::vector<T> data_;
};

int main(){
    Stack<int> stack(128);
    std::string in;
    while(std::cin >> in){
        if(in == "+"){
            int a, b;
            a = stack.Pop();
            b = stack.Pop();
            stack.Push(b + a);
        }else if(in == "-"){
            int a, b;
            a = stack.Pop();
            b = stack.Pop();
            stack.Push(b - a);    
        }else if(in == "*"){
            int a, b;
            a = stack.Pop();
            b = stack.Pop();
            stack.Push(b * a);
        }else{
            stack.Push(std::stoi(in));
        }
    }
    std::cout << stack.Pop() << std::endl;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
// Crt. 2019-12-28  21:20:54
#include <bits/stdc++.h>
using namespace std;

int n;

const char a4[10][10] = { "aaef",
                          "bbef",
                          "cdgg",
                          "cdhh",
};

const char a5[10][10] = { "aeeff",
                          "ad..g",
                          "bd..g",
                          "b.jjh",
                          "cciih",
};

const char a6[10][10] = { "wwhhyy",
                          ".a.b.c",
                          ".a.b.c",
                          "d.e.f.",
                          "d.e.f.",
                          "xxqqyy",
};

const char a7[10][10] = { ".xxyyqq",
                          "wejj...",
                          "we.a...",
                          "yrra...",
                          "y...lrr",
                          "h...l.l",
                          "h...yyl",
};

char ans[2000][2000];

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;

    if (n <= 2) return puts("-1"), 0;

    if (n == 3) {
        puts("a..");
        puts("a..");
        puts(".bb");
        return 0;
    }

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            ans[i][j] = '.';

    if (n % 4 == 0) {
        for (int i = 0; i < n; i += 4)
            for (int j = i; j <= i + 3; ++j)
                for (int k = i; k <= i + 3; ++k)
                    ans[j][k] = a4[j - i][k - i];
    }

    if (n % 4 == 1) {
        for (int i = 0; i < 5; ++i)
            for (int j = 0; j < 5; ++j)
                ans[i][j] = a5[i][j];

        for (int i = 5; i < n; i += 4)
            for (int j = i; j <= i + 3; ++j)
                for (int k = i; k <= i + 3; ++k)
                    ans[j][k] = a4[j - i][k - i];
    }

    if (n % 4 == 2) {
        for (int i = 0; i < 6; ++i)
            for (int j = 0; j < 6; ++j)
                ans[i][j] = a6[i][j];

        for (int i = 6; i < n; i += 4)
            for (int j = i; j <= i + 3; ++j)
                for (int k = i; k <= i + 3; ++k)
                    ans[j][k] = a4[j - i][k - i];

    }

    if (n % 4 == 3) {

        for (int i = 0; i < 7; ++i)
            for (int j = 0; j < 7; ++j)
                ans[i][j] = a7[i][j];

        for (int i = 7; i < n; i += 4)
            for (int j = i; j <= i + 3; ++j)
                for (int k = i; k <= i + 3; ++k)
                    ans[j][k] = a4[j - i][k - i];

    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            printf("%c", ans[i][j]);
        puts("");
    }

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1000000007; // 998244353 = (119<<23)+1
// head
const int nax=1e5+7;
int n,s[nax],g[nax];
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		rep(i,n) cin>>s[i];
		int k=s[n-1];
		for(int i=n-1;i>=0;i--) {
			k=__gcd(k,s[i]);
			g[i]=k;
		}
		int ans=max(k,g[1]);
		k=s[0];
		repn(i,n-2) {
			ans=max(ans,__gcd(k,g[i+1]));
			k=__gcd(k,s[i]);
		}
		cout<<max(ans,k);
		return 0;
}

Measured memory_bytes: 1152
//Matrix Chain Multiplication
//Ebitani Akira

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

#define MAX 100
#define N 128

int M[N][N];
int P[N];
int n;

int main(){
  int i, j, k, l;
  int ans;

  scanf("%d", &n);
  if(n < 1 || n > MAX){
    printf("行列の数が適当ではありません。\n");
    exit(1);
  }

  for(i = 1 ; i <= n ;i++){
    scanf("%d%d", &P[i-1], &P[i]);
    if(P[i-1] > MAX || P[i] > MAX || P[i-1] < 1 || P[i] < 1){
      printf("行列の行または列の値が適当ではありません。\n");
      exit(2);
    }
  }

  for(i = 1 ; i <= n ; i++)
    M[i][i] = 0;
  for(l = 2 ; l <= n ; l++){
    for(i = 1 ; i <= n - l + 1 ; i++){
      j = i + l - 1;
      M[i][j] = 2147483647;

      for(k = i ; k <= j-1 ; k++){
        ans = M[i][k] + M[k+1][j] + P[i-1] *P[j] * P[k];


        if(M[i][j] > ans)
          M[i][j] = ans;
        else
            continue;
        }
      }
    }
    printf("%d\n", M[1][n]);

    return 0;
}



Measured memory_bytes: 2048
n = int(input())
slist = [input() for i in range(n)]

ans = [0 for i in range(4)]

for i in slist:
  if (i == 'AC'):
    ans[0] = ans[0] + 1
  if (i == 'WA'):
    ans[1] = ans[1] + 1
  if (i == 'TLE'):
    ans[2] = ans[2] + 1
  if (i == 'RE'):
    ans[3] = ans[3] + 1


for i in range(4):
  if(i == 0):
    print("AC x " + str(ans[i]))
  if(i == 1):
    print("WA x " + str(ans[i]))
  if(i == 2):
    print("TLE x " + str(ans[i]))
  if(i == 3):
    print("RE x " + str(ans[i]))

Measured memory_bytes: 79308
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///


#include<bits/stdc++.h>

#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define sf(n) scanf("%d", &n);
#define sff(n, m) scanf("%d %d", &n, &m);
#define pf(n) printf("%d", n);
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)  /// type rep(t, 1, n+1) when t is to be iterated from 1 to n
#define rrep(q, i, n) for(int q=i; q>n; q--)
#define mems(a,x) memset(a,x,sizeof(a))
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>
#define pll pair<ll,ll>

#define watch(x) cout << (#x) << " is " << (x) << endl

#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define PI 2*acos(0.0)

#define mx 100005
#define MAX 1000000005
#define inf 1e9
#define INF 1e18
#define MOD 1000000007
//#define MOD 4294967296another
#define MIN 0


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}
/**-----------------------------------------------------------------------------------------------**/

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);


    int a[n];

    rep(i, 0, n)
    {
        scanf("%d", &a[i]);
    }



    sort(a, a+n);


    int ans = a[n/2]-a[n/2-1];

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    int ans=0;
    for(int i=c; i<=d;i++)if(a<=i&&i<=b)ans++;
    cout<<max(0,ans-1)<<endl;
}

Measured memory_bytes: 256
def c_h_and_v():
    from itertools import combinations
    H, W, K = [int(i) for i in input().split()]
    C = [input() for _ in range(H)]

    ans = 0
    for row_num in range(H + 1):
        for rows in combinations(range(H), row_num):
            for col_num in range(W + 1):
                for cols in combinations(range(W), col_num):
                    tmp = 0
                    for r in range(H):
                        for c in range(W):
                            if r in rows or c in cols:
                                continue
                            if C[r][c] == '#':
                                tmp += 1
                    if tmp == K:
                        ans += 1

    return ans

print(c_h_and_v())

Measured memory_bytes: 68932
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> points[100005];

int maxPossible(int num){
    int a = points[0][0];
    int b = points[0][1];
    int c = points[0][2];
    
    for(int i=1;i<num;i++){
        int ans1 = points[i][0] + max(b,c);
        int ans2 = points[i][1] + max(a,c);
        int ans3 = points[i][2] + max(a,b);
        
        a = ans1;
        b = ans2;
        c = ans3;
    }
    return max(a,max(b,c));
}

void solve(){
    int num;
    cin>>num;
    for(int i=0;i<num;i++){
        int a,b,c;
        cin>>a>>b>>c;
        points[i].push_back(a);
        points[i].push_back(b);
        points[i].push_back(c);
    }
    cout<<maxPossible(num);
}

int main()
{

    
    solve();
    
    return 0;
}


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

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

    bool flag = false;
    for (int i = 0; i <= n / 4; i++) {
        if ((n - 4 * i) % 7 == 0) flag = true;
    }

    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
#define INF 1e10
#define EPS 1e-10
#define EQ(a,b) (fabs((a)-(b))<EPS)

double dist[1000][1000];
int id[1000],x[1000],y[1000];

double Distance(int i,int j){
	return sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}


int main(){
	int n;
	while(cin>>n&&n){
		for(int i=0;i<n;i++)cin>>id[i]>>x[i]>>y[i];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			double d=Distance(i,j);
			dist[i][j]=(d<50+EPS?d:INF);
		}
		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
			dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		int m;
		cin>>m;
		for(int i=0;i<m;i++){
			int s,g;
			cin>>s>>g;
			for(int i=0;i<n;i++){
				if(s==id[i]){
					s=i;
					break;
				}
			}
			for(int i=0;i<n;i++){
				if(g==id[i]){
					g=i;
					break;
				}
			}
			if(dist[s][g]==INF){
				cout<<"NA\n";
				continue;
			}
			stack<int> st;
			int v=g;
			while(v!=s){
				for(int i=0;i<n;i++){
					if(i==v)continue;
					double d=Distance(i,v);
					if(d<50+EPS && EQ(dist[s][v],dist[s][i]+d)){
						st.push(v);
						v=i;
						break;
					}
				}
			}
			cout<<id[s];
			while(!st.empty()){
				cout<<' '<<id[st.top()];
				st.pop();
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1684
import math

K=int(input())
num=0
for i in range(1,K+1):
  for j in range(1,K+1):
    gcd_2=math.gcd(i,j)
    for k in range(1,K+1):
      gcd_3=math.gcd(gcd_2,k)
      num=num+gcd_3
print(num)
      

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc011_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, C, K;
  cin >> N >> C >> K;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end());

  int waiting = 0;
  ll ans = 0;
  rep(i, N) {
    if(i - waiting >= C || c[i] - c[waiting] > K) {
      ans++;
      waiting = i;
    }
  }
  ans++;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>

int main()
{
    int X;
    std::cin >> X;

    int b = 2;
    int p = 1;
    int ans = 1;
    int border = (int)std::sqrt(X) + 1;
    for (int i = 0; i < X; i++)
    {
        int num = X;
        while (b < border)
        {
            if (num / b > 0)
            {
                num /= b;
                p *= b;
            }
            else
            {
                ans = std::max(ans, p);
                b++;
                p = 1;
                break;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
    std::string s;
    std::cin >> s;
    int l = s.length();
    int out = 0;
int wsum = 0;
for(int i = 0; i < l; i++){
    if(s[i] == 'W'){
        out += i - wsum;
        wsum++;
    }
}
std::cout << out << std::endl;
return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n,k;
  cin >> n >> k;
  vector<bool>s(n);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int num;
      cin >> num;
      num--;
      s[num] = true;
    }
  }
  ll ans = 0;
  rep(i,n)if(!s[i])ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604