akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L;
int Q;
int X[101010];
int ne[101010][20];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i];
	cin>>L;
	
	FOR(i,N) ne[i][0]=lower_bound(X+i,X+N,X[i]+L+1)-1-X;
	FOR(i,19) {
		FOR(x,N) ne[x][i+1]=ne[ne[x][i]][i];
	}
	
	cin>>Q;
	while(Q--) {
		cin>>x>>y;
		x--,y--;
		if(x>y) swap(x,y);
		
		int day=0;
		for(i=19;i>=0;i--) {
			if(ne[x][i]<y) {
				x=ne[x][i];
				day+=1<<i;
			}
		}
		
		cout<<day+1<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int dfs(int v);
int n,m;
int g[51][51];
int f[51];
int main(){
  int cnt=0;
  memset(g,0,sizeof(g));
  cin>>n>>m;
  int a[m+1],b[m+1];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    g[a[i]][b[i]]=1;
    g[b[i]][a[i]]=1;
  }
  for(int i=0;i<m;i++){
    memset(f,0,sizeof(f));
    g[a[i]][b[i]]=0;
    g[b[i]][a[i]]=0;
    dfs(0);
    g[a[i]][b[i]]=1;
    g[b[i]][a[i]]=1;
    for(int j=0;j<n;j++){
      if(f[j]==0){
        cnt++;
        break;
      }
    }
  }
  cout<<cnt<<endl;
  return(0);
}

int dfs(int v){
  f[v]=1;
  for(int i=0;i<m;i++){
    if(g[v][i]==1&&f[i]==0){
      dfs(i);
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t;
    t=1;
    while(t--)
    {
      ll n;
      cin>>n;
      vector<pair<string,int> > v;
      set<string> st;
      map<string,ll> mp;
      ll mx=0;
      for(int i=0;i<n;i++)
      {
          string s;
          cin>>s;
          mp[s]++;
          mx=max(mx,mp[s]);
          st.insert(s);
      }
      set<string> s1;
      auto it=st.begin();
      while(it!=st.end())
      {
          string s=(*it);
          if(mp[s]==mx)
            s1.insert(s);
          it++;
      }
      it=s1.begin();
      while(it!=s1.end())
      {
          string s=(*it);
          cout<<s<<"\n";
          it++;
      }
    }
}


Measured memory_bytes: 43904
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    if v[0] == v[1] {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
t = input().split()

N = int(t[0])
M = int(t[1])

y = [input() for i in range(M)]

#import pdb; pdb.set_trace()
#まだ未完了
l = [-1] * N
i = 0
ans = 0

if ('1 0' in y) and (N != 1):
  ans = -1

while i < M:
  y[i] = y[i].split()
  a = int(y[i][0])
  b = int(y[i][1])

  if  l[a-1] == -1:
    l[a-1] = b
  elif l[a-1] != b:
    ans = -1
    break
  i += 1

#import pdb; pdb.set_trace()

while -1 in l:
  k  = l.index(-1)
  l[k] = 0

if (l[0] == 0) and (N != 1):
  l[0] = 1

if ans == 0:
  k = N
  while k > 0:
    ans += l[-k] * (10 ** (k-1))
    k -= 1

print(ans)

Measured memory_bytes: 3064
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll Ans = a * c;

    Ans = max(Ans, a * d);
    Ans = max(Ans, b * c);
    Ans = max(Ans, b * d);

    cout << Ans;
}


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

      char c;

      int[] data = new int[s.length()];

      for(int i = 0;i<s.length();i++){
       c = s.charAt(i);
       data[i] = (int)c +n;
       if(data[i]>90){
         data[i]= Math.abs(90-data[i])+64;
       }
     }

     for(int i = 0;i<s.length();i++){
      System.out.print((char)data[i]);

    }
    System.out.println();


  }
}

Measured memory_bytes: 25940
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c,d;

int main(){
  cin >> a >> b >> c >> d;
  int e = c-a;
  int f = d-b;
  cout << c-f << " " << d+e << " " << a-f << " " << b+e <<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
time = []
for i in range(5):
    time.append(int(input()))


def ten_time(x):
    return (x + 9) // 10 * 10


def rem(x):
    return ten_time(x) - x


ans = 0
for i in range(len(time)):
    ans += ten_time(time[i])

ans -= rem(max(time, key=rem))

print(ans)


Measured memory_bytes: 3060
//-----------------------
// author : xyqkoala
// time : 2020-09-20
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;cin>>n;
	int cnt = 0;
	bool f = false;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x==y){
			cnt++;
			if(cnt>=3) f = true;
		}else{
			cnt = 0;
		}
	}
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>
#include <limits.h>
#include<stdlib.h>





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

	if (n >= 30) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;



int main()
{   
    
  int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=0;i<n;++i)
     scanf("%d",&a[i]);
     
   int h[8],cnt=0;

   for(i=0;i<8;++i)
       h[i]=0;
       
       
    
      
     
    for(i=0;i<n;++i)
     {
         if(a[i]>=1 && a[i]<=399)
             h[0]++;
             
        else if(a[i]>=400 && a[i]<=799)
             h[1]++;
             
        else if(a[i]>=800 && a[i]<=1199)
             h[2]++;
             
        else if(a[i]>=1200 && a[i]<=1599)
             h[3]++;
             
        else if(a[i]>=1600 && a[i]<=1999)
             h[4]++;
        
        else if(a[i]>=2000 && a[i]<=2399)
             h[5]++;
             
        else if(a[i]>=2400 && a[i]<=2799)
             h[6]++;
             
        else if(a[i]>=2800 && a[i]<=3199)
             h[7]++;   
             
        else
          cnt++;
     }
     
     int cnt1=0;
     
     for(i=0;i<8;++i)
        {
            if(h[i]>0)
               cnt1++;
        }
    if(cnt1>0)    
    printf("%d %d",cnt1,cnt1+cnt); 
    
    else
      printf("1 %d",cnt); 
      
   
      return 0;    
}
      

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

#[fastout]
fn main() {
    input! {
        mut n: String,
    }
    let mut sum = 0;
    for c in n.chars() {
        sum += c.to_digit(10).unwrap();
    }
    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" });

}


Measured memory_bytes: 2388
# -*- coding: utf-8 -*-
 
N = int(input())

B = [int(e) for e in input().split()]

A = [0] * N

A[0] = B[0]
A[1] = B[0]

for i in range(1, N - 1):
	A[i] = min(B[i], A[i])
	A[i + 1] = B[i]

print(sum(A))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

bool odd(int A){
    return A % 2 == 0;
}

int main()
{
    int A, B;
    cin >> A >> B;
    
    if((odd(A) && odd(B)) || (!odd(A) && !odd(B))){
        cout << (A+B) / 2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var p = int.Parse(line[2]);
            if (n == 0 && m == 0 && p == 0) break;
            var wbuy = 0; var wtotal = 0;
            for (int i = 0; i < n; i++)
            {
                var a = int.Parse(Console.ReadLine().Trim());
                wtotal += a;
                if (i == m - 1) wbuy = a;
            }
            if (wbuy == 0) Console.WriteLine(0);
            else Console.WriteLine(wtotal * (100 - p) / wbuy);
        }
    }
}

Measured memory_bytes: 9264
#include<stdio.h>
int main()
{
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='+'){
            printf("%d\n", a+b);
        }
        else if(op=='-'){
            printf("%d\n", a-b);
        }
        else if(op=='*'){
            printf("%d\n", a*b);
        }
        else if(op=='/'){
            printf("%d\n", a/b);
        }
        else if(op='?'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            if (input[0] < input[1])
            {
                if (input[1] > input[2] && input[2] > input[0])
                {
                    WriteLine("Yes");
                }
                else
                {
                    WriteLine("No");
                }
                return;
            }
            else
            {
                if (input[0] > input[2] && input[2] > input[1])
                {
                    WriteLine("Yes");
                }
                else
                {
                    WriteLine("No");
                }
                return;
            }

        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;

    vl a(x);
    rep(i, x) {
        cin >> a[i];
    }
    vl b(y);
    rep(i, y) {
        cin >> b[i];
    }
    vl c(z);
    rep(i, z) {
        cin >> c[i];
    }
    
    vl v;
    rep(i, x) {
        rep(j, y) {
            v.pb(a[i]+b[j]);
        }
    }
    sort(rall(v));

    vl ans;
    rep(i, min(k, x*y)) {
        rep(j, z) {
            ans.pb(v[i]+c[j]);
        }
    }
    sort(rall(ans));

    rep(i, k) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 43368
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      k: i64,
      abs: [(i64, i64); n],
    }
    let mut abs = abs;
    abs.sort_by_key(|a| a.0);
    let mut k = k;
    let mut i = 0;
    loop {
        k -= abs[i].1;
        if k <= 0 {
            println!("{}", abs[i].0);
            return;
        }
        i += 1;
    }
}


Measured memory_bytes: 6396
K = 96
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
P = 998244353
pa = (1 << 64) - ((1 << 64) % P)
m = int(("1" * 32 + "0" * 64) * 3030, 2)
modP = lambda x: x - ((x & m) >> 64) * pa
s = 1 << K * S
for a in A:
    s = 2 * s + (s >> K * a)
    s = modP(s)
print((s & ((1 << K) - 1)) % P)

Measured memory_bytes: 72768
#include<iostream>
#include<string.h>

using namespace std;

#define MAX_NUM 100

int main(void) {
  int table[MAX_NUM + 1][MAX_NUM + 1];
  int row, column, target;
  int sum4Row = 0;
  int sum4Column[MAX_NUM + 1];
  cin >> row;
  cin >> column;
  memset(table, 0, sizeof(table));
  memset(sum4Column, 0, sizeof(sum4Column));

  for(int i = 0; i < row; i++) {
    for(int j = 0; j < column; j++) {
      cin >> target;
      table[i][j] = target;
      sum4Column[j] += target;    
      sum4Row += target;
    }
    table[i][column] = sum4Row;
    sum4Row = 0;
  }

  for(int i = 0; i < row; i++) {
    for(int j = 0; j < column + 1; j++) {
      if(j == column) { 
        cout << table[i][j];
      }
      else {
        cout << table[i][j] << " ";
      }
    }
    cout << endl;
  }
  int sum4Final = 0;
  for(int i = 0; i < column; i++) {
    cout << sum4Column[i] << " ";
    sum4Final += sum4Column[i];
  }
  cout << sum4Final << endl;
  
  return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }
    vector<int> left(m), right(m);
    int ans;
    bool flag = true;
    rep(i, m) {
        if (i == 0) {
            left[i] = l[i];
            right[i] = r[i];
          	if (right[i] > n) right[i] = n;
        } else {
            if (l[i] > right[i-1] || r[i] < left[i-1]) {
                flag = false;
                break;
            } else {
                if (l[i] > left[i-1]) left[i] = l[i];
                else left[i] = left[i-1];
                if (r[i] < right[i-1]) right[i] = r[i];
                else right[i] = right[i-1];
            }
        }
        
    }
    if (flag) {
        // if (right[m-1] <= n) {
            ans = right[m-1] - left[m-1] + 1;
        // } else if (left[m-1] >= n) {
        //     ans = n - left[m-1] + 1;
        // } else {
        //     ans = 0;
        // }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(20);
  vector<vector<int>> A(20,vector<int>(20));
  int data = 0;
  int counter = 0;

  for(int i = 0;i < M;i++){
    cin >> B[i];
  }
  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      cin >> A[i][j];
    }
  }

  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      data += A[i][j] * B[j];
    }
    data += C;
    if(data > 0)counter++;
    data = 0;
  }

  cout << counter << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
using namespace std;
typedef complex<long long> P;

inline P::value_type cross(const P& a, const P& b) { return a.real()*b.imag() - b.real()*a.imag(); }

bool ok(const vector<P>& ps, int N, int i1, int i2)
{
  const int NM = ps.size();
  const int color = i1 < N;
  int cnt[2][2] = {{0, 0}, {0, 0}};
  for (int i = 0; i < NM; i++) {
    const long long c = cross(ps[i2] - ps[i1], ps[i] - ps[i1]);
    const int col = i < N;
    if (c == 0) {
      if (color != col) {
        return false;
      }
    } else {
      ++cnt[col][c < 0];
    }
  }
  return (cnt[0][0] == 0 && cnt[1][1] == 0) || (cnt[0][1] == 0 && cnt[1][0] == 0);
}

bool check(const vector<P>& ps, int N)
{
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (ok(ps, N, i, j)) {
        return true;
      }
    }
  }
  const int NM = ps.size();
  for (int i = N; i < NM; i++) {
    for (int j = i+1; j < NM; j++) {
      if (ok(ps, N, i, j)) {
        return true;
      }
    }
  }
  return false;
}

inline int cmp(long long x, long long y)
{
  if (x == y) {
    return 0;
  } else if (x < y) {
    return -1;
  } else {
    return 1;
  }
}

bool check_edgecase(const vector<P>& ps, const int N)
{
  const int NM = ps.size();
  const int x = cmp(ps[0].real(), ps[N].real());
  for (int i = 0; i < N; i++) {
    for (int j = N; j < NM; j++) {
      if (x != cmp(ps[i].real(), ps[j].real())) {
        return false;
      }
    }
  }
  const int y = cmp(ps[0].imag(), ps[N].imag());
  for (int i = 0; i < N; i++) {
    for (int j = N; j < NM; j++) {
      if (y != cmp(ps[i].imag(), ps[j].imag())) {
        return false;
      }
    }
  }
  return true;
}

int main()
{
  int N, M;
  while (cin >> N >> M && N != 0) {
    vector<P> ps(N+M);
    for (int i = 0; i < N+M; i++) {
      cin >> ps[i].real() >> ps[i].imag();
    }

    bool straight = true;
    if (N+M > 2) {
      const long long c0 = cross(ps[2]-ps[0], ps[1]-ps[0]);
      for (int i = 3; i < N+M; i++) {
        const long long c = cross(ps[i]-ps[0], ps[1]-ps[0]);
        if (c != c0) {
          straight = false;
          break;
        }
      }
    }
    if (straight) {
      cout << (check_edgecase(ps, N) ? "YES" : "NO") << endl;
    } else {
      cout << (check(ps, N) ? "YES" : "NO") << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a=0,t;
  cin>>n;
  for(int i=1;i<n+1;++i){
    cin>>t;
    if(t!=i)a+=1;
  }
  if(a<=2)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=1; i<=n; ++i) cin >> a[i];
  
  int cnt = 1;
  bool flag = true;
  int i = 1;
  while(flag){
    if(cnt == n) flag = false;
    if(a[i] == 2) break;
    i = a[i];
    ++cnt;
  }
  if(flag) cout << cnt;
  else cout << -1;
    
  return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    d = []
    for i in range(N):
        d.append(int(input()))
    d.sort()
    d.reverse()
    t = 101
    cnt = 0
    for i in range(len(d)):
        if t > d[i]:
            t = d[i]
            cnt += 1
    print(cnt)
main()  

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

int main(){
  int N,K;
  cin >> N >> K;
  int A[60];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);
  int sum = 0;
  for(int i=0;i<K;i++){
    sum += A[N-1-i];
  }
  cout << sum << endl;
}  
  
  
    

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())
S = list(input())
Q = int(input())

D = {chr(ord('a') + i): [] for i in range(26)}

for i, s in enumerate(S):
    D[s].append(i)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1]), query[2]
        i -= 1
        s = S[i]
        if s == x:
            continue

        D[s].remove(i)
        next_i = bisect_left(D[x], i)
        D[x].insert(next_i, i)
        S[i] = x

    if query[0] == '2':
        l, r = int(query[1]), int(query[2])
        l, r = l - 1, r - 1
        ans = 0
        for i in range(26):
            s = chr(ord('a') + i)

            li = bisect_left(D[s], l)
            ri = bisect_right(D[s], r)

            if ri - li > 0:
                ans += 1

        print(ans)

Measured memory_bytes: 134500
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define lli long long int
 
using namespace std;
 
int main() {
  
  string str;
  getline(cin, str);

  vector<char> ans;

  rep(i, str.size()) {
    if (str[i] >= 'a' && str[i] <= 'z') {
      ans.push_back(str[i] - 0x20);
    }
    else if (str[i] >= 'A' && str[i] <= 'Z') {
      ans.push_back(str[i] + 0x20);
    }
    else {
      ans.push_back(str[i]);
    }
  }

  rep(i, str.size()) {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3160
#include<iostream>
 
using namespace std;
int main()
{
	int a,b,c,x;
	cin >> a >> b;
	int tmp = b,i;
	for(i=0; tmp>0; i++){
		tmp /= 10;
	}
	for(int j=0; j<i; j++){
		a *= 10;
	}
	int ab = a+b;
	for(int j=0; j<1111; j++){
		if(ab == j*j){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int n, dp[N] = { };
vi v[N], vv;
void dfs(int node, int par) {
	dp[node] = 1;
	for (auto u : v[node]) {
		if (u == par)
			continue;
		dfs(u, node);
		dp[node] += dp[u];
	}
}
int p1, p2;
void dfs2(int node, int par) {
	vv.pb(node);
	if (node == n) {
		if (vv.size() & 1) {
			p1 = vv[vv.size() / 2];
			p2 = vv[vv.size() / 2 + 1];
		} else {
			p1 = vv[vv.size() / 2 - 1];
			p2 = vv[vv.size() / 2];
		}
		dfs(1, 0);
		int subtreen = dp[p2];
		clr(dp, 0);
		dfs(n, 0);
		int subtree1 = dp[p1];
		if (subtree1 > subtreen) {
			puts("Fennec");
			exit(0);
		}
		puts("Snuke");
		exit(0);
	}
	for (auto u : v[node]) {
		if (u == par)
			continue;
		dfs2(u, node);
	}
	vv.pop_back();
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n;
	lp(i,1,n-1)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs2(1, 0);
	return 0;
}

Measured memory_bytes: 17528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int size = Integer.parseInt(br.readLine());
		Set<String> set = new HashSet<String>();
		String[] strInputNums = br.readLine().split(" ");
		for (int i = 0; i < size; i++) {
			if (!set.contains(strInputNums[i])) {
				set.add(strInputNums[i]);
			}
		}
		size = Integer.parseInt(br.readLine());
		strInputNums = br.readLine().split(" ");
		int matchCnt = 0;
		for (int i = 0; i < size; i++) {
			if (set.contains(strInputNums[i])) {
				matchCnt++;
			}
		}
		System.out.println(matchCnt);
	}
}

Measured memory_bytes: 48568
let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []
    
let rec take n l =
  match l with
    [] -> []
  | x :: xs ->
    if n = 0 then
      []
    else x :: take (n - 1) xs

let rec drop n l =
  match l with
    [] -> []
  | x :: xs ->
    if n = 0 then
      l
    else drop (n - 1) xs 

let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let s = Scanf.sscanf (input_line stdin) "%s" (fun a -> a) in
  let judge cs =
    let mae = take (n/2) cs in
    let ushiro = drop (n/2) cs in
    List.for_all2 (fun a b -> a = b) mae ushiro in
  let ans = if n mod 2 = 1 then "No" else if judge (explode s) then "Yes" else "No"
  in
  print_string ans;
  print_newline ()


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    ll n;
    cin >> n;
    string s;
    map<string, ll> m;
    rep1(i, n){
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    ll ans = 0;
    for (auto x: m){
        ll v = x.second;
        ans += v * (v- 1) / 2;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 11428
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

struct Info
{
	int id;
	string name;
	int score;

	Info()
	{
	}
	Info(int i, string s, int n)
	{
		id = i + 1;
		name = s;
		score = n;
	}
};

struct {
    bool operator()(const Info &a , const Info & b )const
    {   
		if(a.name != b.name)
		{
			//名前はalphabet順
			return a.name < b.name;
		}
		else
		{
			//特典は高い順
			//Trueが先になる
			return a.score > b.score;
		}
    }   
} customSort;
//末尾に宣言で実体

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


	vector<Info> info(n);

	for(int i = 0; i < n; i++)
	{
		string s;
		int n;
		cin >> s >> n;

		//vector.at: vector.[i]と近いが、範囲外参照時にエラーを返してくれる
		info.at(i) = Info(i,s,n);

	}

	//sort
	//template< class RandomIt, class Compare >
	//void sort( RandomIt first, RandomIt last, Compare comp );
	sort(info.begin(), info.end(), customSort);

	//sort(info.begin(), info.end(), [](const Info &a , const Info & b)
	//{
	//	if(a.name != b.name)
	//	{
	//		//名前はalphabet順
	//		return a.name < b.name;
	//	}
	//	else
	//	{
	//		//特典は高い順
	//		//Trueが先になる
	//		return a.score > b.score;
	//	}
//
	//}
	//);
	for(int i = 0; i < n; i++)
	{
		
		cout << info.at(i).id << endl;

	}

};

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

class UnionFind {
public:
    vector<int> parent;
    vector<int> setSize;

    UnionFind(unsigned int size) {
        parent.resize(size + 1);
        iota(parent.begin(), parent.end(), 0);
        setSize.resize(size + 1, 1);
    }

    // xとyが同じ集合に属するか
    bool isSameSet(int x, int y) {
        return findRoot(x) == findRoot(y);
    }

    // xとyの属する集合を併合
    void unionSet(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) { return; }

        parent[x] = y;
        setSize[y] += setSize[x];
    }

private:
    // 木の根を求める
    int findRoot(int x) {
        if (parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = findRoot(parent[x]);
        }
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    vector<int> num_idx(N);
    FOR(i, 0, N) {
        cin >> P[i];
        P[i]--;
        num_idx[P[i]] = i;
    }

    UnionFind uf(N);
    FOR(i, 0, M) {
        int x, y;
        cin >> x >> y;
        uf.unionSet(x - 1, y - 1);
    }


    int ans = 0;
    FOR(i, 0, N) {
        int idx = num_idx[i];
        ans += uf.isSameSet(i, idx);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 1792
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

int n, m;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  return 1;
}

const int maxn = (int) 3e2 + 10;
int dp[2][maxn][maxn];

void solve() {
  memset(dp, 0, sizeof(dp));
  int rot = 0;
  dp[rot][1][1] = 1;
  for (int iter = 1; iter <= m; ++iter) {
    memset(dp[!rot], 0, sizeof(dp[!rot]));
    for (int j = 1; j <= n; ++j) {
      for (int into = 1; into <= j; ++into) {
        int cur = dp[rot][j][into];
        if (!cur) {
          continue;
        }
        if (j < n) {
          add(dp[!rot][j + 1][into], mult(cur, n - j));
        }
        add(dp[!rot][j][into], mult(cur, j - into));
        add(dp[!rot][j][j], mult(cur, into));
      }
    }
    rot = !rot;
  }
  printf("%d\n", dp[rot][n][n]);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1024
#pragma region template 1.0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    vector<double> p(N);
    REP(i, N)
    {
        cin >> p[i];
    }

    vector<double> dp(N + 1);
    dp[0] = 1;
    REP(i, N)
    {
        dp[i + 1] = dp[i] * p[i];
        for (ll j = i; j > 0; --j)
        {
            dp[j] = dp[j] * (1 - p[i]) + dp[j - 1] * p[i];
        }
        dp[0] = dp[0] * (1 - p[i]);
    }
    double ans = 0;
    for (ll i = (N / 2 + 1); i <= N; ++i)
    {
        ans += dp[i];
    }

    cout << fixed << setprecision(15) << ans << endl;
}
#pragma endregion template

Measured memory_bytes: 256
#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 getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit = 100000;
int num[limit+10];

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

	rep(i,n){
		int in;
		cin >> in;
		num[in+1]++;
	}

	int ans = 0;

	rep(i,1,limit+1) chmax(ans,num[i-1]+num[i]+num[i+1]);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
x1,y1,x2,y2 = gets.split.map(&:to_i)

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
N, K = map(int, input().split())
A = [int(i) - 1 for i in input().split()]

def solve() :
  global K
  visited = [-1] * N
  visited[0] = 0

  cur = 0
  while True :
    nex = A[cur]
    if visited[cur] == K - 1 :
      return nex + 1
      
    if visited[nex] == -1 :
      visited[nex] = visited[cur] + 1
      cur = nex
    else :
      # 一回目
      i = visited[nex]
      # 二回目
      j = visited[cur] + 1
      K -= i
      K %= (j - i)
      cur = nex
      break
      
  while K > 0 :
    cur = A[cur]
    K -= 1
    
  return cur + 1
    
print(solve())

Measured memory_bytes: 92148
// https://arc032.contest.atcoder.jp/tasks/arc032_2
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);

    rep(i, n) {
        cin >> h[i];
        dp[i] = INT_MAX;
    }

    dp[0] = 0;
    rep(i, n) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i + 2 < n)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[n - 1] << endl;
    return 0;
};


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int a,b,c,i,count=0;
	scanf("%d%d%d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		if(c % i == 0){
			count++;
		}
	}
		
	printf("%d\n",count);
	return 0;
	
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,a,b) for(i=a;i<=b;i++)
#define pb push_back;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll m,n,i,j,k,p=1000000007,count=0,flag=0,temp1=0,temp2=0;
  
        
   cin>>n;
  ll N=2e5+5;
  ll store[N]={0};
 ll arr[n];
 for(i=0;i<n;i++)cin>>arr[i];

  for(i=0;i<n;i++)
  {
    store[arr[i]]++;
  }

for(i=0;i<N;i++)
{
  if(store[i]>0)count+=((store[i])*(store[i]-1)/2);
}

for(i=0;i<n;i++)
{
  cout<<count-store[arr[i]]+1<<"\n";
}


return 0; 
 
 
}

Measured memory_bytes: 5760
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var A =parseInt(lines[0]);
    var B =parseInt(lines[1]);
    var C = A+B;
    
    if (A <= 0 || B > 100){
        console.log("Impossible");
    }else if (A%3 == 0 || B%3 == 0 || C % 3 == 0){
        console.log("Possible");
    }else{
        console.log("Impossible");
    }
});

Measured memory_bytes: 7500
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::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...);
    }
#else
#define deb(...)
#endif


const int mxn=1e5+1;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            ll n,x,ans=0,i;
    cin>>n>>x;
    ll arr[n];
    fr(i,0,n)
    cin>>arr[i];
    sort(arr,arr+n);
    fr(i,0,n)
    {
        if(x>0)
        {
            ans++;
            x-=arr[i];
            if(x<0)
                ans--;
        }
    }
    if(x>0)
        ans--;
    cout<<ans;

    }
  return 0;
  }




Measured memory_bytes: 256
#include<iostream>

double x[4], y[4];

int main()
{
	while( 1 ){
		for( int i = 0; i < 4; i++ ){
		 	if( !( std::cin >> x[i] >> y[i] ) ) goto end;
		}
	
		if( ( x[1] - x[0] ) * ( x[3] - x[2] ) + ( y[1] - y[0] ) * ( y[3] - y[2] ) == 0 ){
		 	std::cout << "YES" << std::endl;
		}
		else{
		 	std::cout << "NO" << std::endl;
		}
	}
end:

 	return 0;
}

Measured memory_bytes: 1212
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	private static final Scanner IN = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		new Main().run();
	}
	private static final int MAX_N = 100000;
	private static final int MAX_Q = 100000;
	
	private int n;
	private int q;
	
	private final int[] p = new int[MAX_N - 1];
	private final boolean[] isQuery = new boolean[MAX_Q];
	private final int[] v = new int[MAX_Q];
	
	private final int[] marked = new int[MAX_N];
	private final int[] parent = new int[MAX_N];
	
	private void run() {
		
		while(((n = IN.nextInt()) | (q = IN.nextInt())) != 0) {
			
			for (int i = 0; i < n - 1; i ++) {
				
				p[i] = IN.nextInt() - 1;
			}
			Arrays.fill(marked, 0, n, - 1);
			marked[0] = q;
			for (int i = 0; i < q; i ++) {
				
				isQuery[i] = IN.next().charAt(0) == 'Q';
				v[i] = IN.nextInt() - 1;
				if(!isQuery[i] && marked[v[i]] < 0) {
					
					marked[v[i]] = i;
				}
			}
			
			initialize();
			
			long summation = 0;
			for (int i = q - 1; i >= 0; i --) {
				
				if (isQuery[i]) {
					
					summation += find(v[i]) + 1;
					
				} else if (marked[v[i]] == i) {
					
					union(v[i], p[v[i] - 1]);
				}
			}
			System.out.println(summation);
		}
	}
	
	private void initialize() {
		
		Arrays.fill(parent, 0, n, -1);
		for (int i = 0; i < n; i ++) {
			
			initialize(i);
		}
	}
	
	private int initialize(int x) {
		
		if (parent[x] == - 1) parent[x] = (marked[x] >= 0) ? x: initialize(p[x - 1]);
		return parent[x];
	}
	
	private int find(int x) {
		
		if (parent[x] != x) parent[x] = find(parent[x]);
		return parent[x];
	}
	
	private void union(int x, int y) {
		
		parent[x] = find(y);
	}
}

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

using namespace std;

using ll=long long;

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

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<int>prefix_gcd(n);
    vector<int>suffix_gcd(n);
    int g=0;
    for(int i=0;i<n;i++)
    {
        g=gcd(g,v[i]);
        prefix_gcd[i]=g;
    }
    g=0;
    for(int i=n-1;i>=0;i--)
    {
        g=gcd(g,v[i]);
        suffix_gcd[i]=g;
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int c=0;
        if(i>0) c=gcd(c,prefix_gcd[i-1]);
        if(i+1<n)c=gcd(c,suffix_gcd[i+1]);
        ans=max(ans,c);
    }
    cout<<ans<<endl;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

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

int uf[212345], sz[212345];

int find(int u) {
  if (uf[u] == u)
    return u;
  else
    return uf[u] = find(uf[u]);
}

bool merge(int x, int y) {
  int a = find(x), b = find(y);
  if (a == b) return false;
  if (sz[a] < sz[b]) swap(a, b);
  uf[b] = a;
  sz[a] += sz[b];
  return true;
}

//#define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  rep(i, 0, n + 1, 1) {
    uf[i] = i;
    sz[i] = 1;
  }
  rep(i, 0, m, 1) {
    int a, b;
    cin >> a >> b;
    merge(a, b);
  }
  int ans = 0;
  rep(i, 1, n + 1, 1) { ans = max(ans, sz[find(i)]); }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 6776
package main

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

func stringsToInts(s, sep string) []int {
	ss := strings.Split(s, sep)
	ints := make([]int, 0)
	for _, c := range ss {
		i, err := strconv.Atoi(c)
		if err != nil {
			continue
		}
		ints = append(ints, i)
	}
	return ints
}

func intsToStrings(ints []int) []string {
	strs := make([]string, 0)
	for _, i := range ints {
		c := strconv.Itoa(i)
		strs = append(strs, c)
	}
	return strs
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		ints := stringsToInts(line, " ")
		sort.Slice(ints, func(i, j int) bool {
			return ints[i] < ints[j]
		})
		sints := intsToStrings(ints)
		fmt.Println(strings.Join(sints, " "))
	}

	if err := scanner.Err(); err != nil {
		// log.Println(err)
		return
	}
}



Measured memory_bytes: 1136
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;cin>>n;
  vi d(n);
  rep(i,n) cin>>d[i];
  int ans =0;
  for(int i =0; i<n-1;i++){
    for(int j=i+1; j<n;j++){
      ans += d[i]*d[j];
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 256