akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
bool prime[10000000+1];
void SieveOfEratosthenes() 
{
  memset(prime, true, sizeof(prime)); 
  for (ll p=2;p*p<=10000000;p++) 
  {  
    if (prime[p]==true) 
    {   
       for (ll i=p*p;i<=10000000;i+=p) 
          prime[i]=false; 
    } 
  }
}
int main()
{
  IOS
  SieveOfEratosthenes();
  ll n;
  cin>>n;
  ll c=0;
  vector <ll> v;
  for(ll i=2;i<=10000000;i++)
  {
    if(i>n)
      break;
    if(prime[i])
    {
      for(ll j=1;n>1;j++)
      {
        ll r=pow(i,j);
        if(n%r==0)
        {
          c++;
          v.pb(r);
          n=n/r;
        }
        else
          break;
      }
    }
  }
  ll s=0;
  for(ll i=1;i*i<=n;i++)
  {
    if(n%i==0)
    {
      if((n/i)==i)
        s++;
      else
        s+=2;
    }
  }
  if(s==2&&find(v.begin(),v.end(),n)==v.end())
    c++;
  cout<<c;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] ax = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] ax2 = ax.Where(w => w % 2 == 0).ToArray();
        if (ax2.Length == 0)
        {
            Console.WriteLine("APPROVED");
            return;
        }
        int[] ax3 = ax2.Where(w => w % 3 == 0 || w % 5 == 0).ToArray();
        if (ax2.Length != ax3.Length)
        {
            Console.WriteLine("DENIED");
            return;
        }
        Console.WriteLine("APPROVED");
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n;
    cin>>n;
    vector< pair<int ,int> > p(n); 
    vector< pair<int ,int> > arm(n); 
    for(int i = 0;i< n; i++){
        cin >> p.at(i).first >> p.at(i).second;
        arm[i].first=p[i].first+p[i].second;
        arm[i].second=p[i].first-p[i].second;
    }
    sort(arm.begin(),arm.end()); 
    //cout<<" ";
    /*
    rep(i,n){
        cout << arm[i].second<<" ";
        //左手  
    }
    cout<<endl;
    rep(i,n){
        cout << arm[i].first<<" ";
        //右手
    }
    */
    int ans=n;
    int i=0;
    while(i<n-1){
        int j=1;
        if(arm[i].first>arm[i+1].second){
            while(arm[i].first>arm[i+j].second){
                if(i+j>=n){
                break;
             }
                ans--;
                j++;
            }
        }
        i += j;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn main() {
    let r: f64 = read();

    let l = r * 2f64 * std::f64::consts::PI;
    println!("{}", l);
}


Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	double[] GR => Strs.Select(double.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public const long INFL = 4011686018427387913L;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var h = G;
		var a = G;
		var dp = new RMQ(N);
		var rev = new int[N];
		for (var i = 0; i < N; i++) rev[h[i] - 1] = i;
		for (var i = 0; i < N; i++)
		{
			var j = rev[i];
			dp[j] = a[j] + dp.Max(0, j);
		}
		WriteLine(dp.Max(0, N));
	}
}
class RMQ
{
	int N2;
	long[] segtree;
	public RMQ(int N) : this(new long[N]) { }
	public RMQ(long[] array)
	{
		N2 = 1;
		while (N2 < array.Length) N2 <<= 1;
		segtree = new long[2 * N2 - 1];
		for (var i = 0; i < 2 * N2 - 1; i++) segtree[i] = 0;
		for (var i = 0; i < array.Length; i++) segtree[i + N2 - 1] = array[i];
		for (var i = N2 - 2; i >= 0; i--) segtree[i] = Math.Max(segtree[2 * i + 1], segtree[2 * i + 2]);
	}
	public void Update(int index, long value)
	{
		index += N2 - 1;
		segtree[index] = value;
		while (index > 0)
		{
			index = (index - 1) / 2;
			segtree[index] = Math.Max(segtree[index * 2 + 1], segtree[index * 2 + 2]);
		}
	}
	public long this[int n] { get { return Max(n, n + 1); } set { Update(n, value); } }
	public long Max(int from, int to) => Max(from, to, 0, 0, N2);
	long Max(int from, int to, int node, int l, int r)
	{
		if (to <= l || r <= from) return 0;
		if (from <= l && r <= to) return segtree[node];
		return Math.Max(Max(from, to, 2 * node + 1, l, (l + r) >> 1), Max(from, to, 2 * node + 2, (l + r) >> 1, r));
	}
}

Measured memory_bytes: 45372
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n;
	set<char> s;
	cin>>n;
	REP(i,n){
		char a;
		cin>>a;
		s.insert(a);
	}
	cout<<((s.size()==3)?"Three":"Four")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int a,b,count=0;
    cin>>a>>b;
    for(int i=1;i<=a;i++){
        for(int j=i;j<=13;j++){
          	if(i!=a){
            	if(i==j){
                	count++;
            	}else if(i<j){
                	break;
            	}
            }else{
            	if(j<=b){
                	if(i==j){
                    	count++;
                    }
                }
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys, collections, heapq
file = sys.stdin
H,W = map(int, file.readline().split())
C = [list(map(int,i.split())) for i in file.readlines()]
prev = [0 for i in range(W)]
G = []
def height(C):
    global prev
    P = []
    for i in range(W):
        if C[-1][i] == 1:
            p = 0
        else: p = prev[i] + 1
        P.append(p)
    prev = P[:]
    return P

def square(C):
    P = height(C)
    global G
    L = collections.deque()
    for i,v in enumerate(P):
        if not L:
            L.append((i, v))
            continue
        if v > L[-1][1]:
            L.append((i, v))
        elif v < L[-1][1]:
            k = i - 1
            while L and v < L[-1][1]:
                a = L.pop()
                heapq.heappush(G,  -(k - a[0] + 1) * a[1])
            L.append((a[0], v))
    while L:
        a = L.pop()
        heapq.heappush(G, -(len(P) - a[0]) * a[1])

def ans(C):
    ans = []
    global G
    for i in range(H):
        currentC = C[:i+1]
        square(currentC)
    return str(-G[0])

print(ans(C))

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

ll part[100010];
ll tmp[100010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    vector<ll> a,b,c;
    ll x;
    cin>>n;
    f(n){
        cin>>x;
        a.pb(x);
    }
    f(n){
        cin>>x;
        b.pb(x);
    }
    f(n){
        cin>>x;
        c.pb(x);
    }
    sort(all(a));
    sort(all(b));
    int i=1;
    for(auto val:b){
        ll l=lower_bound(all(a),val)-a.begin();
        tmp[i]=l;
       ++i;
    }
    fi(i,1,n+1){
        part[i]=tmp[i]+part[i-1];
    }
    ll ans=0;
    for(auto val:c){
        int l=lower_bound(all(b),val)-b.begin();
        ans+=part[l];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4340
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

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

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int tmp, tmp2;
            cin >> tmp >> tmp2;
            honest[tmp - 1][i] = tmp2;
        }
    }

    int maxcount = 0;
    for (int num = 0; num <= n; num++) {
        vector<int> choose(n);
        for (int i = 0; i < n; i++) {
            i < num ? choose[i] = 1 : choose[i] = 0;
        }
        sort(choose.begin(), choose.end());

        do {
            // debug
            for (int i = 0; i < n; i++) {
                //cout << choose[i] << " ";
            }
            int current = 0;

            vector<vector<int>> tmp = honest;
            for (int i = 0; i < n; i++) {
                if (choose[i] == 0) {
                    for (int j = 0; j < n; j++) {
                        tmp[j][i] = -1;
                    }
                }
            }

            bool flag = true;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if(tmp[i][j] == -1) continue;
                    else if(tmp[i][j] != choose[i]){
                        flag = false;
                        break;
                    }
                }
                if(!flag) break;
            }
            if(flag){
                for(int i = 0; i < n; i++){
                    if(choose[i] == 1) current++;
                }
                maxcount = max(maxcount, current);
                //cout << "   :" << current << endl;
            } else {
                //cout << "   : xx" << endl;
            }
        } while (next_permutation(choose.begin(), choose.end()));
    }
    cout << maxcount << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,l;
    string s;
    cin>>n>>l;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    cout<<v[i];


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
//  #define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  list<int> lst;
  int N;
  cin>>N;
  for (int  i = 0; i < N; i++)
  {
    string str; int A;
    cin>>str;
    if(str == "insert")
    {
      cin>>A;
      lst.push_front(A);
    }
    else if (str == "delete")
    {
      cin >> A;
      auto itr = lst.begin();
      while(true)
      {
        if(*itr == A)
        {
          lst.erase(itr);
          break;
        }
        itr++;
        if(itr == lst.end()) break;
      }
    }
    else if(str == "deleteFirst")
    {
      lst.pop_front();
    }
    else if (str =="deleteLast")
    {
      lst.pop_back();
    }
  }
  int C = 0;

  while(!lst.empty())
  {
    if(C != 0) cout<<" ";
    cout<< *lst.begin();
    lst.pop_front();
    C++;
  }
  cout<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}


Measured memory_bytes: 34440
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f q.front()
#define SIZE (ll)(1e3)
#define mod (ll)(1e9+7)
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t1,t2,t3;
	t1=a;t2=b;t3=c;
	a=t3;b=t1;c=t2;
	cout<<a<<" "<<b<<" "<<c;
	return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 != 0) {
        print("IMPOSSIBLE");
    } else {
        print((A + B) / 2);
    }

}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
    print("A")
else:
    print("B")

Measured memory_bytes: 63980
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var townsPos = Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToList();
            int[] towns = new int[N];
            for (int i = 0; i < N; i++)
            {
                towns[i] = i;
            }
            var allPermutation = AllPermutation(towns);

            double distance = 0;

            foreach (var p in allPermutation)
            {
                for (int i = 0; i < p.Length - 1; i++)
                {
                    distance += Math.Sqrt(Math.Pow(Math.Abs(townsPos[p[i]][0] - townsPos[p[i + 1]][0]), 2) +
                                             Math.Pow(Math.Abs(townsPos[p[i]][1] - townsPos[p[i + 1]][1]), 2));
                }

            }

            Console.WriteLine(distance / allPermutation.Count());
        }
        public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable
        {
            var a = new List<T>(array).ToArray();
            var res = new List<T[]>();
            res.Add(new List<T>(a).ToArray());
            var n = a.Length;
            var next = true;
            while (next)
            {
                next = false;

                // 1
                int i;
                for (i = n - 2; i >= 0; i--)
                {
                    if (a[i].CompareTo(a[i + 1]) < 0) break;
                }
                // 2
                if (i < 0) break;

                // 3
                var j = n;
                do
                {
                    j--;
                } while (a[i].CompareTo(a[j]) > 0);

                if (a[i].CompareTo(a[j]) < 0)
                {
                    // 4
                    var tmp = a[i];
                    a[i] = a[j];
                    a[j] = tmp;
                    Array.Reverse(a, i + 1, n - i - 1);
                    res.Add(new List<T>(a).ToArray());
                    next = true;
                }
            }
            return res;
        }
    }
}

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

int main(){
    int A, B;
    
    cin >> A >> B;

    if(A > B) {
        cout << A+(A-1) <<endl;
    }
    else if (B > A){
        cout <<B+B-1<<endl;
    }
    else{
        cout << A+B << endl;
    }
        
}

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

int main() {
  int n;
  cin >> n;
  int a;
  vector<int> vec(100010);
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec.at(a+3)++;
    vec.at(a+4)++;
    vec.at(a+5)++;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec.at(0) << endl;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  long long int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  long long int m = A, M = A;
  for(int i = 1; i < (int)N; ++i){
    long long int m_1 = m + C, M_1 = M + D, m_2 = m - D, M_2 = M - C;
    if(B >= m_1){
      m = m_1;
      M = M_1;
    }else{
      m = m_2;
      M = M_2;
    }
    //cout << m << " " << M << endl;
  }
  if(m <= B && M >= B){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, p: [usize; n], q: [usize; n]);
    let permutations = make_permutation(n);

    let mut p_num: i32 = 0;
    let mut q_num: i32 = 0;

    for h in 0..permutations.len() {
        let mut is_p = true;
        for i in 0..n {
            if p[i] != permutations[h][i] + 1 {
                is_p = false;
                break;
            }
        }
        if is_p {
            p_num = h as i32;
        }
        let mut is_q = true;
        for i in 0..n {
            if q[i] != permutations[h][i] + 1 {
                is_q = false;
                break;
            }
        }
        if is_q {
            q_num = h as i32;
        }
    }

    println!("{}", num::abs(p_num - q_num));
}

fn make_permutation(n: usize) -> Vec<Vec<usize>> {
    let mut vecs: Vec<Vec<usize>> = vec![Vec::new(); factorial(n)];
    let nums: Vec<usize> = (0..n).collect();
    let indexes: Vec<usize> = (0..factorial(n)).collect();
    push_recusive(nums, indexes, &mut vecs);
    vecs
}

fn push_recusive<T: Clone>(
    nums: Vec<T>,
    indexes: Vec<usize>,
    vecs: &mut Vec<Vec<T>>,
) -> &mut Vec<Vec<T>> {
    if nums.len() == 0 {
        return vecs;
    }
    let block_size = factorial(nums.len() - 1);
    for (block_index, num) in nums.iter().enumerate() {
        for inner_index in 0..block_size {
            let index = indexes[block_size * block_index + inner_index];
            vecs[index].push(num.clone());
        }
        let new_nums = {
            let mut tmp = nums.clone();
            tmp.remove(block_index);
            tmp
        };
        let new_indexes: Vec<usize> = {
            let slice = &indexes[(block_size * block_index)..(block_size * (block_index + 1))];
            slice.to_vec()
        };
        push_recusive(new_nums, new_indexes, vecs);
    }
    vecs
}

fn factorial(i: usize) -> usize {
    if i <= 1 {
        1
    } else {
        (2..=i).fold(1, |acc, x| acc * x)
    }
}


Measured memory_bytes: 6504
#include <iostream>

using namespace std;

int main() {
    int a,b,c,i,k;
    k = 0;
    cin >> a >> b >> c;
    for(i=a;i<=b;i++){
        if(c%i==0){
            k = k+1;
        }
    }
   cout << k <<endl;
}


Measured memory_bytes: 3116
//1,000,000

#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int k, x;
	cin >> k >> x;

	int xmin, xmax;

	xmin = max(-1000000, x - k +1);
	xmax = min(1000000, x + k - 1);

	for (int i = xmin; i <= xmax; i++) {
		if (i == xmin) {
			cout << i;
		}
		else {
			cout << " " << i;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

ans = s.count('R') * s.count('G') * s.count('B')
for i in 0..n
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[i+t] && s[i+t] != s[i+2*t] && s[i] != s[i+2*t]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14384
// C - gacha
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int ans = 1;
    sort(s.begin(), s.end());
    rep(i, n-1){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

long long dp[90];
long long ryuka(long long i)
{
	if (i == 0) return 2;
	if (i == 1) return 1;
	if (dp[i] != -1) return dp[i];
	return dp[i] = ryuka(i - 1) + ryuka(i - 2);
}

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

	rep(i, 90) dp[i] = -1;
	cout << ryuka(n) << endl;
	return 0;
}


Measured memory_bytes: 256
import math

def makePrime(x):
    x = int(x)
    x += 1
    count = 0
    if x%5 != 1:
        x += 6-x%5
    for i in range(2,int(math.sqrt(x)+1)):
        if x%i == 0:
            count = 1
            break
    if count == 1:
        return str(makePrime(x+1))
    else:
        return str(x)

N = int(input())
a = []
a.append(str(11))
for i in range(N-1):
    b = a[i]
    a.append(makePrime(b))
print(' '.join(a))


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

const int nmax=100010;

vector<int> graph[nmax];
int parent[nmax][20]; // all is -1
int depth[nmax];

void dfs(int v,int p,int d){
	parent[v][0]=p;
	depth[v]=d;
	for(auto &v2:graph[v]) if(v2!=p) dfs(v2,v,d+1);
}

int lca(int u,int v){
	if(depth[u] < depth[v]) swap(u,v);
	for(int i=19;i>=0;--i) if((depth[u]-depth[v])>>i&1) u=parent[u][i];
	if(u==v) return u;
	for(int i=19;i>=0;--i){
		if(parent[u][i]!=parent[v][i]){
			u=parent[u][i];
			v=parent[v][i];
		}
	}
	return parent[u][0];
}

int main(void){
	int n; cin >> n;
	rep(i,n){
		int k; cin >> k;
		rep(j,k){
			int v; cin >> v;
			graph[i].push_back(v);
		}
	}

	// rep(i,n)rep(j,20) parent[i][j]=-1;
	dfs(0,-1,0);
	rep(j,19)rep(i,n){
		if(parent[i][j]==-1)
			parent[i][j+1]=-1;
		else
			parent[i][j+1]=parent[parent[i][j]][j];
	}

	int q; cin >> q;
	rep(i,q){
		int u,v; cin >> u >> v;
		cout << lca(u,v) << endl;
	}
	return 0;
}

Measured memory_bytes: 19544
/* Those who cannot remember the past are condemned to repeat it.*/
/* author:Ajeet */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define ll long long int
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int sz=1e7;
#define mod 1000000007
#define ull unsigned long long int
int dp[3][100005];
int main()
{
int N;
    cin>>N;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) {
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < N; i++) {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }
    cout << max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]) <<endl;

    return 0;

}


Measured memory_bytes: 2560
Tmp = []
Tmp  = input().rstrip().split(' ')

N = int(Tmp[0])
K = int(Tmp[1])

Ans = 0
nTmp = 0
nTmp2 = 0
nTmp3 = 0

if K == 0:
  Ans = N **2
else:
    for i in range(N+1):
        if i == 0:
            continue
        B = i
        nTmp = B - K
        if nTmp > 0:
            nTmp2 = N // B
            nTmp3 = (B - K) * nTmp2
            Ans += nTmp3
            nTmp2 = N % B
            if nTmp2 != 0:
                nTmp2 = nTmp2 - K + 1
                if nTmp2 > 0:
                    Ans += nTmp2
    
print(Ans)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;


int main(){
	ll r; cin >> r;
	if (r < 1200) cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    a, b, c, d = map(int, input().split())

    ab = abs(a - b) <= d
    bc = abs(b - c) <= d
    ca = abs(c - a) <= d
    if ca or (ab and bc):
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		cout << a * b << endl;
	}
	else {
		cout << "-1" << endl;
	}
}

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

int gcd(int a, int b) {
  if(a < b) {
    return gcd(b, a);
  }
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int gcd3(int a, int b, int c) {
    return gcd(a, gcd(b, c));
}


int main() {
    int K;
    long count = 0;
    cin >> K;
    for (int i=1; i<=K; i++) {
        for (int j=1; j<=K; j++) {
            for (int k=1; k<=K; k++) {
                count += gcd3(i, j, k);
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>
#include <cstring>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

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



int main(void) {
	string S;cin>>S;
	string T;cin>>T;

	S += S;

	bool flag = false;
	REP(i,T.size()){
		int j=0;
		while(T[j]==S[i+j])j++;
		if(j==T.size()){
			flag = true;
			break;
		}
	}

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

    return 0;
}

Measured memory_bytes: 256
S = [int(i) for i in input()]
p = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 0:
        p[i] = 1
q = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 1:
        q[i] = 1

pans = 0
for i in range(len(S)):
    if S[i] != p[i]:
        pans += 1

qans = 0
for i in range(len(S)):
    if S[i] != q[i]:
        qans += 1

print(min(pans, qans))


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int f(int n){
    return n*(n-1)/2;
}


int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    srepn(i,1,n){
        int ni = i;
        for(int j = 2;; j++){
            if(ni==1) break;
            while(ni%j==0){
                ni/=j;
                mp[j]++;
            }
        }
    }
    ll ans = 0;
    int a2=0, a4=0, a14=0, a24=0, a74=0;
    for(auto e : mp){
        if(e.second >= 2) a2++;
        if(e.second >= 4) a4++;
        if(e.second >= 14) a14++;
        if(e.second >= 24) a24++;
        if(e.second >= 74) a74++;
    }
    ans += f(a4)*(a2-2);
    ans += a14*(a4-1);
    ans += a24*(a2-1);
    ans += a74;
    cout << ans << endl;

}

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

int main(){

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

    sort(d.begin(), d.end());

    cout << d[N/2]-d[N/2-1] << endl;

    return 0;
}

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

const long long MOD = 1000000007;

long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

long long comb(long long a, long long b) {
    long long x = 1, y = 1;
    for (long long i = 0; i < b; i++) {
        x *= a - i;
        y *= i + 1;
        x %= MOD;
        y %= MOD;
    }
    return (x * pow(y, MOD-2)) % MOD;
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    rep(i, n) {
        ans += (ll)i * (n-i) % MOD * pow(m, 2);
        ans %= MOD;
    }
    rep(i, m) {
        ans += (ll)i * (m-i) % MOD * pow(n, 2);
        ans %= MOD;
    }
    ll s = n * m;
    ans *= comb(s-2, k-2);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      
      
using namespace std;      
      
int main() {      
    std::ios::sync_with_stdio(false);  
    std::cin.tie(nullptr);  
    int a;  
    int prev;  
    cin >> prev;  
    while (cin>>a){  
        if (prev != a) {  
            cout << "No" << endl;  
            return 0;  
        }  
        prev = a;  
    }  
    cout << "Yes" << endl;                                                   
}  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(int (i) = 0; i <= (n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define elm1(pair) (pair).first
#define elm2(pair) (pair)).second
typedef long long ll;
typedef unsigned long long ull;
const ull MOD = 1000000007;
ull mpow(ull a, ull n);
ull inv_mod(ull a){return mpow(a, MOD-2);}

ull mpow(ull a, ull n)
{
    ull ans = 1;
    while(n>>=1){
        if(n & 1)(ans *= a)%= MOD;
        (a*=a)%=MOD;
    }
    return ans;
}

ull nCr(ull n, ull r)
{
    vector<ull> factorial(n+1);
    factorial[0]=1;
    rep(i, n)factorial[i+1] = factorial[i]*(i+1)%MOD;
    return factorial[n]*(inv_mod(factorial[n-r])%MOD*inv_mod(factorial[r])%MOD) % MOD;
}

ll dp[3000][3000] = {0};

//max manpuku
ll naps(vector<pair<ll, ll>> F, ll T, ll n, ll M)
{
    if(n >= F.size())return M;
    if(T <= 0.5)return M;
    return max(naps(F, T-F[n].first, n+1, M+F[n].second), naps(F, T, n+1, M));
}

int main()
{
    ll N, T;
    cin >> N >> T;
    vector<pair<int, int>> F(N);
    rep(i, N)cin >> F[i].first >> F[i].second;

    sort(F.begin(), F.end());

    int ans = 0;
    vector<int> dp(T, 0);
    rep(i, N){
        ans =  max(ans, dp[T-1]+F[i].second);
        for(int j = T-1; j >= F[i].first; --j){
            dp[j] = max(dp[j], (dp[j - F[i].first]+F[i].second));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vec A(N);
    rep(i, N) cin >> A[i];
    if(A[0] != 0) drop(-1);

    ll ans = 0;
    ll prev = 0;
    rep(i, N){
        if(A[i] <= prev) ans += A[i];
        else if(A[i] == prev + 1) ++ans;
        else drop(-1);
        prev = A[i];
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		
		String in = scanner.nextLine();
		
		int a = Integer.parseInt(in);
		
		String[] nums = in.split("");
		
		int sum = 0;
		for (String num : nums) {
			sum += Integer.parseInt(num);
		}
		
		if (a % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
		
}


Measured memory_bytes: 21972
fun main(args: Array<String>) {
    a86(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a86(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (a, b) = args[0].split(" ").map { it.toInt() }
    println(if ((a * b) % 2 == 0) "Even" else "Odd")
}

Measured memory_bytes: 37924
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    double x[3], y[3];
    rep(i, 3){
        cin >> x[i] >> y[i];
    }

    vector<double> l;
    double s = 0.0;
    rep(i, 3){
        rep(j, i){
            l.emplace_back(sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])));
            s += l.back();
        }
    }
    s *= 0.5;

    double S = s;
    rep(i, 3){
        S *= s - l[i];
    }
    S = sqrt(S);

    double r = 2.0 * S / (l[0] + l[1] + l[2]);

    SORT_INV(l);

    double ans = (l[0] * r) / (l[0] + 2.0 * r);

    cout << fixed << setprecision(10) << ans << endl;

    cout << flush;

    return 0;
}

// (1-ans/r)l[0]=2ans
// l[0]-l[0]ans/r=2ans
// l[0]r-l[0]ans=2rans
// -l[0]ans-2rans=-l[0]r
// l[0]ans+2rans=l[0]r
// (l[0]+2r)ans=l[0]r
// ans=l[0]r/(l[0]+2r)

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

void test();
int interest(int debt, double interest_rate,int n);

int main(void)
{
	test();
	return 0;
}

void test()
{
	long long debt;
	int n;
	debt = 100000;
	cin >> n;

	debt = interest(debt, 1.05, n) ;
	
	cout << debt << endl;
}

int interest(int debt, double interest_rate,int n)
{

	if (n == 1)
	{	
		int intedebt = debt*interest_rate;
		if((intedebt%1000) != 0)
			return intedebt - intedebt%1000 + 1000;
		else
		{
			return intedebt;
		}
	}
	else
	{
		int func_intedebt = interest(debt, interest_rate, n - 1) * interest_rate;
		if ((func_intedebt % 1000) != 0)
			return func_intedebt - func_intedebt % 1000 + 1000;
		else
			return func_intedebt;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, X; cin >> A >> B >> X;
    string res = "NO";
    if(A + B >= X and X >= A){ 
        res = "YES";
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input()) + 1
ans = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for val in range(n):
    if len(make_divisors(val)) == 8 and val%2 != 0:
        ans += 1
print(ans)


Measured memory_bytes: 38640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

const double EPS = 1e-10;
bool equals(double a, double b){ return (fabs(a) - fabs(b)) < EPS;};

class Point{
public:
	double x, y;
	
	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point(const Point &p) { x = p.x; y = p.y;};
	
	Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
	Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
	Point operator * (const double &a) { return Point(x * a, y * a); }
	Point operator / (const double &a) { return Point(x / a, y / a); }
	
	Point & operator = (const Point& p) {x = p.x; y = p.y; return *this;};
	Point & operator += (const Point& p) {x += p.x; y += p.y; return *this;};
	Point & operator -= (const Point& p) {x -= p.x; y -= p.y; return *this;};
	Point & operator *= (const Point& p) {x *= p.x; y *= p.y; return *this;};
	Point & operator /= (const Point& p) {x /= p.x; y /= p.y; return *this;};
	
	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	
	bool operator > (const Point &p) const {
		return x != p.x ? x > p.x : y > p.y;
	}
	
	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
	
	double abs() { return sqrt(norm()); };
	double norm() { return x * x + y * y;};
};

typedef Point Vector;


double norm(Vector a){
	return a.x * a.x + a.y * a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

struct Segment{
	Point p1, p2;
};

typedef Segment Line;


bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a,b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2){
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1 - a2, b1 - b2);
}

bool isPrallel(Segment s1, Segment s2){
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef vector<Point> Polygon;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int q;
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		Segment s1, s2;
		cin>>s1.p1.x>>s1.p1.y>>s1.p2.x>>s1.p2.y;
		cin>>s2.p1.x>>s2.p1.y>>s2.p2.x>>s2.p2.y;
		
		if(isPrallel(s1,s2)) cout<<2<<endl;
		else if(isOrthogonal(s1,s2)) cout<<1<<endl;
		else cout<<0<<endl;
	}
	
	
	return 0;
}


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

N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a, b, -c))
dist = [float('inf')] * (N+1)
dist[1] = 0
for _ in range(N-1):
    for u, v, weight in edges:
        if dist[v] > dist[u] + weight:
            dist[v] = dist[u] + weight
negative = [False] * (N+1)
for _ in range(N):
    for u, v, weight in edges:
        if dist[v] > dist[u] + weight:
            dist[v] = dist[u] + weight
            negative[v] = True
print('inf' if negative[N] else -dist[N])

Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vec = vector<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)

bool isP(string s)
{
	string t = s;
	reverse(t.begin(), t.end());
	return s == t;
}

int main()
{
	string s1;
	cin >> s1;
	string s2 = s1.substr(0, s1.size()/2);

	bool ans = isP(s1) && isP(s2);
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int h, w, map[51][51];

void island(int _w, int _h) {
	map[_w][_h] = 2;
	for (int i = -1;i <= 1;i++) {
		for (int j = -1;j <= 1;j++) {
			if (_w + i >= 1 && _w + i <= h&&_h + j >= 1 && _h + j <= w&&map[_w + i][_h + j] == 1) {
				island(_w + i, _h + j);
			}
		}
	}
}

int main() {
	while (cin >> w >> h, w + h) {
		for (int i = 1;i <= h;i++) {
			for (int j = 1;j <= w;j++) {
				cin >> map[i][j];
			}
		}
		int count = 0;
		for (int i = 1;i <= h;i++) {
			for (int j = 1;j <= w;j++) {
				if (map[i][j] == 1) {
					count++, island(i, j);
				}
			}
		}
		cout << count << endl;
		for (int i = 1;i <= 50;i++)for (int j = 1;j <= 50;j++)map[i][j] = -1;
	}
	return 0;
}

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

using i64 = long long;
const i64 LLINF = (1LL << 60);

int M;
int d;
i64 c;
i64 sum = 0;
i64 digit = 0;

int main()
{
    cin >> M;
    for ( int i = 0; i < M; i++ ) {
        cin >> d >> c;
        digit += c;
        sum += d * c;
    }
    
    cout << digit + (sum - 1) / 9 - 1 << endl;

    return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e6+5;
const ll mod =   1e9+7;
int a[10000000];
int main()
{  fast
int n;
cin>>n;
ll ans=1;
a[1]=1;

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

		for(int j=i;j<=n;j+=i)
		a[j]++;

}
for(int i=2;i<=n;i++){
//	cout<<a[i]<<" ";
	ans+=1ll*(1ll*i*(a[i]+1));

}
cout<<ans;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i,j,k,c = 0;
		int[][] a;
		a = new int[n][n];
		for(i=0; i<n; i++){
			a[0][i] = sc.nextInt();
			a[1][i] = sc.nextInt();
			a[2][i] = sc.nextInt();
			}
		for(i=0; i<3; i++){
			for(j=0; j<n; j++){
					for(k=j+1; k<n; k++){
					if(a[i][j] == a[i][k]){
						a[i][k] = 0;
						c = c + 1;
						}
					}
					if(c > 0){
						a[i][j] = 0;
					}
					c = 0;
				}
			}
		for(i=0; i<n; i++){
			System.out.println(a[0][i] + a[1][i] + a[2][i]);
		}
	}
}

Measured memory_bytes: 20964
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;
const int M = 1000000007;

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

	vector<long long> t(n + 2), a(n + 2);
	rep(i,n) cin >> t[i + 1];
	rep(i,n) cin >> a[i + 1];
	t[0] = -1;
	a[n + 1] = -1;

	vector<long long> T(n + 2, 0);
	vector<long long> k(n + 2);
	rep(i,n){
		if(t[i] != t[i + 1]){
			T[i + 1] = true;
		}
		k[i + 1] = t[i + 1];
	}
	T[1] = true;
	//rep(i,n + 2){ cout << k[i] << ' '; }cout << endl;

	for(int i = n + 1; i >= 2; i--){
		if(T[i - 1]) continue;
		if(a[i] != a[i - 1]){
			T[i - 1] = true;
		}
		k[i - 1] = min(k[i - 1], a[i - 1]);
	}
	T[n] = true;
	//rep(i,n + 2){ cout << k[i] << ' '; }cout << endl;
	
	int cur = 0;
	range(i,1,n + 1){
		cur = k[i];
		if(cur > t[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	cur = 0;
	for(int i = n; i >= 1; i--){
		cur = k[i];
		if(cur > a[i]){
			cout << 0 << endl;
			return 0;
		}
	}

	long long ans = 1;
	range(i,1,n + 1){
		if(not T[i]) (ans *= k[i]) %= M;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3328