akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vli vector<li>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pi pair<int,int>
#define FOR(i,s,n) for(auto i=s;i<n;++i)
#define FORN(i,s,n) for(auto i=s;i<=n;++i)
#define FORR(i,s,n) for(auto i=s;i>=n;--i)
#define FORE(i,a) for(auto i : a)
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    int n;
    cin >> n;
    vll f(n+1,0);
    FOR(i,1,101) {
        FOR(j,1,101) {
            FOR(k,1,101) {
                ll val = i*i+j*j+k*k+i*j+j*k+i*k;
                if(val<=n)
                    f[val]++;
            }
        }
    }
    FOR(i,1,n+1) {
        cout << f[i] << "\n";
    }
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout<<"pon";
	else if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) cout<<"hon";
	else cout<<"bon";
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n; cin >> n;
    int a[n];
    bool error=false;
    rep(i, n){
        cin >> a[i];
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 and a[i] % 5 != 0){
                error = true;
            }
        }
    }
    
    if(error){cout << "DENIED" << endl;}
    else {cout << "APPROVED" << endl;}
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


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

  ll num = 7;
 
  vector<int> p(K);
  num = num % K;

  for(int i = 0; i < K; i++) {
    if(num == 0) { cout << i + 1; return 0; }
    if(p[num] == 0) { p[num % K] = 1; num = (num * 10 + 7) % K; }
    else break;
  }

  
  if(p[0] == 0) cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 7112
#include <iostream>
#include <vector>

#define rep(i, n) for (size_t i = 0; i < (size_t)n; ++i)

using namespace std;

void printn_chars(const vector<char> &chars) {
  for (auto c : chars) {
    cout << c;
  }

  cout << endl;
}

void succ_chars(vector<char> &chars) {
  auto n = chars.size();

  rep(i, n) {
    auto x = n - 1 - i;  // (n-1)..0
    chars[x]++;

    auto max = 'a';
    rep(j, x) {
      auto c = chars[j];
      if (max < c) {
        max = c;
      }
    }

    if (max + 1 < chars[x]) {
      chars[x] = 'a';
    } else {
      return;
    }
  }
}

int main() {
  int n;
  cin >> n;
  auto chars = vector<char>(n, 'a');

  while (chars[0] == 'a') {
    printn_chars(chars);
    succ_chars(chars);
  }
}


Measured memory_bytes: 1536
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int h = sc.nextInt();
		
		int[] b = new int[n];
		int max = 0;
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			b[i] = sc.nextInt();
			if(a>max)
				max = a;
		}
		
		Arrays.sort(b);
		
		System.out.println(solve(n, h, max, b));
	}
	static int solve(int n, int h, int max, int[] b){
		int sum = 0, c = 0;
		for(int i=n-1;i>=0;i--){
			if(b[i]>=max){
				sum+=b[i];
				c++;
			}
			if(sum>=h)
				return c;
		}
		return c+(int)Math.ceil((double)(h-sum)/max);
	}
}

Measured memory_bytes: 65464
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,p=0,w=0,g=0,y=0;
  cin>>n;
  char c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]=='P'){
      ++p;
    }else if(c[i]=='W'){
      ++w;
    }else if(c[i]=='G'){
      ++g;
    }else if(c[i]=='Y'){
      ++y;
    }
  }
  int ans=0;
  if(p>=1){
    ++ans;
  }
  if(w>=1){
    ++ans;
  }
  if(g>=1){
    ++ans;
  }
  if(y>=1){
    ++ans;
  }
  if(ans==3){
    cout<<"Three"<<endl;
  }else if(ans==4){
    cout<<"Four"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3620
using System.Collections.Generic;
using System;

public class Check
{
    public bool chk { get; set; }
    public int a { get; set; }
    public int b { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var alp = "abcdefghijklmnopqrstuvwxyz";
        var d = new Dictionary<char, int>();
        var d2 = new Dictionary<int, char>();
        for (int i = 0; i < 26; i++) { d[alp[i]] = i; d2[i] = alp[i]; }
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string ss = Console.ReadLine().Trim();
            string[] s = ss.Split(' ');
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j].Length == 4 && s[j][0] == s[j][3])
                {
                    var that = checkThat(s[j], d);
                    if (that.chk) { changeAll(ss, d, d2, that.a, that.b); goto end; }
                }
                if (s[j].Length == 4 && s[j][0] != s[j][3])
                {
                    var This = checkThis(s[j], d);
                    if (This.chk) { changeAll(ss, d, d2, This.a, This.b); goto end; }
                }
            }
            end:;
        }
    }
    public static void changeAll(string s, Dictionary<char, int> d, Dictionary<int, char> d2, int a, int b)
    {
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i].ToString() == " ") Console.Write(" ");
            else Console.Write(changeChr(s[i].ToString(), d, d2, a, b));
        }
        Console.WriteLine();
    }
    public static string changeChr(string s, Dictionary<char, int> d, Dictionary<int, char> d2, int a, int b)
    {
        for (int i = 0; i < 26; i++)
            if ((a * i + b) % 26 == d[s[0]]) return d2[i].ToString();
        return "";
    }
    public static Check checkThis(string s, Dictionary<char, int> d)
    {
        var ret = new Check();
        var tchange = d[s[0]]; var hchange = d[s[1]]; var ichange = d[s[2]]; var schange = d[s[3]];
        for (int i = 0; i < 26; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                if (((d['t'] * i + j) % 26 == tchange) &&
                        ((d['h'] * i + j) % 26 == hchange) &&
                     ((d['i'] * i + j) % 26 == ichange) &&
                     ((d['s'] * i + j) % 26 == schange)) { ret.a = i; ret.b = j; ret.chk = true; return ret; }
            }
        }
        ret.chk = false; return ret;
    }
    public static Check checkThat(string s, Dictionary<char, int> d)
    {
        var ret = new Check();
        var b = d[s[2]];
        var tchange = d[s[0]];
        var hchange = d[s[1]];
        for (int i = 0; i < 26; i++)
        {
            if (((d['t'] * i + b) % 26 == tchange) &&
                    ((d['h'] * i + b) % 26 == hchange)) { ret.chk = true; ret.a = i; ret.b = b; return ret; }
        }
        ret.chk = false; return ret;
    }
}

Measured memory_bytes: 9368
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
for i in range(N):
    c[i], t[i] = map(int, input().split())
cost = 1001

for i in range(N):
    if t[i] <= T and c[i] < cost:
        cost = c[i]

if cost <= 1000:
    print(cost)
else:
    print('TLE')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, x; cin>>n>>x;
    int arr[n];
    int ans = 0;
    For(i, 0, n){
        cin>>arr[i];
        if(arr[i]>x){
            ans += (arr[i]-x);
            arr[i]=x;
        }
    }
    For(i, 1, n){
        int v = arr[i]+arr[i-1]-x;
        if(v <= 0)
            continue;
        ans += v;
        arr[i] -= v;
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 1024
#include <iostream>

using namespace std;


int main() {
    string p[3];
    cin >> p[0] >> p[1] >> p[2];

    int current = 0;
    for(; !p[current].empty(); ) {
        int nxt = p[current][0] - 'a';
        p[current].erase(p[current].begin());
        current = nxt;
    }

    cout << char(current + 'A') << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//---------------------------------------
//---------------------------------------

int main(void)
{
	double x1, y1, x2, y2;
	cout << fixed <<setprecision(4);
	
	cin >> x1;
	cin >> y1;
	cin >> x2;
	cin >> y2;
	
	cout << sqrt(pow((x1 - x2), 2) + pow((y1- y2), 2)) << endl;
	
	return 0;
	
	
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
const int fish=998244353;
int fac[10000007],N,inv[10000007];
int Pow(int x,int y){int ans=1;for (;y;y>>=1,x=1ll*x*x%fish) if (y&1) ans=1ll*ans*x%fish;return ans;}
void Pre(int ned){
	fac[0]=1;
	for (int i=1;i<=ned;i++)
		fac[i]=1ll*fac[i-1]*i%fish;
	inv[ned]=Pow(fac[ned],fish-2);
	for (int i=ned-1;i>=0;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%fish;
}
int C(int n,int r){if (n<r) return 0;return 1ll*fac[n]*inv[r]%fish*inv[n-r]%fish;}
void work(){
	scanf("%d",&N);
	long long ans=Pow(3,N);
	for (int i=N/2+1;i<=N;i++)
		((ans-=1ll*C(N,i)*Pow(2,N-i+1))+=fish)%=fish;
	cout<<ans;
	return;
}
int main(){
	Pre(10000000);
	work();
	return 0;
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[101];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int s=0;
  int t=0;
  int i=n-1;
  while(i>=0){
    s +=a[i];
    if(i-1>=0){
    t +=a[i-1];
  }
    i=i-2;
  }
  cout<<s-t;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n),x(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  for(int i=1; i<n-1; i+=2){
    sum-=2*a[i];
  }
  x[0]=sum;
  for(int i=0; i<n-1; i++){
    x[i+1]=2*a[i]-x[i];
  }
  rep(i,n) cout << x[i] << " ";


  return 0;
}


Measured memory_bytes: 2816
<?php

while (TRUE) {
    fscanf(STDIN, "%d %d", $a, $b);
    if (feof(STDIN)) {
        break;
    }
    $gcd = gcd($a, $b);
    $lcm = $a * $b / $gcd;
    echo sprintf('%d %d', $gcd, $lcm);
    echo PHP_EOL;
}

function gcd($a, $b) {
    while ($a !== $b) {
        if ($a > $b) {
            $a -= $b;
        } else {
            $b -= $a;
        }
    }
    return $a;
}

Measured memory_bytes: 6624
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



int main() {
  ll a,b,c; cin >> a >> b >> c;

  if (c-a-b < 0) {
    cout << "No" << endl;
    return 0;
  }
   
  if (4*a*b < (c-a-b)*(c-a-b)) {
      cout << "Yes" << endl;
    }
  else {
      cout << "No" << endl;
    }
    
	return 0;
  }

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        long n = sc.nextLong();
        long x = sc.nextLong();
        
        long ans = 0;
        
        ans+=n;
        
        ans += solveE(n-x,x);
        
        System.out.println(ans);
    }
    
    long solveE(long big, long small){
    	long sho = big/small;
    	long amari = big%small;
    	
    	long ans = 2*sho*small;
    	
    	if(amari>0){
    		ans += solveE(small,amari);
    	}
    	else{
    		ans -= small;
    	}
    	
    	return ans;
    }
 
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22612
N = gets.chomp.to_i
P = gets.chomp.split(" ").map(&:to_i)
Q = gets.chomp.split(" ").map(&:to_i)

pi = -1
qi = -1

(1..N).to_a.permutation(N).sort.each_with_index do |x, i|
  pi = i if x == P
  qi = i if x == Q
  break if pi >= 0 && qi >= 0
end

puts (pi - qi).abs


Measured memory_bytes: 7384
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
using lint = long long int;

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

	int* a = new int[N];
	bool* ball = new bool[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ball[i] = false;
	}

	int ballNum = 0;
	for (int i = N; i >= 1; i--) {
		int sum = 0;
		for (int j = 2; ; j++) {
			int n = i * j;
			if (n > N)
				break;
			if (ball[n - 1])
				sum++;
		}

		if (a[i - 1] != sum % 2) {
			ball[i-1] = true;
			ballNum++;
			sum++;
		}
	}

	cout << ballNum << endl;
	for (int i = 0; i < N; i++) {
		if (ball[i]) {
			cout << i + 1;
			if (i < N - 1)
				cout << " ";
		}
	}
	cout << endl;

	delete[] a;
	delete[] ball;

	return 0;
}

Measured memory_bytes: 1920
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

constexpr ll MAX = 30000;


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

    if (N == 3) {
        printf("2 5 63\n");
        return 0;
    } else if (N == 4) {
        printf("2 5 20 63\n");
        return 0;
    } else if (N == 5) {
        printf("2 5 20 30 63\n");
        return 0;
    }

    vector<ll> ans;
    for (ll i = 2; i <= MAX; i++) {
        if (i % 2 == 0 || i % 3 == 0) {
            ans.push_back(i);
            if (ans.size() == N) {
                break;
            }
        }
    }

    auto print = [&]() {
        for (ll i = 0; i < N; i++) {
            printf("%lld%c", ans[i], " \n"[i == N - 1]);
        }
    };

    ll sum = accumulate(ans.begin(), ans.end(), (ll)0);

    if (sum % 6 == 0) {
        print();
    } else if (sum % 6 == 2) {
        ans.erase(find(ans.begin(), ans.end(), 8));
        for (ll i = ans.back() + 1; ; i++) {
            if (i % 6 == 0) {
                ans.push_back(i);
                break;
            }
        }
        print();
    } else if (sum % 6 == 3) {
        ans.erase(find(ans.begin(), ans.end(), 9));
        for (ll i = ans.back() + 1; ; i++) {
            if (i % 6 == 0) {
                ans.push_back(i);
                break;
            }
        }
        print();
    } else if (sum % 6 == 5) {
        ans.erase(find(ans.begin(), ans.end(), 9));
        for (ll i = ans.back() + 1; ; i++) {
            if (i % 6 == 4) {
                ans.push_back(i);
                break;
            }
        }
        print();
    } else {
        assert(false);
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = n;
	while (n--)
	{
		int num;
		cin >> num;
		if (num >= a && num < b)
		{
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

long num(char c) {
    return c - '0';
}

int main() {
    string S;
    cin >> S;
    int n = S.size();
    long sum = 0;
    for (int bit = 0; bit < (1 << (n - 1)); ++bit) {
        long cur = 0;
        for (int i = 0; i < n - 1; ++i) {
            cur += num(S[i]);
            if (bit & (1 << i)) {
                sum += cur;
                cur = 0;
            }
            else {
                cur *= 10;
            }
        }
        sum += cur + num(S[n-1]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

}

Measured memory_bytes: 26068
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		if ((i & 1) && (a & 1))ans++;

	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3596
N = int(input())
list = list(int(i) for i in input().split())
list.insert(0, 0)
list.insert(N+1, 0)
total = 0


for i in range(N+1):
    total += abs(list[i]-list[i+1])
for i in range(N):
    print(total - abs(list[i+1]-list[i+2]) - abs(list[i]-list[i+1]) + abs(list[i]-list[i+2]))

Measured memory_bytes: 14044
import Control.Applicative
import Control.Monad

isRight :: [Int] -> Bool
isRight [a, b, c] =
  if a > b then
    if a > c then a^2 == b^2 + c^2
      else c^2 == a^2 + b^2
  else -- b >= a
    if b > c then b^2 == a^2 + c^2
      else c^2 == a^2 + b^2

isObtuse :: [Int] -> Bool
isObtuse [a, b, c] =
  if a > b then
    if a > c then a^2 > b^2 + c^2
      else c^2 > a^2 + b^2
  else -- b >= a
    if b > c then b^2 > a^2 + c^2
      else c^2 > a^2 + b^2

isAcute :: [Int] -> Bool
isAcute [a, b, c] =
  if a > b then
    if a > c then a^2 < b^2 + c^2
      else c^2 < a^2 + b^2
  else -- b >= a
    if b > c then b^2 < a^2 + c^2
      else c^2 < a^2 + b^2

isTriangle :: [Int] -> Bool
isTriangle [a, b, c] =
  if (a + b > c) && (b + c > a) && (a + c > b) then True
    else False

solver' :: [Int] -> [Int] -> [Int]
solver' xs [a, b, c, d] =
  if isRight xs then [a+1, b+1, c, d]
  else if isAcute xs then [a+1, b, c+1, d]
  else [a+1, b, c, d+1]

converter :: [Int] -> String
converter [a, b, c, d] = show a ++ " " ++ show b ++ " " ++ show c ++ " " ++ show d

solver :: [Int] -> IO()
solver counter = do
  input <- (map (read :: String -> Int)) . words <$> getLine
  if isTriangle input then do
    let counter' = solver' input counter
    solver counter'
  else putStrLn $ converter counter

main :: IO()
main = solver [0, 0, 0, 0]
--  let counter = [0, 0, 0, 0]
--  [a, b, c] <- (map (read :: String -> Int)) . words <$> getLine
--  print $ solver' [a, b, c] [0, 0, 0, 0]



Measured memory_bytes: 4184
#include<iostream>
using namespace std ;
int main()
{
    string s,t;
    cin >>  s >> t ;
    int temp=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i]){temp++;}
    }
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, x;
	cin >> N >> x;
	int a[N];
	rep(i, 0, N) cin >> a[i];

	ll rsl = 0;
	
	if(a[0] > x) {
		rsl += (a[0] - x);
		a[0] = x;
	}

	rep(i, 0, N - 1) {
		if(a[i + 1] + a[i] > x) {
			rsl += (a[i + 1] - x + a[i]);
			a[i + 1] = x - a[i];
		}
	}

	cout << rsl << endl;
}


Measured memory_bytes: 640
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

int main(void) {
    int N;
    cin>>N;
    string S;
    int A=0;
    int W=0;
    int T=0;
    int R=0;

    for(int i=0;i<N;i++){
        cin>>S;

        if(S=="AC"){
            A++;
        }else if(S=="WA"){
            W++;
        }else if(S=="TLE"){
            T++;
        }else  if(S=="RE"){
            R++;
        }

    }

    cout<<"AC x "<<A<<endl;
    cout<<"WA x "<<W<<endl;
    cout<<"TLE x "<<T<<endl;
    cout<<"RE x "<<R<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    cout << a[n / 2] - a[(n - 1) / 2] << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '#' else 0 for c in list(input())]
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    rows = []
    for re in row_pro:
        rows.append([i for i, b in enumerate(re) if b])
    cols = []
    for ce in col_pro:
        cols.append([i for i, b in enumerate(ce) if b])
    pat = tuple(product(rows, cols))
    r = 0
    for pate in pat:
        t0 = 0
        for p0 in pate[0]:
            for p1 in pate[1]:
                t0 += gg[p0*w + p1]
        if t0 == k:
            r += 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
n, q = map(int, input().split())
s = input()
countS = [0]*n
for i in range(n-1):
    countS[i+1] = countS[i]
    if s[i]=='A' and s[i+1]=='C':
        countS[i+1] += 1

for i in range(q):
    l, r = map(int, input().split())
    print(countS[r-1]-countS[l-1])

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

int S[1000];
int top;
void initialize() {
	top = 0;
}

bool isEmpty() {
	return top == 0;
}

bool isFull() {
	return top >= 999;
}
void push(int x) {

	++top;
	S[top] = x;
}
int pop() {

	top--;
	return S[top + 1];

}
int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push((int)a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 3216
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    r = int(sys.stdin.readline())
    print(3 * (r ** 2))


Measured memory_bytes: 5200
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//ei1333さんのGitHubから https://ei1333.github.io/luzhiled/

//グラフ用テンプレ
//edge := 重み付き辺
//Edges := 重み付き辺集合
//WeightedGraph := 重み付きグラフ
//UnWeightedGraph := 重みなしグラフ
//Matrix := 距離行列
template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int to, T cost) : src(-1), to(to), cost(cost) {}
	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
	
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
//テンプレここまで

//最大流 Ford-Fulkerson: O(FE) 容量が無理数の場合, 有限回の操作で終了しないことがある
template< typename flow_t >
struct FordFulkerson {
	struct edge {
		int to;
		flow_t cap;
		int rev;
		bool isrev;
		int idx;
	};

	vector< vector< edge > > graph;
	vector< int > used;
	const flow_t INF;
	int timestamp;

	FordFulkerson(int n) : INF(numeric_limits< flow_t >::max()), timestamp(0) {
		graph.resize(n);
		used.assign(n, -1);
	}

	void add_edge(int from, int to, flow_t cap, int idx = -1) {
		graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
		graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
	}

	flow_t dfs(int idx, const int t, flow_t flow) {
		if(idx == t) return flow;
		used[idx] = timestamp;
		for(auto &e : graph[idx]) {
			if(e.cap > 0 && used[e.to] != timestamp) {
				flow_t d = dfs(e.to, t, min(flow, e.cap));
				if(d > 0) {
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	flow_t max_flow(int s, int t) {
		flow_t flow = 0;
		for(flow_t f; (f = dfs(s, t, INF)) > 0; timestamp++) {
		flow += f;
		}
		return flow;
	}

	void output() {
		for(int i = 0; i < graph.size(); i++) {
			for(auto &e : graph[i]) {
				if(e.isrev) continue;
				auto &rev_e = graph[e.to][e.rev];
				cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
			}
		}
	}
};
//最大流 Ford-Fulkersonここまで

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<pair<int, int> > r(n), b(n);
	REP(i,n) cin >> r[i].first >> r[i].second;
	REP(i,n) cin >> b[i].first >> b[i].second;
	FordFulkerson<int> g(n*2+2);
	REP(i, n) g.add_edge(0, i+1, 1);
	REP(i, n) g.add_edge(n+i+1, n*2+1, 1);
	REP(i, n){
		REP(j, n){
			if(r[i].first < b[j].first && r[i].second < b[j].second){
				g.add_edge(i+1, n+j+1, 1);
			}
		}
	}
	cout << g.max_flow(0, n*2+1) << endl;
}

Measured memory_bytes: 384
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> //lower_bound , upper_bound
// using namespace __gnu_pbds;//kth smallest : *pd.find_by_order(k-1) , no. of elem < X : pd.order_of_key(X) , delete X : pd.erase(X).
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl '\n'
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod=(1e+9)+7;
const ll sz = 2e5+9;
ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
ll power(ll a,ll b,ll m = mod) {ll res = 1;while(b>0){if(b&1)res = (res*a)%m;b = b>>1;a = (a*a)%m;}return res;}

string backtrack(vector<vector<ll>> &dp,ll x,ll y,string &a,string &b){
    if(x==0 || y==0) return "";
    string k="";
    if(a[x-1]==b[y-1]) k+=a[x-1]+backtrack(dp,x-1,y-1,a,b);
    else if(dp[x-1][y]>dp[x][y-1]) k+=backtrack(dp,x-1,y,a,b);
    else k+=backtrack(dp,x,y-1,a,b);
    return k;
}

void solve()
{
   string a,b;
    cin>>a>>b;
    ll x=a.size(),y=b.size();
    vector<vector<ll>> dp(x+1,vector<ll>(y+1,0));
    f(i,1,x+1){
        f(j,1,y+1){
            if(a[i-1]==b[j-1]) dp[i][j]= 1LL + dp[i-1][j-1];
            else dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[x][y]<<nl;
    string ans; 
    ans=backtrack(dp,x,y,a,b);
   cout<<string(ans.rbegin(),ans.rend()) <<nl;
}
 
int main()
{
    #ifdef JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    clock_t beg = clock();
    solve();
    clock_t end = clock();
    fprintf(stderr, "%.3f sec, Copyright %c 2019 PyThor. \n", double(end - beg) / CLOCKS_PER_SEC , 184);
    return 0;
}


Measured memory_bytes: 71168
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
 
long long f(int a,int b){
	return Comb(a+b+2,a+1)-1;
}
int main(){
	double a;scanf("%lf",&a);
	printf("%.12f\n",a*a*a/27);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <inttypes.h>
#include <math.h>

#define MIN(A, B) (((A)<(B))?(A):(B))
#define MAX(A, B) (((A)<(B))?(B):(A))
int main(void)
{
    uint32_t A, B, K;
    scanf("%" PRIu32 "%" PRIu32 "%" PRIu32, &A, &B, &K);
    for (uint32_t i = A; i <= MIN(A+K-1, B); i++) {
        printf("%" PRIu32 "\n", i);
    }
    for (uint32_t i = MAX(B-K+1, MIN(A+K, B+1)); i <= B; i++) {
        printf("%" PRIu32 "\n", i);
    }
    return 0;
}



Measured memory_bytes: 128
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &A, &B, &K)

	var buffer bytes.Buffer
	for i := A; i <= B; i++ {
		if i < A+K || i > B-K {
			buffer.WriteString(strconv.Itoa(i))
			buffer.WriteString("\n")
		}
	}
	fmt.Println(buffer.String())

}


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, m, d;
	cin >> n >> m >> d;
	
	ll cnt = 0;
	FOR(i, 1, n + 1) {
		if (i + d <= n) cnt++;
		if (i - d >= 1) cnt++;
	}
	
	//cout << cnt << endl;

//	cout << (double) ((cnt) * pow(n, (m - 1))) / pow(n, m) << endl;
//	cout << (double) (cnt) / n << endl;
	if (d == 0) cnt /= 2;
	//cout << (double) (m - 1) * (double) (cnt) / (n * n) << endl;
	printf("%.9f\n", (double) (m - 1) * (double) (cnt) / (n * n));
  	
	return 0;
}


Measured memory_bytes: 256
<?php
list($n) = ints();
$a = ints();
$max = max($a);
if ($max === 1) exit('pairwise coprime');
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$a[$i]])) ++$cnt[$a[$i]];
    else $cnt[$a[$i]] = 1;
}
$p = new Prime($max);
$primes = $p->primes();
$maxc = 0;
foreach ($primes as $prime) {
    $c = 0;
    for ($j = $prime; $j <= $max; $j += $prime) {
        if (isset($cnt[$j])) $c += $cnt[$j];
    }
    $maxc = max($maxc, $c);
}
if ($maxc === $n) exit('not coprime');
if ($maxc === 1) exit('pairwise coprime');
echo 'setwise coprime';

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 素数関係
class Prime
{
    private $n;
    private $table; // 素数の添字にtrueが格納された配列

    function __construct($n)
    {
        $this->n = $n;
        $this->makeTable();
    }

    function makeTable()
    {
        $n = $this->n;
        $table = array_fill(2, $n - 1, true);
        $rn = (int) floor(sqrt($n));
        for ($i = 2; $i <= $rn; $i++) {
            if (!isset($table[$i])) continue;
            for ($j = 2 * $i; $j <= $n; $j += $i) {
                unset($table[$j]);
            }
        }
        $this->table = $table;
    }

    // 素数
    function primes()
    {
        return array_keys($this->table);
    }

    function table()
    {
        return $this->table;
    }

    // 素数判定
    function isPrime($x)
    {
        return isset($this->table[$x]);
    }

    // 素因数分解
    function factor($x)
    {
        $res = [];
        if ($x === 1) return $res;
        $primes = $this->primes();
        foreach ($primes as $prime) {
            while ($x % $prime === 0) {
                if (isset($res[$prime])) $res[$prime]++;
                else $res[$prime] = 1;
                $x /= $prime;
            }
        }
        if ($x > 1) {
            if (isset($res[$x])) $res[$x]++;
            else $res[$x] = 1;
        }
        return $res;
    }
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			String str1=in.next();
			String str2=in.next();
			out.println(solve(str1,str2));
		}
		out.flush();
	}
	
	static int solve(String str1,String str2) {
		char s1[]=str1.toCharArray(), s2[]=str2.toCharArray();
		int DP[][]=new int[str1.length()][str2.length()];
		
		for(int i=0;i<str1.length();i++) {
			for(int j=0;j<str2.length();j++) {
				if(s1[i]==s2[j]) {
					if(i>0 && j>0)DP[i][j]=DP[i-1][j-1]+1;
					else DP[i][j]=1;
				}
				else {
					if(i>0 && j>0)DP[i][j]=Math.max(DP[i][j-1], DP[i-1][j]);
					else if(j==0 && i>0)DP[i][j]=DP[i-1][j];
					else if(i==0 && j>0)DP[i][j]=DP[i][j-1];
					else DP[i][j]=0;
				}
			}
		}
		int res=0;
		for(int i=0;i<str2.length();i++)res=Math.max(DP[str1.length()-1][i], res);
		return res;
	}

}



Measured memory_bytes: 64856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N;
    cin >> N;
    vector<pii> city(N);
    vector<int> place(N);
    rep(i, N) {
        cin >> city[i].first >> city[i].second;
        city[i].first--;
        city[i].second--;
        place[city[i].first] = i;
    }
    vector<int> X(N);
    rep(i, N) { X[city[i].second] = city[i].first; }
    sort(All(city));
    UnionFind uf(N);
    set<int> se;
    for(int i = 0; i < N; i++) {
        se.insert(city[i].second);
        auto stop = se.find(city[i].second);
        int cnt = 0;
        auto it = se.begin();
        while(it != stop) {
            uf.unite(i, X[*it]);
            cnt++;
            if(it != se.begin()) {
                se.erase(it++);
            } else
                it++;
        }
        if(cnt)
            se.erase(stop);
    }
    vector<int> res(N);
    rep(i, N) { res[place[i]] = uf.size(i); }
    rep(i, N) { cout << res[i] << endl; }
}

Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 16002;

int main() {
	string str;
	int x, y;
	int FN = 0;
	int F[MAX] = { 0 };

	bool dp[4][MAX] = { { false } };
	int index[4] = { 0,1,2,3 };

	dp[0][MAX / 2] = true;
	dp[2][MAX / 2] = true;

	cin >> str >> x >> y;

	for (int i = 0; i < str.length(); i++) {
		if (str[i] == 'T')FN++;
		else F[FN]++;
	}
	FN++;

	for (int i = 0; i < FN; i++) {
		for (int j = 0; j < MAX; j++) {
			if		(j - F[i] >= 0  && dp[index[0]][j - F[i]])dp[index[1]][j] = true;
			else if (j + F[i] < MAX && dp[index[0]][j + F[i]] && i != 0)dp[index[1]][j] = true;
			else	dp[index[1]][j] = false;
		}
		swap(index[0], index[1]);
		swap(index[0], index[2]);
		swap(index[1], index[3]);
	}

	if (FN % 2) {
		swap(index[0], index[2]);
		swap(index[1], index[3]);
	}

	if (dp[index[0]][x + MAX / 2] && dp[index[2]][y + MAX / 2])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
  int A,B,C;
  cin >>A >>B >>C;
  if(A>B){
    cout <<0 <<endl;
  }
  else{
    if(C<(B/A)){
      cout <<C <<endl;
    }
    else{
      cout <<B/A <<endl;
    }
  }
  return 0;
}

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

int main()
{
    int S, hour, minute, second;
    
    cin >> S;
    
    hour = S / 3600;
    
    S -= hour * 3600;
    
    minute = S / 60;
    S -= minute * 60;
    
    second = S;
    
    cout << hour << ":" << minute << ":" << second << endl;

    
    
    return 0;
}

Measured memory_bytes: 1164
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		PrintWriter out=new PrintWriter(System.out);
		FastScanner fs=new FastScanner();
	
		int n=fs.nextInt();
		int a[]=fs.readArray(n);
	//	Arrays.sort(a);
	    
	    int count=0;
	   int max=0;
	   for(int i:a)
	   max=Math.max(i,max);
	   
	   int div[]=new int[max+1];
	   
	   for(int i:a){
	       for(int j=i;j<=max;j+=i)
	       div[j]++;
	   }
	 
	   for(int i:a){
	       if(div[i]==1)
	       count++;
	   }
	    
	    out.println(count);
		out.close();
	
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


Measured memory_bytes: 47884
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int n, d;	cin >> n >> d;	//入力
	int empty = 0;

	int siya = d * 2 + 1;
	if (n % siya != 0) { empty = 1; }	//あまりがあるかどうかで01
	int ans = (n / siya) + empty;		//計算


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

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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    vector<int> ans(n + 1);
    int res = 0;
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = 2 * i; j <= n; j += i)
            sum += ans[j];
        sum %= 2;
        ans[i] = (sum != a[i]);
        res += ans[i];
    }
    cout << res << endl;
    if (res) {
        for (int i = 1; i <= n; i++) {
            if (ans[i]) {
                cout << i << ' ';
            }
        }
    }
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
using namespace std;

string s;
int q;
string str1 = "";
string str2 = "";

void op1()
{
  string temp = str2;
  str2 = str1;
  str1 = temp;
}

void op2()
{
  int f;
  char c;
  cin >> f >> c;
  if (f == 1)
  {
    str1 += c;
  }
  else if (f == 2)
  {
    str2 += c;
  }
  else
  {
    cout << "SWW" << endl;
  }
}

int main()
{
  cin >> s >> q;

  bool rev = false;

  for (int i = 0; i < q; i++)
  {
    int t;
    cin >> t;
    if (t == 1)
    {
      op1();
      rev = !rev;
    }
    else if (t == 2)
    {
      op2();
    }
    else
    {
      cout << "SWW" << endl;
    }
  }

  if (rev)
  {
    reverse(s.begin(), s.end());
  }

  reverse(str1.begin(), str1.end());
  s = str1 + s + str2;

  cout << s << endl;
}
#include <iostream>


Measured memory_bytes: 1348
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0, now = 0;
	string s;
	cin >> s;
	REP(i, s.size()){
		if(s[i] == 'A' ||s[i] == 'T' || s[i] == 'C' ||s[i] == 'G')
		{
			ans = max(now + 1, ans);
			now ++; 
		}
		else now = 0;
	}
    cout << ans << endl;
}

Measured memory_bytes: 256