akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

long long int array[200001];

int main()
{
    int a = 0, b = 0, c;
    long long int n, answer = 0;
    long long int divide_num = 1;
    long long int array_sum = 0;
    long long int same_array_mul_sum = 0;

    for (int i = 0; i<9; i++)
    {
        divide_num *= 10;
    }

    divide_num += 7;

    scanf("%lld", &n);

    for (int i = 0; i<n; i++)
    {
        scanf("%lld", &array[i]);
    }

    for (int i = 0; i<(int)n; i++)
    {
        array_sum += array[i];

        if (array_sum > divide_num)
        {
            a ++;
            array_sum %= divide_num;
        }
    }

    for (int i = 0; i<(int)n; i++)
    {
        same_array_mul_sum += array[i]*array[i];

        if (same_array_mul_sum > divide_num)
        {
            b ++;
            same_array_mul_sum %= divide_num;
        }
    }

    answer = (array_sum)*(array_sum) - same_array_mul_sum + divide_num;

    if (answer > divide_num)
    {
        answer %= divide_num;
    }

    c = a*a -b;

    answer *= (1 + divide_num);


    answer /= (long long int)2;

    answer %= divide_num;

    printf("%lld", answer);

    return 0;
}

Measured memory_bytes: 3204
N = int(input())
d = []
visited = [False for _ in range(N+1)]
for _ in range(N):
  d.append(int(input())-1)

i = 0
cnt = 0
while True:
  if i == 1:
    break
  elif cnt >= N:
    cnt = -1
    break
  elif visited[i]:
    cnt = -1
    break
  else:
    visited[i] = True
    cnt += 1
    i = d[i]
  
print(cnt)

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

int main(){
  int N;
  cin >> N;
  double t, v[N+1], ta[N];
  rep(i, N) {
    cin >> t;
    if(!i) ta[i] = t;
    else ta[i] = ta[i-1] + t;
  }
  rep(i, N) cin >> v[i];
  v[N] = 0.0, t = 0;
  int pos = 0;
  double ans = 0, vel = 0.0;
  while(t < ta[N-1]){
    bool can1 = true, can0 = true;
    for(int i = pos; i < N; i++){
      if(ta[i] - t  == vel - v[i+1]) can0 = false;
      if(ta[i] - t  - (vel - v[i+1]) == 1.0) can1 = false;
    }
    if(!can0) {
      ans += vel - 0.5;
      vel--;
    }
    else if(can0 && !can1){
      if(vel == v[pos]) ans += vel;
      else ans += vel + 0.25;
    }
    else if(vel < v[pos]){
      ans += vel + 0.5;
      vel++;
    } else ans += vel;
    t++;
    if(t >= ta[pos]) pos++;
  }
  printf("%6f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();
    int[] ind = new int[n+1];
    int[] score = new int[n];
    int[] additional = new int[n-1];

    ind[0] = n*2;
    for(int i = 1; i <= n; i++){
      ind[i] = sc.nextInt();
    }
    for(int i = 0; i < n; i++){
      score[i] = sc.nextInt();
    }
    for(int i = 0; i < n-1; i++){
      additional[i] = sc.nextInt();
    }



    int ans = 0;
    for(int i = 1; i <= n; i++){
      ans += score[ind[i]-1];
      if(ind[i] - ind[i-1] == 1){
        ans += additional[ind[i]-2];
      }
    }
 
    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    double a,b,x,M=3.14159265358979,rad,ans;
    cin >> a >> b >> x;
    if(x<=a*a*b/2){
        rad=atan(2*x/(a*b*b));
        ans=(rad/2/M)*360;
    }
    else{
        rad=atan(a/(2*b-(2*x/(a*a))));
        ans=(rad/2/M)*360;
    }
    cout << setprecision(15) << 90-ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 100010;
int a[8][N], n, b[8][N], t1[N], t2[N], k, ans[N], rec[N];
// b * c -> c_{b_i}
void mul(int *a,int *b,int *c) {
  static int tb[N], tc[N];
  rep (i, 1, n) tb[i] = b[i], tc[i] = c[i];
  rep (i, 1, n) a[i] = tc[tb[i]];
}
void getinv(int *a,int *b) {
  rep (i, 1, n) a[b[i]] = i;
}
void getpower(int* ret,int *a,int b) {
  rep (i, 1, n) ret[i] = i;
  while (b) {
    if (b&1) mul(ret, ret, a);
    mul(a, a, a);
    b >>= 1;
  }
}
int main() {
  read(n), read(k);
  rep (i, 1, 2) rep (j, 1, n)
    read(a[i][j]);
  getinv(b[1], a[1]), getinv(b[2], a[2]);
  rep (i, 3, 6) {
    mul(a[i], b[i-2], a[i-1]);
    mul(b[i], b[i-1], a[i-2]);
  }
  // A = Q^{-1} P Q P^{-1}
  mul(t1, b[2], a[1]), mul(t1, t1, a[2]), mul(t1, t1, b[1]);
  getinv(t2, t1);
  int tmp = (k - 1) / 6;
  getpower(ans, t1, tmp);
  mul(ans, ans, a[(k-1) % 6 + 1]);
  getpower(rec, t2, tmp);
  mul(ans, ans, rec);
  rep (i, 1, n) printf("%d ", ans[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#include <functional>
#include <map>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int x;
	int a, b;

	cin >> x;

	switch (x)
	{
	case 1:
		cout << "Hello World" << endl;
		break;

	case 2:
		cin >> a >> b;
		cout << a + b << endl;

	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
hh = gets.chomp.split.map(&:to_i)

min = 1000000000000000
min_h = 0

hh.each_with_index do |h, i|
  kion = t - h * 0.006
  diff = (a - kion).abs
  if diff < min
    min = diff
    min_h = i
  end
end

puts min_h + 1


Measured memory_bytes: 1788
W,H,m,c[10][10];
DP[10][10][10][10][51];//cà[yÀW][xÀW][¶[][E[][_fcÊ]
#define Update(tgt,val) ((val)>(tgt)?tgt=(val):0)
CalcO(o,x,y){//_fcÊÌvZ
	if(c[x][y]>0){
		o+=c[x][y];
		if(o>m)
			o=m;
	}
	return o;
}
CalcF(f,x,y){//càÌvZ
	if(c[x][y]<0)
		f+=c[x][y];
	return f;
}
main(){
	int x,y,range,d,dx,f,o,xl,xr,fn,on,f0;
	for(;scanf("%d%d",&W,&H),W;){
		scanf("%d%d%d",&f0,&m,&o);
		for(y=0;y<H;y++)
			for(x=0;x<W;x++)
				scanf("%d",&c[x][y]);
		f0++;//cà0ÅàDPÍ1ÆµÄANAÉÈéÌðh®
		if(o>1)
			for(x=0;x<W;x++)
				DP[0][x][x][x][CalcO(o-1,x,0)]=CalcF(f0,x,0);
		for(y=0;y<H-1;y++){
			for(range=0;range<W;range++){//¶EÉ@éL³
				for(o=m;o>1;o--){
					for(d=0;d<2;d++){//»ÝÊuxð³¹é
						for(xl=0;xl<W-range;xl++){//¶[
							for(dx=0;dx<=range;dx++){//xÏÊ
								xr=xl+range;
								x=d?xl+dx:xr-dx;
								if(f=DP[y][x][xl][xr][o]){
									//ºÖ@é
									fn=CalcF(f,x,y+1);
									on=CalcO(o-1,x,y+1);
									Update(DP[y+1][x][x][x][on],fn);
									if(x>0){
										if(x==xl){//¶Ö@é
											fn=CalcF(f,x-1,y);
											on=CalcO(o-1,x-1,y);
											Update(DP[y][x-1][x-1][xr][on],fn);
										}else{//¶ÖiÞ
											Update(DP[y][x-1][xl][xr][o-1],f);
										}
									}
									if(x<W-1){
										if(x==xr){//EÖ@é
											fn=CalcF(f,x+1,y);
											on=CalcO(o-1,x+1,y);
											Update(DP[y][x+1][xl][x+1][on],fn);
										}else{//EÖiÞ
											Update(DP[y][x+1][xl][xr][o-1],f);
										}
									}
								}
							}//dx
						}//xl
					}//d
				}//o
			}//range
		}//y
		fn=0;
		for(x=0;x<W;x++){
			for(o=m;o>0;o--){
				f=DP[H-1][x][x][x][o];
				if(f>fn)
					fn=f;
			}
		}
		printf(fn?"%d\n":"NA\n",f0-fn);
		memset(DP,0,sizeof(DP));
	}
	//puts("");
	exit(0);
}

Measured memory_bytes: 0
#[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" ) };
}

fn main() {
    input! {
        n: usize,
        h: [usize;n],
        a: [u64;n]
    }

    let mut sqd = SqDecomposition::new(n+1, std::cmp::max, 0);
    for i in 0..n {
        let tmp = sqd.fold(h[i]+1) + a[i];
        sqd.update(h[i], tmp);
    }
    println!("{}", sqd.fold(n+1));
}

#[allow(dead_code)]
struct SqDecomposition {
    all: Vec<u64>,
    sq: Vec<u64>,
    d: usize,
    op: Box<Fn(u64, u64) -> u64>,
    init: u64,
}
#[allow(dead_code)]
impl SqDecomposition {
    fn new<B>(n: usize, op: B, init: u64) -> SqDecomposition
    where
        B: Fn(u64, u64) -> u64 + 'static,
    {
        let d = (n as f64).sqrt().ceil() as usize;
        SqDecomposition {
            all: vec![init; n],
            sq: vec![init; d],
            d: d,
            op: Box::new(op),
            init: init,
        }
    }
    fn update(&mut self, i: usize, a: u64) {
        self.all[i] = a;
        self.sq[i / self.d] = (self.op)(self.sq[i / self.d], a);
    }
    #[doc = " [0,n)"]
    fn fold(&self, n: usize) -> u64 {
        let mut ret = self.init;
        for i in 0..n / self.d {
            ret = (self.op)(ret, self.sq[i]);
        }
        for i in 0..n % self.d {
            ret = (self.op)(ret, self.all[n - n % self.d + i]);
        }
        ret
    }
}

Measured memory_bytes: 10492
N,K = map(int,input().split())
mod = 10**9+7

ans = 0
cnt = 0
gs = dict()
for i in range(K,1,-1):
    n = pow(K//i,N,mod)
    for j in range(2,K+1):
        if i*j > K: break
        n -= gs[i*j]
        n %= mod
    gs[i] = n
    ans += n*i%mod
    ans %= mod
    cnt += n
    cnt %= mod
ans += pow(K,N,mod) - cnt
ans %= mod
print(ans)

Measured memory_bytes: 20776
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	//*/
	int ABCD = 0;
	boolean ans = false;
	
	public void input() throws IOException {
		/*
		S = br.readLine();
		/*/
		ABCD = in.nextInt();
		//*/
	}

	public void solve() throws IOException {
		
		int A = ABCD/1000;
		int B = (ABCD/100)%10;
		int C = (ABCD/10)%10;
		int D = ABCD%10;
		
		ans = (A==B && B==C) || (B==C && C==D);
		
	}
	
	public void output() {
		out.println(ans?"Yes":"No");
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


Measured memory_bytes: 21076
A, B, M = map(int, input().split())
LA = [int(a) for a in input().split()]
LB = [int(b) for b in input().split()]
T = [[int(t) for t in input().split()] for _  in range(M)]
C = 10 ** 9
for i in range(M):
    C = min(LA[T[i][0]-1]+LB[T[i][1]-1]-T[i][2], C)
print(min(C, min(LA)+min(LB)))


Measured memory_bytes: 32496
#include <stdio.h>

int i, n;

int main() {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            printf(" %d", i);
        } else {
            if (i % 10 == 3) {
                printf(" %d", i);
            } else {
                if ((i % 100 >= 30) && (i % 100 <= 39)) {
                    printf(" %d", i);
                } else {
                    if ((i % 1000 >= 300) && (i % 1000 <= 399)) {
                        printf(" %d", i);
                    } else {
                        if ((i % 10000 >= 3000) && (i % 10000 <= 3999)) {
                            printf(" %d", i);
                        }
                    }
                }
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 2104
N = gets.to_i
x = []
y = []
t = []
N.times do
  line = gets.split.map(&:to_i)
  t << line[0]
  x << line[1]
  y << line[2]
end

s = 0
while s < N
  if s == 0
    if x[s]+y[s] > t[s]
      puts "No"
      exit 0
    end
    if (x[s]+y[s])%2 != t[s]%2
      puts "No"
      exit 0
    end
  else
    if((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs) > t[s]-t[s-1]
      puts "No"
      exit 0
    end
    if(((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs)%2 != (t[s]-t[s-1])%2)
      puts "No"
      exit 0
    end
  end
  s+=1
end
puts "Yes"

Measured memory_bytes: 4248
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        int len = int.Parse(Reader.ReadLine());

        List<string> list = new List<string>();

        for (int i = 0; i < inpt.Length; i += len)
        {
            if (i + len > inpt.Length)
            {
                list.Add(inpt.Substring(i));
            } else {
                list.Add(inpt.Substring(i, len));
            }
        }
        string ans = string.Join("", list.Select(a => a.Substring(0, 1)));
        Console.WriteLine(ans);
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


abcdefgh
3


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		double[][] pos = new double[20][2];
		int n = 0;
		while(stdIn.hasNext()){
			String[] a = stdIn.next().split(",");
			pos[n][0] = Double.parseDouble(a[0]);
			pos[n++][1] = Double.parseDouble(a[1]);
		}
		double sum = 0;
		for(int i=0;i<n-1;i++){
			sum += (pos[i][0]-pos[i+1][0])*(pos[i][1]+pos[i+1][1]);
		}
		sum += (pos[n-1][0]-pos[0][0])*(pos[n-1][1]-pos[0][1]);
		sum = sum/2;
		if(sum<0){
			sum *= -1;
		}
		System.out.printf("%.6f\n",sum);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>

using namespace std;


const double pi = 2*acos(0);

int main() {
    //freopen("output.txt", "w", stdout);
    int r; cin >> r;
    cout << fixed << setprecision(4);
    cout << (3.14159) * (double)r * 2 << endl;
}

Measured memory_bytes: 3780
from collections import defaultdict
import math
n = math.factorial(int(input()))
i = 2
factors = defaultdict(int)
ans = 1
while i**2 <= n:
    while n%i==0:
        n //= i
        factors[i] += 1
    i += 1
if n > 1:
    factors[n] += 1
for k,v in factors.items():
    ans = (ans*(v+1))%(10**9+7)
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int n, m;
int limit = 50;
vector<int> a(limit), b(limit);
vector<vector<bool>> graph(limit, vector<bool>(limit));
vector<bool> visited(limit);

void dfs(int v) {
  visited.at(v) = true;
  for (int v2 = 0; v2 < n; v2++) {
    if (graph.at(v).at(v2) == false) continue;
    if (visited.at(v2) == true) continue;
    dfs(v2);
  }
}

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

  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
    graph.at(a.at(i)).at(b.at(i)) = graph.at(b.at(i)).at(a.at(i)) = true;
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    graph.at(a.at(i)).at(b.at(i)) = graph.at(b.at(i)).at(a.at(i)) = false;
    for (int j = 0; j < n; j++) {
      visited.at(j) = false;
    }

    dfs(0);

    bool bridge = false;
    for (int j = 0; j < n; j++) {
      if (visited.at(j) == false) bridge = true;
    }

    if (bridge) ans += 1;
    graph.at(a.at(i)).at(b.at(i)) = graph.at(b.at(i)).at(a.at(i)) = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define sz(x) x.size()

using namespace std;

int main(){
    int n;cin>>n;
    vector<int>a(n);
    for(int i =0 ;i <n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    cout<<a[n/2]-a[n/2-1];
}

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


int main() 
{
	int a,b,c,d;
	
	scanf("%d%d",&a,&b);
	if(b>=a)
	  printf("unsafe");
	  else
	  printf("safe");
    for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
  for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
  for(int zz=0;zz<1000;zz++) if(zz%2==0) zz++; 
	return 0;
}


Measured memory_bytes: 1732
n = gets.chomp.to_i
x = gets.chomp.split(' ').map(&:to_i)

a = []
n.times{|i| a.push( {:index => i, :value => x[i]} )}
a.sort!{|lhs, rhs| lhs[:value] <=> rhs[:value]}

b = [0] * n
n.times{|i| b[ a[i][:index] ] = i }

n.times do |i|
  j = b[i]
  
  if j >= (n / 2) then
    puts a[(n / 2) - 1][:value].to_s
  else
    puts a[n / 2][:value].to_s
  end
end

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

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

  string ans = "No";

  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == 'A') {
      if (S[i + 1] == 'C') {
        ans = "Yes";
      }
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    int N, x;
    std::cin >> N >> x;

    std::vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> a[i];
    }
    
    std::sort(a.begin(), a.end());

    int ret = 0;
    for (int i = 0; i < N; ++i) {
        x -= a[i];
        if (x >= 0) {
            ++ret;
        } else {
            break;
        }
    }
    
    if (x > 0) {
        --ret;   
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
N=int(input())
a=[int(x) for x in list(str(N))]
s=a[0]*100+a[0]*10+a[0]
t=s+111
if a[0]>a[1]:
    print(s)
elif a[0]==a[1]:
    if a[1]<a[2]:
        print(t)
    else:
        print(s)
else:
    print(t)

Measured memory_bytes: 3064
function Main(_input) {
    var num_X = parseInt(_input);
    var num_org = 100;
    var num_Y = num_org;
    var year = 0;
    while(true){
        year++;
        num_Y = Math.floor(num_Y * 1.01);
        if(num_Y >= num_X) break;
    }
    console.log(year);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a*b%2==0){
        cout<<"Even"<<endl;
    }else{
        cout<<"Odd"<<endl;
    }
    return 0;
}

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

long long int N, M, a, b, r = 1, s, i, j, l;

int decimaldigits(long long A){
    int j, k;
    for(j = 0, k = 1; k < A; ++j, k *= 10);
    return j;
}

int main(){
    scanf("%lld", &N);
    if(N % 9)return 0 & puts("0");
    N /= 9;
    M = N;
    for(l = 0; l < 30; ++l){
        a = decimaldigits(N) + l;
        for(i = 0; a >= 0; a -= 2, ++i){
            if(a == 0 && N != 0){r = 0; break;}
            r *= (i ? 10 : 9) - N % 10;
            b = ((long long int)pow(10, a) - 1) / 9 * (N % 10);
            N = abs(N - b);
            N /= 10;
            //cout << a << " " << r << " " << b << " " << N << endl;
        }
        if(N != 0)r = 0;
        s += r;
        r = 1;
        N = M;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int a, b; cin >> a >> b;
    string ans = "Impossible";
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
        ans = "Possible";
    }
    cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

ll calc (const ll& a, const char& op, const ll& b)
{
    ll ans;

    switch (op)
    {
        case '+':
        {
            ans = a + b; 
            break;
        }
        case '-':
        {
            ans = a - b; 
            break;
        }
        case '*':
        {
            ans = a * b; 
            break;
        }
        case '/':
        {
            ans = a / b; 
            break;
        }
        case '?':
        {
           ans = a % b; 
           break;
        }
        default:
        {
            cerr << "Error: Unknown operator." << endl;
            return 1;
        }
    }

    return ans;
}

int main()
{
    ll a, b;
    char op;

    while(cin >> a >> op >> b)
    {
        if (op == '/' || op == '?')
        {
            if (b == 0)
            {
                //cout << a << op << b << endl;
                continue;
            }
        } 

        if (op == '?')
        {
            if (a >= b)
                continue;
        }

        cout << calc(a, op, b) << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
using System;

class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] nums = Console.ReadLine().Split(' ');
    int count = 0;
    int h = 0;
    
    for(int i = 0; i < N; i++)
    {
      if(h <= int.Parse(nums[i]))
      {
        h = int.Parse(nums[i]);
        count++;
      }
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int> v;
for(int i=0;i<n;i++)
{   int x;
    cin>>x;
    v.push_back(x);

}
vector<int> dp(n,0);
for(int i=n-2;i>=0;i--)
{
    dp[i]=INT_MAX;
    for(int j=1;j<=k;j++)
    {
      if(j+i==n)
            break;
      dp[i]=min(dp[i],dp[i+j]+abs(v[i]-v[i+j]));

    }
  

}
cout<<dp[0];
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  reverse(h.begin(), h.end());
  int ans = 0;
  int val = 0;
  for (int i = 1; i < n; i++) {
    if (h[i-1] <= h[i]) val++;
    else val = 0;
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

  int r,g,b;
  int ans;
  cin >> r >> g	>> b;
  ans = 100*r+10*g+b;
  if(ans%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

bool f(int l, int r, int j, vector<int>& x, vector<int>& a, vector<int>& b, vector<int>& c, vector<vector<vector<int> > >& memo) {
	if (memo[l][r][j] != -1) return memo[l][r][j];
	if (r - l == 1 && x[l] == a[j]) return memo[l][r][j] = 1;
	for (int m = l + 1; m <= r - 1; m++)
		if (f(l, m, b[j], x, a, b, c, memo) && f(m, r, c[j], x, a, b, c, memo))
			return memo[l][r][j] = 1;
	return memo[l][r][j] = 0;
}

int main() {
	int N; cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; i++)
		cin >> x[i];
	int M; cin >> M;
	vector<int> a(M), b(M), c(M);
	for (int j = 0; j < M; j++) {
		cin >> a[j] >> b[j] >> c[j];
		b[j]--; c[j]--;
	}
	vector<vector<vector<int> > > memo(N + 1, vector<vector<int> >(N + 1, vector<int>(M, -1)));
	cout << (f(0, N, 0, x, a, b, c, memo) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1932
#include<bits/stdc++.h>
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
const int N=5e5+5;
struct P{
	int l,r,w;
}s[26][N<<2];
char str[N];
inline int  read(){//inline read()
	int f=1,res=0;
	char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')f=-1;
	while(c>='0'&&c<='9')res=(res<<3)+(res<<1)+(c^48),c=getchar();//res+=res*10+c-'0' 
	return f*res;
}
void build(int p,int l,int r,int pos){
	s[pos][p].l=l,s[pos][p].r=r;s[pos][p].w=0;//w
	if(l==r)return;
	int mid=l+r>>1;
	build(p*2,l,mid,pos);
	build(p*2+1,mid+1,r,pos);
}
void update(int p,int x,int pos,int w){
	if(s[pos][p].l==s[pos][p].r&&s[pos][p].l==x){
		s[pos][p].w+=w;
		return;
	}
	int mid=s[pos][p].l+s[pos][p].r>>1;
    if(x<=mid)update(p*2,x,pos,w);
     else update(p*2+1,x,pos,w);
    s[pos][p].w=s[pos][p*2].w+s[pos][p*2+1].w;
    //if(s[pos][p].w)cout<<s[pos][p].l<<' '<<s[pos][p].r<<' '<<s[pos][p].w<<' '<<pos<<endl;
}
int query(int p,int l,int r,int pos){
	//cout<<pos<<' '<<s[pos][p].l<<' '<<s[pos][p].r<<s[pos][p].w<<endl;
	int res=0;
	if(s[pos][p].l>=l&&s[pos][p].r<=r)return s[pos][p].w;
	int mid=s[pos][p].l+s[pos][p].r>>1;
	if(l<=mid)res+=query(2*p,l,r,pos);
	if(r>mid)res+=query(2*p+1,l,r,pos);//res+query(2*p+1,l,r,pos);
	//if(res)cout<<s[pos][p].l<<' '<<s[pos][p].r<<' '<<res<<' '<<pos<<endl;
	return res;
}
int main(){
	int n=read();
	scanf("%s",str+1);
	for(int i=0;i<26;i++)build(1,1,n,i);
	for(int i=1;i<=n;i++)update(1,i,str[i]-97,1);
	int q=read();
	for(;q;q--){
		int ope=read();
		if(ope==2){
			int l=read(),r=read(),ans=0;
			for(int i=0;i<26;i++)
			{
		//	cout<<i<<' '<<query(1,l,r,i)<<endl;
			 if(query(1,l,r,i))ans++;}
			printf("%d\n",ans);
		}
		else{
			int pos=read();
			char a[3];
			scanf("%s",a);
			update(1,pos,str[pos]-97,-1);
			update(1,pos,a[0]-97,1);
			str[pos]=a[0];
		}
	}
	return 0;
}

Measured memory_bytes: 373120
#include <stdio.h>
int main(void)
{
	char s[6];
	
	scanf("%s", s);
	
	if(s[0] == 'S'){
		printf("Cloudy");
	}else if(s[0] == 'C'){
		printf("Rainy");
	}else{
		printf("Sunny");
	}
	
	return 0;
}

Measured memory_bytes: 128
# 入力
N,M=map(int,input().split())

l1=[]
for i in range(N):
    l1.append(list(map(int,input().split())))

l2=[]
for i in range(M):
    l2.append(list(map(int,input().split())))


for i in range(N):
    # 距離の最小値（1つ目のチェックポイントへの距離で初期化している）
    d=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])

    # 最も近いチェックポイントの番号（1番目で初期化）
    b=1

    # 2つ目以降のチェックポイントへの距離を求める
    for j in range(1,M):
        x=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])

        # 距離がより小さい場合のみ更新
        if x<d:
            d=x
            # 0-index なので調整するために +1 している
            b=j+1

    # チェックポイントの番号を出力
    print(b)

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

int main(void){
  int b=0,d=0;
  string c;
  cin>>c;
  for(int i=0;i<c.size();i++){
    if(c[i]=='A'){
      d = i;
      break;
    }
  }
  for(int i=c.size();i>=0;i--){
    if(c[i]=='Z'){
      b =i;
      break;
    }
  }
  cout<<b-d+1<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double s = (double)w*h/2.0;
  int ismult = (x == w/2.0 && y == h/2.0);
  cout << fixed << setprecision(9) << s << " " << ismult << endl;
  return 0;
}


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

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  G[u].append(v)
  G[v].append(u)
seen = [-1]*n
p, q, r = 0, 0, 0
def dfs(v):
  stack = [(v, 0)]
  seen[v] = 0
  f = False
  while stack:
    v, c = stack.pop()
    for nv in G[v]:
      if seen[nv] == -1:
        seen[nv] = c^1
        stack.append((nv, c^1))
      else:
        if seen[nv]^c == 0:
          f = True
  return f
for v in range(n):
  if seen[v] != -1:
    continue
  if not G[v]:
    r += 1
  else:
    if dfs(v):
      p += 1
    else:
      q += 1
ans = r*(2*n-r) + (p+q)*(p+q) + q*q
print(ans)

Measured memory_bytes: 36932
import numpy as np
M = 10**9+7
N = int(input())
X = np.array(list(map(int,input().split())))

D = X[1:]-X[:N-1]

ans = 0
s = 0
nn = 1
for n in range(1,N):
    nn *= n
    nn %= M

for i,d in enumerate(D):
    s = (s + pow((i+1),M-2,M))%M
    ns = (nn*s) % M
    ans = (ans + ns*d %M ) % M
    ans %= M

print(ans)

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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  scanf("%d %d", &n, &m);

  double res = 0;

  double prev = 1, ord = 1, cor = pow(2,m);

  while(true){
    if(prev / cor * ord * (1900 * m + (n - m) * 100) < 1e-11){
      break;
    }

    res += prev/cor*ord*(1900*m + (n - m) * 100);
    ord++;
    
    prev *= 1.0 - 1.0 / cor;

  }

  printf("%d\n", (int)ceil(res));
  return 0;
}



Measured memory_bytes: 256
from collections import Counter
N,K=map(int,input().split())
A=list(map(int,input().split()))

cnt=Counter(A)
cnt_sorted=sorted(cnt.items(), reverse=True,key=lambda x:x[1])

sum=0
for i in range(min(K,len(cnt))):
    sum+=cnt_sorted[i][1]

print(N-sum)

Measured memory_bytes: 42936
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3=x2-(y2-y1);
  y3=y2+(x2-x1);
  x4=x3-(y3-y2);
  y4=y3+(x3-x2);
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC066
{
    class C
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            List<int> list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                if (i % 2 != 0) { list.Add(a[i]); }
                else { list.Insert(0, a[i]); }
            }

            if (n % 2 == 0) { list.Reverse(); }
            Console.WriteLine(string.Join(" ", list));
        }
    }
}


Measured memory_bytes: 43704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const int INF = 1001001001;
 
vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];
 
void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}
 
int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using Graph = vector<vector<int>>;

int main(void){
    int N;cin>>N;
    Graph G(N+1);
    for(int i=1;i<N;i++){
        int a,b;cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N+1,-1);
    queue<int> que;

    dist[1] = 0;
    que.push(1);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int next_v : G[v]){
            if(dist[next_v]!=-1) continue;

            if(dist[v]==0){
                dist[next_v] = 1;
            }else{
                dist[next_v] = 0;
            }
            que.push(next_v);
        }
    }

    vector<int> p(N+1);

    int red = 0,blue = 0;
    for(int i=1;i<=N;i++){
        if(dist[i]==0){
            red++;
        }else{
            blue++;
        }
    }
    int Nred=1,Nblue=2,Nwhite=3;
    if(red>N/3&&blue>N/3){
        for(int i=1;i<=N;i++){
            if(dist[i]==0){
                if(Nred<=N){
                    p[i] = Nred;
                    Nred += 3;
                }else{
                    p[i] = Nwhite;
                    Nwhite += 3;
                }
            }else{
                if(Nblue<=N){
                    p[i] = Nblue;
                    Nblue += 3;
                }else{
                    p[i] = Nwhite;
                    Nwhite += 3;
                }                
            }
        }
    }else if(red<=N/3){
        for(int i=1;i<=N;i++){
            if(dist[i]==0){
                p[i] = Nwhite;
                Nwhite += 3;
            }else{
                if(Nred<=N){
                    p[i] = Nred;
                    Nred += 3;
                }else if(Nblue<=N){
                    p[i] = Nblue;
                    Nblue += 3;
                }else{
                    p[i] = Nwhite;
                    Nwhite += 3;
                }
            }
        }
    }else{
        for(int i=1;i<=N;i++){
            if(dist[i]==1){
                p[i] = Nwhite;
                Nwhite += 3;
            }else{
                if(Nred<=N){
                    p[i] = Nred;
                    Nred += 3;
                }else if(Nblue<=N){
                    p[i] = Nblue;
                    Nblue += 3;
                }else{
                    p[i] = Nwhite;
                    Nwhite += 3;
                }
            }
        }        
    }
    for(int i=1;i<=N;i++){
        cout << p[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 15220
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] d = new int[n];
        double d1 = 0;
        double d2 = 0;
        double d3 = 0;
        double di = 0;
        for (int i = 0; i < n; i++) 
            x[i] = sc.nextInt();
        for (int i = 0; i < n; i++)
            y[i] = sc.nextInt();
        for (int i = 0; i < n; i++) {
            d[i] = Math.abs(x[i]-y[i]);
            d1 += d[i];
            d2 += Math.pow(d[i],2);
            d3 += Math.pow(d[i],3);
            di = Math.max(di,d[i]);
        }
        System.out.println(d1);
        System.out.println(Math.sqrt(d2));
        System.out.println(Math.cbrt(d3));
        System.out.println(di);
    }
}


Measured memory_bytes: 26420
# https://atcoder.jp/contests/arc091/tasks/arc091_a

n, m = gets.split.map(&:to_i)

res = (n - 2) * (m - 2) if n > 1 && m > 1
res = [n * m - 2, 0].max if n == 1 || m == 1
res = 1 if n == 1 && m == 1

puts res

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

typedef long long ll;

int main(){
    int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<int> p(A),q(B),r(C);

    for(int i=0; i<A; i++) cin>>p[i];
    for(int i=0; i<B; i++) cin>>q[i];
    for(int i=0; i<C; i++) cin>>r[i];

    vector<ll> cut;

    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());

    for(int i=0; i<X; i++) cut.push_back(p[i]);
    for(int i=0; i<Y; i++) cut.push_back(q[i]);
    for(int i=0; i<C; i++) cut.push_back(r[i]);

    sort(cut.begin(),cut.end(),greater<ll>());

    ll ans = accumulate(cut.begin(),cut.begin()+X+Y,0ll);

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    vvi ans(h,vi(w,-1));
    for(int i=0;i<b;i++){
        for (int j=0;j<a;j++){
            ans[i][j]=0;
        }
        for(int j=a;j<w;j++){
            ans[i][j]=1;
        }
    }
    for(int i=b;i<h;i++){
        for (int j=0;j<a;j++){
            ans[i][j]=1;
        }
        for (int j=a;j<w;j++){
            ans[i][j]=0;
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;

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

    long long x;
    cin >> x;

    long long p = 100, cnt = 0;
    while(p < x)
    {
        p = p + (p * 0.01);
        cnt++;
    }

    cout << cnt;

    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

void Main() {
  int H = read<int>();
  int W = read<int>();
  vector<string> M(H);
  rep(i, H) M[i] = read<string>();

  int inf = 1e9;
  int ans = 0;

  rep(lef, W-1) {
    int rig = lef+1;

    vvi C(H+1, vi(H+1));

    rep(d, H*2+1) {
      vi D(H+1);
      int l = d <= H ? d : 0;
      int r = d >= H ? d-H : 0;
      rep(i, H) {
        if (l+i > H-1) continue;
        if (r+i > H-1) continue;
        if (M[l+i][lef] == M[r+i][rig]) D[i]++;
      }
      rep(i, H) D[i+1] += D[i];

      rep(i, H) {
        int a = l + i;
        int b = r + i;
        if (a <= H && b <= H) C[a][b] = D[H-max(l, r)-i-1];
      }
    }

    vvi dp(H+1, vi(H+1, inf));
    dp[0][0] = 0;

    rep(i, H+1) rep(j, H+1) {
      if (i+1 <= H) amin(dp[i+1][j], dp[i][j] + C[i][j]);
      if (j+1 <= H) amin(dp[i][j+1], dp[i][j] + C[i][j]);
    }
    ans += dp[H][H];
  }

  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 1152