akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

ll n,k,l;
ll a,b;
vector<vector<ll> > r;
vector<vector<ll> > t;
vector<ll> ra;
vector<ll> ta;

void dfsr(int c,int p,int color){
    ra[c] = color;
    rep(i,r[c].size()){
        if(r[c][i] != p && ra[r[c][i]] == -1){ 
            dfsr(r[c][i],c,color);
        }
    }
}

void dfst(int c,int p,int color){
    ta[c] = color;
    rep(i,t[c].size()){
        if(t[c][i] != p && ta[t[c][i]] == -1){
            dfst(t[c][i],c,color);
        }
    }
}

int main(){
    
    cin >> n >> k >> l;
    r.resize(n);
    t.resize(n);
    rep(i,k){
        cin >> a >>b;
        a--;b--;
        r[a].pb(b);
        r[b].pb(a);
    }  
    rep(i,l){
        cin >> a >> b;
        a--;b--;
        t[a].pb(b);
        t[b].pb(a);
    }

    ra.resize(n);
    ta.resize(n);

    fill(all(ra),-1);
    fill(all(ta),-1);

    ll cnt = -1;

    rep(i,n){
        if(ra[i] == -1){
            cnt++;
            dfsr(i,-1,cnt);
        }
    }
    
    cnt = -1;

    rep(i,n){
        if(ta[i] == -1){
            cnt++;
            dfst(i,-1,cnt);
        }
    }

    map<pair<ll,ll>,ll> m;

    for(int i = 0;i < n;i++){
        m[mp(ra[i],ta[i])]++;
    }
    rep(i,n){
        cout << m[mp(ra[i],ta[i])] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 30336
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		boolean[] fs=new boolean[10001];
		for(int i=0; i<10001; i++){
			fs[i]=isPrime(i-2)&&isPrime(i);
		}

		for(; sc.hasNext();){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			for(; !fs[n]; n--);
			println((n-2)+" "+n);
		}
	}

	boolean isPrime(int n){
		for(int i=2; i*i<=n; i++){
			if(n%i==0){
				return false;
			}
		}
		return n>=2;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int main()
{
  long N,i,total;
  scanf("%ld",&N);
  long AA[N],AC[N],AG[N],AT[N];
  long CA[N],CC[N],CG[N],CT[N];
  long GA[N],GC[N],GG[N],GT[N];
  long TA[N],TC[N],TG[N],TT[N];
  
  AA[1]=1;
  AC[1]=1;
  AG[1]=1;
  AT[1]=1;
  
  CA[1]=1;
  CC[1]=1;
  CG[1]=1;
  CT[1]=1;
  
  GA[1]=1;
  GC[1]=1;
  GG[1]=1;
  GT[1]=1;
  
  TA[1]=1;
  TC[1]=1;
  TG[1]=1;
  TT[1]=1;
  
  AA[2]=4;
  AC[2]=3;
  AG[2]=4;
  AT[2]=4;
  
  CA[2]=4;
  CC[2]=4;
  CG[2]=3;
  CT[2]=4;
  
  GA[2]=4;
  GC[2]=3;
  GG[2]=4;
  GT[2]=4;
  
  TA[2]=4;
  TC[2]=4;
  TG[2]=4;
  TT[2]=4;
  
  if(N>3){
	for(i=3; i<N; i++){
      AA[i]=(AA[i-1]+CA[i-1]+GA[i-1]+TA[i-1])%1000000007;
      AC[i]=(AA[i-1]+CA[i-1]+        TA[i-1])%1000000007;
      AG[i]=(AA[i-1]+CA[i-1]+GA[i-1]+TA[i-1])%1000000007;
      AT[i]=(AA[i-1]+CA[i-1]+GA[i-1]+TA[i-1])%1000000007;
      
      CA[i]=(AC[i-1]+CC[i-1]+GC[i-1]+TC[i-1])%1000000007;
      CC[i]=(AC[i-1]+CC[i-1]+GC[i-1]+TC[i-1])%1000000007;
      CG[i]=(        CC[i-1]+GC[i-1]+TC[i-1])%1000000007;
      CT[i]=(AC[i-1]+CC[i-1]+GC[i-1]+TC[i-1])%1000000007;
      
      GA[i]=(AG[i-1]+CG[i-1]+GG[i-1]+TG[i-1])%1000000007;
      GC[i]=(        CG[i-1]+GG[i-1]+TG[i-1]-AT[i-2]-AG[i-2])%1000000007;
      GG[i]=(AG[i-1]+CG[i-1]+GG[i-1]+TG[i-1])%1000000007;
      GT[i]=(AG[i-1]+CG[i-1]+GG[i-1]+TG[i-1])%1000000007;
      
      TA[i]=(AT[i-1]+CT[i-1]+GT[i-1]+TT[i-1])%1000000007;
      TC[i]=(AT[i-1]+CT[i-1]+GT[i-1]+TT[i-1]-AG[i-2])%1000000007;
      TG[i]=(AT[i-1]+CT[i-1]+GT[i-1]+TT[i-1])%1000000007;
      TT[i]=(AT[i-1]+CT[i-1]+GT[i-1]+TT[i-1])%1000000007;
  	}
  }
  
  total = AA[N-1]+AC[N-1]+AG[N-1]+AT[N-1]+CA[N-1]+CC[N-1]+CG[N-1]+CT[N-1]+GA[N-1]+GC[N-1]+GG[N-1]+GT[N-1]+TA[N-1]+TC[N-1]+TG[N-1]+TT[N-1];
  printf("%ld",total%1000000007);
    return 0;
}

Measured memory_bytes: 128
using System;

namespace A___Red_or_Not
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}


Measured memory_bytes: 11092
n,m = map(int, input().split())
S = []
C = []
for i in range(m):
    s,c = map(int, input().split())
    S.append(s)
    C.append(c)

flag = True
x = 0

for i in range(1000):
    x = i
    d = []
    flag = True
    if x == 0:
        d.append(x)
    while x != 0:
        num = x % 10
        d.append(num)
        x = x // 10
    d = d[::-1]
    if len(d) != n:
        flag = False
        continue
    for j in range(m):
        try:
            if d[S[j]-1] == C[j]:
                pass
            else:
                flag = False
        except IndexError:
            flag = False
    if flag:
        x = i
        break
print(x if flag else -1)

Measured memory_bytes: 3064
#include<stdio.h>
int abs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int h, w, d;
	scanf("%d %d %d", &h, &w, &d);
	int i, j;
	int a[302][302];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			scanf("%d", &a[i][j]);
	int x[90004], y[90004];
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			x[a[i][j]] = i;
			y[a[i][j]] = j;
		}
	}
	int v[90004];
	for (i = 1; i <= d; i++)
		v[i] = 0;
	for (i = d + 1; i <= h * w; i++)
		v[i] = v[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
	int q;
	scanf("%d", &q);
	int l, r;
	int ans[100005];
	for (i = 0; i < q; i++)
	{
		scanf("%d %d", &l, &r);
		ans[i] = v[r] - v[l];
	}
	for (i = 0; i < q; i++)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j, k;
	long int x;
	long int a, b;
	long int work;
	long int flg = 0;
	
	scanf("%ld", &x);
	
	a = b = 0;
	
	for(i = 0; i <= 2 * (long int)sqrt( (long int)sqrt(x) + 1 ) + 1; i++) {
		for(j = 0; j <= i; j++) {
			if(i * i * i * i * i - x == j * j * j * j * j) {
				a = i;
				b = j;
				flg = 1;
				break;
			}
			
			if(i * i * i * i * i - x == (-1) * j * j * j * j * j) {
				a = i;
				b = (-1) * j;
				flg = 1;
				break;
			}
		}
		if(flg != 0) {
			break;
		}
	}
	
	printf("%ld %ld\n", a, b);
	
	return 0;
}


Measured memory_bytes: 2148
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN];

void solve(){
    cin>>n;
    bool y=0;
    while(n!=0){
        if(n%10==7)y=1;
        n/=10;
    }
    if(y==1)cout<<"Yes";
    else cout<<"No";
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 3672
N=int(input())
sequence=list(range(1,N+1))
for i in range(len(sequence)) :
    num=sequence[i]
    if num %3==0 and num%5==0:
        sequence[i]="FizzBuzz"
    elif num%3==0:
        sequence[i]="Fizz"
    elif num%5==0:
        sequence[i]="Buzz"
total=0
for i in sequence:
    if isinstance(i,int):
        total+=i
print(total)

Measured memory_bytes: 48472
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,x,preCost=0,Cost=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	Cost=abs(a[1]-a[0]);
	for(i=2;i<n;i++){
		x=min(Cost+abs(a[i]-a[i-1]) , preCost+abs(a[i]-a[i-2]));
		preCost=Cost;
		Cost=x;
	}
	cout<<Cost<<endl;

}

Measured memory_bytes: 3880
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		    Scanner sc = new Scanner(System.in);

		    int n = sc.nextInt();
		    if(n % 111 == 0) {
		    	System.out.println(n);
		    }
		    else {
		    	System.out.println(n /111 * 111 + 111);
		    	
		    }
		    
		    sc.close(); }
}


Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#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; cin >> N;
  if (N%2==0) cout << N << endl;
  else cout << 2*N << endl;
  return 0;
}

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

int main() {
    int x, y;
    int ans = 0;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if((2 * i + 4 * (x - i)) == y){
            ans = 1;
            break;
        }
    }
    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
//package com.karancp;

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStream;


 class Main {
    public static void main(String args[])
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader z = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        task solver =new task();
        solver.solve(z,out);
        out.close();
    }

    static class task
    {

        static long gcd(long a,long b)
        {
            if(b==0)return a;
            else return gcd(b,a%b);
        }
        static long lcm(long a,long b)
        {
            long pp=a*b;
            long bb=gcd(a,b);
            long res =pp/bb;
            return res;
        }
        static int max(int a,int b)
        {
            return Math.max(a,b);
        }
        static int min(int a,int b)
        {
            return Math.min(a,b);
        }





        public static void solve(InputReader pp, PrintWriter out) {
         Scanner z=new Scanner(System.in);
         double n=z.nextDouble();
         double k=z.nextDouble();
         double ans=0.000000000000;
         double p=0.5000000000;
         int i;
            DecimalFormat df =new DecimalFormat("#.###############");
         for(i=1;i<=n;i++)
         {
             if(i>=k){
              ans+=(1/n);
             }
            else{ double kk=(k/(i*1.00));
             //kk=Math.ceil(kk);
             kk=Math.log(kk)/Math.log(2);
             kk=Math.ceil(kk);
             int pow=(int)kk;
             ans+=(((1.0)/n)*(Math.pow(p,pow)));}
             //out.println(ans);
         }
         out.print(df.format(ans));
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }

    }



}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int n,i,count=0,bit=0;
  cin >> n;
  int s[n];
  for(i=0;i<n;i++)
  {
    cin >> s[i];
  }
  while(bit == 0)
  {
    for ( i = 0; i < n; i++)
    {
      if(s[i] % 2 == 1)
      {
        bit = 1;
        break;
      }
    }
    if(bit == 1)
    {
      break;
    }
    for ( i = 0; i < n; i++)
    {
      s[i] /= 2;
    }
    count++;
  }
  cout << count;
  return 0;
}

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

using namespace std;

typedef long long ll;

int Q;

void f(int t, int a, int b, int c, int d) {
	c = max(c, 1);
	d = min(d, a+b);
	if (c > d) return;
	if (t == 1) {
		if (a >= b) {
			for (int i = c; i <= d; i++) {
				if (i & 1) putchar('A');
				else putchar('B');
			}
		} else {
			for (int i = c; i <= d; i++) {
				if (i & 1) putchar('B');
				else putchar('A');
			}
		}
		return;
	}
	if (b == a * t) {
		for (int i = c; i <= d; i++) {
			if (i % (t+1) == 1) putchar('A');
			else putchar('B');
		}
		return;
	}
	if (!a) {
		for (int i = c; i <= d; i++) putchar('B');
		return;
	}
	ll _ = (b + a - 1) / a;
	if (_ <= t) {
		int x = (1LL * t * (a+1) - b) / t;
		if (x >= t) {
			int k = (1LL * t * (a+1) - 1LL * t * t - b) / (1LL * t * t - 1) + 1;
			int x = k * (t+1);
			for (int i = c; i <= min(d, x); i++) if (i % (t+1) == 0) putchar('B'); else putchar('A');
			f(t, a - t * k, b - k, c - x, d - x);
		} else {
			for (int i = c; i <= min(d, x); i++) putchar('A');
			f(t, a - x, b, c - x, d - x);
		}
	} else {
		int x = b - t * a;
		for (int i = c; i <= min(d, x); i++) putchar('B');
		f(t, a, a * t, c - x, d - x);
	}
}

int main() {
	scanf("%d", &Q);
	while (Q--) {
		int A, B, C, D;
		scanf("%d%d%d%d", &A, &B, &C, &D);
		int t = 0;
		if (A >= B) t = (A + B) / (B + 1);
		else t = (B + A) / (A + 1);
		f(t, A, B, C, D);
		puts("");
	}
	return 0;
}

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

int calc(int n, int m) {
    int f(int k) {
        return k * (k - 1) / 2;
    }

    int ans = 0;
    if (n >= 2) ans += f(n);
    if (m >= 2) ans += f(m);
    return ans;
}

void main() {
    int n, m; scan(n, m);
    writeln(calc(n, m));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

using namespace std;

typedef long long int ll;

vector <pair <ll,ll> > veca;
int main()
{
    ll n,a,b,b1,c,c1,i,j,k,p,q,minn;
    cin >> a >> b;
    if (abs(a-b)==1||abs(a-b)==0)
        cout << "Yay!\n";
    else
        cout << ":(\n";
}



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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MOD = 1e9+7;
const ll INF = 1e16;

int main() {
    FASTIO

    int n;
    cin >> n;
    vector<bool> v(n);
    for(int i=0; i<n; i++) {
        int x, y;
        cin >> x >> y;
        v[i] = (x == y);
    }
    bool flag = false;
    for(int i=0; i<n-2; i++) {
        if(v[i] && v[i+1] && v[i+2]) {
            cout << "Yes\n";
            flag = true;
            break;
        }
    }
    if(!flag) cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    while (1)
    {
        string temp = to_string(n);
        bool good = true;
        for (int i = 0; i < temp.length() - 1; i++)
            if (temp[i] != temp[i + 1])
                good = false;
        if (good)
        {
            cout << temp;
            return 0;
        }
        n++;
    }
}

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            int N = int.Parse(L[0]);
            int X = int.Parse(L[1]);

            S = Console.ReadLine();
            L = S.Split(' ');
            int res = 0;
            int ans = 1;

            for (int i=0; i<N; i++)
            {
                int Li = int.Parse(L[i]);
                res = res + Li;
                if(res <= X)
                {
                    ans++;
                }
                else
                {
                    break;
                }

            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 11092
// Problem : E - 1 or 2
// Contest : AtCoder - AtCoder Beginner Contest 126
// URL : https://atcoder.jp/contests/abc126/tasks/abc126_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N,M;
	cin>>N>>M;
	vi adj[N+1],vis(N+1);
	map<pi,int> m;
	F0R(x,M)
	{
		int a,b,c;
		cin>>a>>b>>c;
		adj[a].pb(b);
		adj[b].pb(a);
		m[{a,b}]=c;
		m[{b,a}]=c;
	}
	int ans=0;
	
	FOR(x,1,N+1)
	{
		if(!vis[x])
		{
			ans++;
			stack<int> st;
			st.push(x);
			while(sz(st)!=0)
			{
				int S=st.top();
				st.pop();
				vis[S]=1;
				F0R(x,sz(adj[S]))
				{
					int val=adj[S][x];
					if(!vis[val])
					{
						st.push(val);
					}
				}
			}
		}
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 22308
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a[102];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int sum = 0;
	for (i = 0; i < n; i++)
		sum += a[i];
	int cnt = 0;
	for (i = 0; i < n; i++)
		if (a[i] * 4 * m >= sum)
			cnt++;
	if (cnt < m)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
K,N=gets.split.map &:to_i;M=998244353;I=[1,1];*F=I;*R=I
2.upto(N+K){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M}
a=[]
1.upto((K+1)/2){|q|i=q*2+1;[x=0,i-K].max.upto([q,N].min){|t|x=(x+F[q]*R[t]*R[q-t]*F[N+K-i]*R[K-i+t]*R[N-t]*2**t)%M};a<<x}
p *[*o=(1...K).map{|i|a[~-i/2]},a[-1],*o.reverse]

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ll N; cin >> N;
  ll ans = INF;
  for(ll i=1; i <= sqrt(N); ++i) {
    if(N%i == 0){
      int A = to_string(i).size(), B = to_string(N/i).size();
      if(ans > max(A,B)) ans = max(A,B);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for b in B:
        sum_v = 1
        l = -1
        r = N
        while r - l > 1:
            m = (l + r) // 2
            if b > A[m]:
                l = m
            else:
                r = m
        sum_v *= l + 1

        l = -1
        r = N
        while r - l > 1:
            m = (l + r) // 2
            if b < C[m]:
                r = m
            else:
                l = m
        sum_v *= N - r
        ans += sum_v
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23328
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	
	int n,aaa;
	cin>>n;
	vector<vector<int>> v(n),c(n);
	vector<int> k(n),ans(n),d(n);
	rep(i,n){
		cin>>aaa>>k[i];
		v[i].resize(k[i]);
		c[i].resize(k[i]);
		rep(j,k[i]){
			cin>>v[i][j]>>c[i][j];
		}
		ans[i]=-1;
		d[i]=INF;
	}
	d[0]=0;
	int m=INF,mi;
	rep(aaaa,n){
		m=INF;
		rep(i,n){
			if(ans[i]==-1 && d[i]<m){
				m=d[i];
				mi=i;
			}
		}
		ans[mi]=m;
		rep(j,k[mi]){
			d[v[mi][j]]=min(ans[mi]+c[mi][j],d[v[mi][j]]);
		}
	}



	rep(i,n){
		cout<<i<<" "<<ans[i]<<endl;
	}
	
}

Measured memory_bytes: 6712
n = int(input())
a = list(map(int, input().split()))
fac = [1 for _ in range(n+1)]
mod = 10 ** 9 + 7

ans = 1

cnt = [0, 0, 0]
for i in range(n):
    ans = ans * cnt.count(a[i]) % mod
    for j in range(3):
        if a[i] == cnt[j]:
            cnt[j] += 1
            break

print(ans)

Measured memory_bytes: 14056
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,a;
    cin>>n>>a;
    n%=500;
    if(n<=a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;
#define ll long long
#define pb push_back

// 前に&をつけるとvectorの参照渡しになる
int solve(int x, int y, vector<vector<char> > tile, int H, int W, int count, vector<vector<bool> >& flag) {
    // cout << count << ":" << y << ","<< x << endl;
    count++;
    if (!flag[y][x]) {
        return count;
    } else {
        flag[y][x] = false;
    }
    if (y + 1 < H) {
        if (tile[y + 1][x] == '.' && flag[y + 1][x]) {
            count = solve(x, y + 1, tile, H, W, count, flag);
        }
    }
    if (y - 1 >= 0) {
        if (tile[y - 1][x] == '.' && flag[y - 1][x]) {
            count = solve(x, y - 1, tile, H, W, count, flag);
        }
    }
    if (x + 1 < W) {
        if (tile[y][x + 1] == '.' && flag[y][x + 1]) {
            count = solve(x + 1, y, tile, H, W, count, flag);
        }
    }
    if (x - 1 >= 0) {
        if (tile[y][x - 1] == '.' && flag[y][x - 1]) {
            count = solve(x - 1, y, tile, H, W, count, flag);
        }
    }
    return count;
}

int main() {

    int H, W;
    while(true) {
        cin  >> W >> H;
        if (W==0 && H == 0) break;
        vector<vector<char> > tile(H, vector<char>(W));
        vector<vector<bool> > flag(H, vector<bool>(W, true));
        int x, y, count = 0;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> tile[i][j];
                if (tile[i][j] == '@') {
                    x = j;
                    y = i;
                }
            }
        }

        count = solve(x, y, tile, H, W, count, flag);
        cout << count << endl;
    }

}



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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

template <class T>
class BIT {
    public:
        int n;
        std::vector<T> x;
        T sum(int r) const {
            T S = 0;
            for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1)
                S += x[r];
            return S;
        }
        BIT(int n_ = 0) : n(n_), x(n + 1, 0) {}
        int size() const { return n; }
        void add(int k, const T &a) {
            for (; k < n; k |= k + 1) x[k] += a;
        }
        void set(int k, const T &a) { add(k, a - sum(k, k + 1)); }
        // [l r) の総和
        T sum(int l, int r) const { return sum(r) - sum(l); }
};

template <class T>
class BITRange {
    private:
        BIT<T> a, b;
        T sum(int r) const { return a.sum(r) + b.sum(r) * r; }
        void add(int r, const T &x) {
            a.add(r, x * r);
            b.add(r, -x);
        }
    public:
        BITRange(int n = 0) : a(n), b(n) {}
        int size() const { return a.size(); }
        T sum(int l, int r) const { return sum(r) - sum(l); }
        void add(int l, int r, const T &x) {
            add(l, -x);
            add(r, x);
        }
};


signed main() {
    ll N,M;
    cin>>N>>M;
    vector<vector<PLL>> u(M+1); // u[s]: 頂点数sの名産物のリスト
    rep(i,0,N){
        PLL p;
        cin>>p.first>>p.second;
        u[p.second-p.first+1].push_back(p);
    }
    auto bit = BITRange<ll>(M+10);
    ll confi = N; // 必ず1回以上取得できる名産物の種類数
    cout<<confi<<endl; // d=1のとき
    rep(d, 2, M+1){
        confi -= u[d-1].size();
        for (auto p : u[d-1]){
            bit.add(p.first, p.second+1, 1);
        }
        ll opt = 0;
        for (ll j=0; j<=M; j+=d){
            opt += bit.sum(j, j+1);
        }
        cout<<confi+opt<<endl;
    }
    return 0;
}


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

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

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

  int n, m, k;
  cin >> n >> m >> k;
  vector<int> x(n + 1), y(m + 1), a(m + 1);
  rep(i, 1, n + 1) cin >> x[i];
  rep(i, 1, m + 1) {
    cin >> y[i];
    a[i] += a[i - 1] + y[i];
  }

  int ans = 0, cnt = 0;
  int wa = 0;

  rep(i, 0, n + 1) {
    cnt += x[i];

    int left = -1, right = m + 1;
    while (right - left > 1) {
      int mid = (left + right) / 2;

      if (cnt + a[mid] <= k)
        left = mid;
      else
        right = mid;
    }
    auto itr = upper_bound(a.begin(), a.end(), k - cnt) - a.begin();
    // cout << itr << ' ';
    // cout << k - cnt << '\n';
    // cout << i + left << '\n';
    if (k - cnt >= 0) chmax(wa, i + itr - 1);
    if (left != -1) chmax(ans, i + left);
  }

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

Measured memory_bytes: 7956
#include<stdio.h>

long long gcd(long long a,long long b)
{
	if(b==0)return a;
	else gcd(b,a%b);
}

int main()
{
	long long a,b;
	while(scanf("%lld %lld",&a,&b)!=EOF)printf("%lld %lld\n",gcd(a,b),a/gcd(a,b)*b);
	return 0;
}

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

int comp(const void* a, const void* b);

int main() {
	int t;
	int* x;
	int n, k;
	int i, j;
	int* ans;
	int* bou;
	scanf("%d", &t);
	ans = (int*)malloc(t * sizeof(int));
	for (i = 0; i < t; i++) {
		ans[i] = 0;
		scanf("%d%d", &n, &k);
		x = (int*)malloc(n * sizeof(int));
		bou = (int*)malloc((n - 1) * sizeof(int));
		for(j=0;j<n;j++)scanf("%d", &x[j]);
		if (k >= n)ans[i] = 0;
		else {
			for (j = 0; j < n - 1; j++) {
				bou[j] = x[j + 1] - x[j];
			}
			qsort(bou, n - 1, sizeof(int), comp);
			for (j = k-1 ; j < n - 1; j++)ans[i] += bou[j];
		}
	}
	for (i = 0; i < t; i++) {
		printf("%d\n", ans[i]);

	}

	return 0;
}

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

Measured memory_bytes: 5904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==s)
    {
        a=a-1;
        cout<<a<<" "<<b<<endl;
    }
    else if(u==t)
    {
        b=b-1;
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#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 CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n,m;
    while(cin>>n>>m,n+m){
        vvi v(n+1,vi(m+1,0));
        rep(i,n)rep(j,m)cin>>v[i][j];
        vector<pii>ans(m,pii(0,0));
        rep(i,n)rep(j,m)if(v[i][j]){ans[j].first++;ans[j].second= -1*(j+1);}
        sort(all(ans),greater<pii>());
        rep(i,m){if(i)cout<<" ";cout<<-1*ans[i].second;}
        cout<<endl;
    }
}

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

int main() {
    string s;
    string s1 = "";
    cin >> s;
    int n; cin >> n;
    int track = 0;

    for(int i = 0; i < n; i++) {
        int oper1; cin >> oper1;
        if(oper1 == 1) {
            track++;
        }else{
            int oper2; cin >> oper2; char x; cin >> x;
            if(oper2 == 1 && track % 2 == 0) s1 += x;
            else if(oper2 == 1) s += x;
            else if(track % 2 == 0) s += x;
            else s1 += x;
        }
    }

    if(track % 2 == 0) {
        reverse(s1.begin(), s1.end());
        cout << s1 << s;
    }else{
        reverse(s.begin(), s.end());
        cout << s << s1;
    } 
}

Measured memory_bytes: 960
"use strict";

function Main(input) {
	let flips = 0, finishes = 0;
	for (let i = 0; i < input.length; i++) {
		if (input[i] !== 'W') continue;

		flips += i - finishes;
		finishes += 1;
	}

	console.log(flips);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
ll ans = 0, n, a[100001] = {}, n_minus = 0;

int main(void)
{
	cin >> n;
	rep(i, n){
		cin >> a[i];
		if(a[i] < 0) n_minus++;
	}
	sort(a, a + n);
	if(a[0] >= 0){
		rep(i, n - 1){
			ans += a[i + 1];
		}
		ans -= a[0];
		cout << ans << endl;
		if(n > 2){
			ll t = a[0] - a[1];
			cout << a[0] << " " << a[1] << endl; 
			rep(i, n - 3){
				cout << t << " " << a[i + 2] << endl;
				t -= a[i + 2];
			}
			cout << a[n - 1] << " " << t << endl;
		}else{
			cout << a[1] << " " << a[0] << endl;
		}
	}else if(a[n - 1] < 0){
		ans += a[n - 1];
		rep(i, n - 1){
			ans -= a[i];
		}
		cout << ans << endl;
		ll t = a[n - 1] - a[n - 2];
		cout << a[n - 1] << " " << a[n - 2] << endl;
		rep(i, n - 2){
			cout << t << " " << a[n - i - 3] << endl;
			t -= a[n - i - 3];
		}
	}else{
		rep(i, n){
			if(i < n_minus)	ans -= a[i];
			else ans += a[i]; 
		}
		cout << ans << endl;
		ll t = a[n_minus - 1];
		rep(i, n - n_minus - 1){
			cout << t << " " << a[n_minus + i] << endl;
			t -= a[n_minus + i];
		}
		cout << a[n - 1] << " " << t << endl;
		t = a[n - 1] - t;
		rep(i, n_minus - 1){
			cout << t << " " << a[i] << endl;
			t -= a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 2688
package main

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

func main() {
	fsc := NewFastScanner()
	A, B := fsc.Next(), fsc.Next()
	C := A + B
	val, _ := strconv.Atoi(C)
	for i := 1; i < val; i++ {
		if i*i == val {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int N;
int s[25][25];
int t[60000];
int u[25];
int lc;
bool flg[100];

int main(){
  flg[1]=flg[13]=flg[17]=flg[19]=flg[23]=true;
  
  while(1){
    cin>>N;
    if(N==0)break;
    memset(s,0,sizeof(s));
    memset(t,0,sizeof(t));
    memset(u,0,sizeof(u));
    lc=1;
    for(int i=0;i<N;i++){
      int a,b,c;
      cin>>a>>b;
      if(!flg[a])lc = lc/__gcd(lc,a)*a;
      for(int j=0;j<a;j++){
        cin>>c;
        s[a][(j-b%a+a)%a]+=c;
        if(flg[a])u[a]=max(u[a],s[a][(j-b%a+a)%a]);
      }
    }
    int ans=0,ans2=0;
    for(int i=1;i<=24;i++){
      if(flg[i])ans+=u[i];
      else for(int j=0;j<lc;j++)t[j]+=s[i][j%i];
    }
    for(int i=0;i<lc;i++)ans2=max(ans2,t[i]);
    cout<<ans+ans2<<endl;
  }
  return 0;
}

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

int main() {
    int N;
    scanf("%d", &N);
    char *S = (char*)malloc((N+1) * sizeof(char));
    scanf("%s", S);
    int i;
    int count = 0;
    for(i=0; i<=N-2; i++) {
        if((S[i] == 'A') && (S[i+1] == 'B') && (S[i+2] == 'C')) {
            count++;
        }
    }
    printf("%d\n", count);
    free(S);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
#include <iomanip>

using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	double x;
	cin >> x;
	cout << setprecision(10);
	cout << pow(x/3, 3) << endl;
	
}

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

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

    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, n){
        ll mid = b[i];

        ll upper = lower_bound(a.begin(), a.end(), mid) - a.begin();
        ll lower = c.end() - upper_bound(c.begin(), c.end(), mid);

        ans += upper * lower;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if (A%3 == 0) {
    cout << "Possible" << endl;
  } else if (B%3 == 0) {
    cout << "Possible" << endl;
  } else if ((A + B)%3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  
  
  return 0;  
}

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

class Main {
    public static void main(String[] args) throws IOException {
        Scan sc = new Scan();
        long n = sc.scanLong();
        long tmp = n*(n-1);
        System.out.println(tmp/2);
        
    }
}

class Scan {
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public long scanLong()throws IOException
    {
        long integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}

Measured memory_bytes: 21204
package main
import "fmt"
func main() {
  var n,m int
  fmt.Scan(&n)
  m = 2*(n/2)
  if m == n {
    fmt.Println(m*(m-2)/2)
  } else {
    fmt.Println(m*m/2)
  }
  for i:=1;i<=m;i++ {
    for j:=i+1;j<=m;j++ {
      if i+j == m+1 { continue }
      fmt.Println(i,j)
    }
  }
  if m == n-1 {
    for i:=1;i<=m;i++ {
      fmt.Println(i,n)
    }
  }
}

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

const int64_t MAX = 2e+6+10;
const int64_t MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int64_t i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int64_t K;
    string S;
    cin >> K;
    cin >> S;
    int64_t N = S.size();
    
    // 前処理
    COMinit();
    
    vector<int64_t> POW26(K+10),POW25(K+10);
    POW26[0] = 1;
    POW25[0] = 1;
    for ( int64_t i = 1; i < K+10; ++i){
        POW25[i] = POW25[i-1] * 25 % MOD;
        POW26[i] = POW26[i-1] * 26 % MOD;
    }
    
    int64_t sum = 0;
    for ( int64_t k = 0; k <= K; ++k){
        sum = ( sum + ( COM(N+K-k-1,N-1) * POW26[k] ) % MOD * POW25[K-k] % MOD ) % MOD;
    }
    
    if ( sum < 0 ) sum += MOD;
    
    cout << sum << endl;
    
    
    return 0;
}


Measured memory_bytes: 66684