akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author /\
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DAtCoderExpress2 solver = new DAtCoderExpress2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAtCoderExpress2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();
            int[][] pre = new int[n + 2][n + 2];
            for (int i = 0; i < m; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                pre[1][r]++;
                pre[l + 1][r]--;
            }
            int[][] sum = new int[n + 2][n + 2];
            for (int i = 1; i < n + 2; i++) {
                for (int j = 1; j < n + 2; j++) {
                    sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + pre[i][j];
                }
            }
            while (q-- > 0) {
                int q1 = in.nextInt();
                int q2 = in.nextInt();
                out.println(sum[q1][q2]);
            }
        }

    }

    static class Scanner {
        private StringTokenizer st;
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 62884
//トポソの唯一性
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
 
int main(){
 
    int n, m; cin >> n >> m;
    vector<vector<int> > adj(n);
    vector<int> d(n, 0);                           //入次数
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;                   //a->bへ有向辺
        d[b]++;
        adj[a].push_back(b);
    }
 
    queue<int> q;
 
    //入次数が0の頂点queueに入れる
    for(int i = 0; i < n; i++){
        if(d[i] == 0) q.push(i);                    
    }
 
    vector<int> ans;
 
    while(!q.empty()){
 
        int v = q.front();
        q.pop();
        ans.push_back(v);
 
        //vから伸びている有向辺をなめる
        for(int i = 0; i < (int)adj[v].size(); i++){
            d[adj[v][i]]--;
            //辺を取り除いた後に入次数が0になったら
            if(d[adj[v][i]] == 0) q.push(adj[v][i]);
        }
 
    }
 
    for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  map<int, int> mp;
  for (int i = 0; i < 3; ++i) {
    Cin(int, a, b);
    mp[a]++;
    mp[b]++;
  }

  bool ok = true;
  for (auto e : mp)
    if (e.second >= 3) ok = false;

  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void cutBlock(vector<string>& block, int& h, int& w)
{
    int minY = INT_MAX;
    int maxY = INT_MIN;
    int minX = INT_MAX;
    int maxX = INT_MIN;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(block[i][j] == '#'){
                minY = min(minY, i);
                maxY = max(maxY, i);
                minX = min(minX, j);
                maxX = max(maxX, j);
            }
        }
    }

    h = maxY - minY + 1;
    w = maxX - minX + 1;
    block = vector<string>(block.begin()+minY, block.begin()+maxY+1);
    for(int i=0; i<h; ++i)
        block[i] = string(block[i].begin()+minX, block[i].begin()+maxX+1);
}

void rotateBlock(vector<string>& block, int& h, int& w)
{
    vector<string> ret(w, string(h, ' '));
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            ret[j][h-1-i] = block[i][j];
        }
    }
    swap(block, ret);
    swap(h, w);
}

int score(vector<string>& s)
{
    int h = s.size();
    int w = s[0].size();
    int ret = 0;
    for(int i=0; i<h; ++i){
        if(s[i] == string(w, '#'))
            ++ ret;
    }
    return ret;
}

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

    while(--n >= 0){
        int h1, w1;
        cin >> h1 >> w1;
        vector<string> block(h1);
        for(int i=0; i<h1; ++i)
            cin >> block[i];
        cutBlock(block, h1, w1);

        int h2, w2;
        cin >> h2 >> w2;
        vector<string> s(h2);
        for(int i=0; i<h2; ++i)
            cin >> s[i];

        int ret = -1;
        for(int a=0; a<4; ++a){
            for(int y=0; y<=h2-h1; ++y){
                for(int x=0; x<=w2-w1; ++x){
                    bool ng = false;
                    for(int i=0; i<h1; ++i){
                        for(int j=0; j<w1; ++j){
                            if(s[y+i][x+j] == '#' && block[i][j] == '#')
                                ng = true;
                        }
                    }
                    if(ng)
                        continue;

                    vector<string> t = s;
                    for(int i=0; i<h1; ++i){
                        for(int j=0; j<w1; ++j){
                            if(block[i][j] == '#')
                                t[y+i][x+j] = '#';
                        }
                    }
                    ret = max(ret, score(t));
                }
            }
            rotateBlock(block, h1, w1);
        }

        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=3000+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
int n,m;
int a[N];
int x[N],y[N];
void input()
{
	n=read<int>(),m=read<int>();
	For(i,1,n)a[i]=read<int>();
	For(i,1,m)
	{
		x[i]=read<int>(),y[i]=read<int>();
		//if(x[i]>y[i])swap(x[i],y[i]);
	}
}
int dp[N][N],tmp[N][N];
const int mo=1e9+7;
ll power(ll x,int y)
{
	ll res=1;
	for(;y;x=x*x%mo,y>>=1)if(y&1)res=res*x%mo;
	return res;
}
int inv;
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
void work()
{
	//inv=power(2,mo-2);
	inv=(mo+1)/2;
	For(i,1,n)For(j,i+1,n)
	{
		if(a[i]>a[j])dp[j][i]=1;
		if(a[i]<a[j])dp[i][j]=1;
	}
	For(i,1,m)
	{
		int u=x[i],v=y[i];
		For(j,1,n)tmp[j][u]=tmp[u][j]=tmp[v][j]=tmp[j][v]=0;
		For(j,1,n)if(j!=u&&j!=v)
		{
			add(tmp[j][v],(dp[j][u]+dp[j][v])%mo);
			add(tmp[j][u],(dp[j][u]+dp[j][v])%mo);
			add(tmp[u][j],(dp[u][j]+dp[v][j])%mo);
			add(tmp[v][j],(dp[u][j]+dp[v][j])%mo);
		}
		tmp[u][v]=tmp[v][u]=(dp[u][v]+dp[v][u])%mo;
		For(j,1,n)
		{
			dp[j][u]=1ll*tmp[j][u]*inv%mo;	
			dp[j][v]=1ll*tmp[j][v]*inv%mo;	
			dp[u][j]=1ll*tmp[u][j]*inv%mo;	
			dp[v][j]=1ll*tmp[v][j]*inv%mo;	
		}
	}
	int s=power(2,m);
	int ans=0;
	For(i,1,n)For(j,1,i-1)
	{
	//	cout<<1ll*dp[i][j]*s%mo<<(j==i-1?'\n':' ');
		add(ans,1ll*dp[i][j]*s%mo);
	}
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}



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

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0 ; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int x[3]{}, y[3];
	for (int i = 0; i < 3; i++) {
		y[i] = a[0][i];
	}
	for (int i = 0; i < 3; i++) {
		x[i] = a[i][0] - y[0];
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (a[i][j] != x[i] + y[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env ruby
require 'matrix'
n, m, l = gets.chomp.split.map(&:to_i)

a = []
b = []
n.times do
  a << gets.chomp.split.map(&:to_i)
end
m.times do
  b << gets.chomp.split.map(&:to_i)
end
ma = Matrix.build(n,m){|r, c| a[r][c]}
mb = Matrix.build(m,l){|r, c| b[r][c]}
# puts Matrix[b]
(ma * mb).to_a.map{ |r| puts r * ' ' }

Measured memory_bytes: 7792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

#define INF 1e9

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;
  while(cin >> n && n){
    vector<int> dp_a(n+1, INF), dp_b(n+1, INF);
    dp_a[0] = 0, dp_b[0] = 0;
    for(int i = 0; i <= 200; i++){
      int tetra = i * (i+1) * (i+2) / 6;
      for(int j = tetra; j <= n; j++){
        dp_a[j] = min(dp_a[j], dp_a[j-tetra] + 1);
        if(tetra%2 != 0) dp_b[j] = min(dp_b[j], dp_b[j-tetra] + 1);
      }
    }
    cout << dp_a[n] << ' ' << dp_b[n] << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

using namespace std;
int main() {
	string s, t, ch;
	int q, ty, f;

	cin >> s;
	cin >> q;
	rep(i, q) {
		cin >> ty;
		if (ty == 1) {
			swap(s, t);
		}
		else {
			cin >> f >> ch;
			if (f == 1)t += ch;
			else s += ch;
		}
	}
	reverse(t.begin(), t.end());
	t += s;
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int i,j,k,t,l,y;
  cin>>t;
  long int min=-1;
  long long sum=0;
  for(i=0;i<t;i++){
    cin>>y;
    sum+=y;
    if(min<y){
      min=y;
    }
  }
  if(min<sum-min){
      cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    int dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1) dp[i][j]=0;
    rep(i,n){
        rep(j,i){
            if(s[i]!=s[j])continue;
            if(i-dp[i][j]<=j)continue;
            chmax(dp[i+1][j+1],dp[i][j]+1);
        }
    }
    int res=0;
    rep(i,n+1)rep(j,n+1)chmax(res,dp[i][j]);
    cout<<res<<endl;
}

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

int a[2000];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%d", &a[i]);
		int Min = INT_MAX;
		rep(i, n)for (int j = i + 1; j < n; j++) {
			Min = min(Min, abs(a[j] - a[i]));
		}
		printf("%d\n", Min);
	}
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int xx = sc.nextInt();

		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		long gcd = Math.abs(x[0] - xx);
		for (int i = 1; i < n; i++) {
			gcd = gcd(gcd, Math.abs(x[i] - xx));
		}
		
		pr.println(gcd);
	}

	static long lcm(long n, long m) {
		return n / gcd(n, m) * m;
	}

	static long gcd(long n, long m) {
		if (m == 0) {
			return n;
		} else {
			return gcd(m, n % m);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 48608
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp         make_pair

typedef unsigned int uint;

uint solve(uint *in){
  uint key=0;
  int carry=0;
  rep(i,32){
    int cnt=0;
    rep(j,8){
      if (in[j]%2 == 1)cnt++;
    }

    if ((carry+cnt)%2 != in[8]%2){
      key+=(1<<i);  
      carry=(carry+8-cnt)/2;
    }else {
      carry=(carry+cnt)/2;
    }
    rep(j,9)in[j]/=2;
  }

  return key;
}


main(){
  int te;
  uint in[9];
  scanf("%d",&te);
  while(te--){
    rep(i,9){
      scanf("%x\n",&in[i]);
    }
    printf("%x\n",solve(in));
  }
  return false;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int res = 0 ;
		for(int i = 1 ; i <= k ; i++) {
			for(int j = 1 ; j<= k ; j++ ) {
				for(int t= 1 ; t <= k ; t++) {
					 res += gcd(gcd(i, j), t);
				}
			}
		}
		System.out.println(res);
	}

	 public static int gcd(int a, int b) 
     { 
         if (a == 0) 
             return b; 

         return gcd(b%a, a); 
     } 
}


Measured memory_bytes: 35764
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
int32_t main() {
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
    return 0;
}

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

int main() {
  string sNum; 
  
  cin >> sNum;
  
  if (sNum[0] == sNum[1] && sNum[1] == sNum[2]) {
    cout << "Yes" << endl;
  } else if (sNum[1] == sNum[2] && sNum[1] == sNum[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define db double
#define int LL
using namespace std;
const int N   = 3e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();

#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,a[N];
int check(int p)
{
	int tmp=0;
	rep(i,1,n) tmp+=abs(a[i]-p);
	return tmp;
}

signed main()
{
	read(n);
	rep(i,1,n) read(a[i]),a[i]-=i;
	sort(a+1,a+1+n);
	int mid=1+n>>1;
	int l=max(1ll,mid-10);
	int r=min(n,mid+10);
	int ans=INF;
	rep(i,l,r) ans=min(ans,check(a[i]));
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys

N, K = map(int, sys.stdin.readline().strip().split())
S = sys.stdin.readline().strip()

l = x = ans = 0
for r in range(N):
    if S[r] == '0' :
        if r == 0 or S[r-1] == '1':
            x += 1
    if x > K:
        while S[l] == '1':
            l += 1
        while S[l] == '0':
            l += 1
        x -= 1
    ans = max(ans, r-l+1)
print(ans)

Measured memory_bytes: 42096
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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)*}
    };
}

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

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,
        A: [i64; N+1],
        B: [i64; N],
    }
    let mut A = A;
    let mut B = B;
    let mut ans = 0;
    for i in 0..N {
        if A[i] > B[i] {
            let diff = B[i];
            A[i] = diff;
            B[i] = 0;
            ans += diff;
        } else {
            let diff = A[i];
            A[i] = 0;
            B[i] = B[i] - diff;
            ans += diff;
        }
        if A[i + 1] > B[i] {
            let diff = B[i];
            A[i + 1] = A[i + 1] - diff;
            B[i] = 0;
            ans += diff;
        } else {
            let diff = A[i + 1];
            A[i + 1] = 0;
            B[i] = B[i] - diff;
            ans += diff;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.range;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto nl = readNums!int;
  auto n = nl[0], l = nl[1];

  auto r = iota(l, l+n);
  auto sum = r.sum;

  int min = 1000;
  foreach(i; r){
    if(min.abs > i.abs) min = i;
  }

  writeln(sum - min);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc064.contest.atcoder.jp/tasks/arc064_c>
問題文============================================================
 xy 平面があります。 すぬけ君は座標 (xs,ys) から座標 (xt,yt) まで移動しようとしています。
 すぬけ君は好きな向きへ速さ 1 で動くことができます。 なお、すぬけ君は大きさのない点と見なすことにします。
 
 平面上には N 個の円形のバリアが張ってあります。
 i 番目のバリアは中心が (xi,yi) で半径が ri です。
 バリアは互いに重なっていたり、互いを含んでいたりすることがあります。
 
 平面上の各座標について、その座標がどのバリアの内部にも含まれない場合、その座標には宇宙線が降り注いでいます。
 
 すぬけ君は移動中にできるだけ宇宙線を浴びたくないので、宇宙線を浴びる時間が最小になるように移動します。
 すぬけ君が移動中に宇宙線を浴びる時間の最小値を求めてください。

=================================================================

解説=============================================================

================================================================
*/
struct edge{
    int u,v;
    double c;
    edge(){}
    edge(int u,int v,double c):u(u),v(v),c(c){}
};

#define MAX_N 1000
ll x[MAX_N+2],y[MAX_N+2],r[MAX_N+2];

inline double c_dist(int i,int j){
    double d = hypot(x[i]-x[j],y[i]-y[j]);
    return max(d-(r[i]+r[j]),0.0);
}
double solve(){
    ll xs,ys,xt,yt; cin >> xs >> ys>> xt >> yt;
    int N; cin >> N;
    x[0] = xs; y[0] = ys; r[0] = 0;
    for(int i = 1; i <= N;i++) cin >> x[i] >> y[i] >> r[i];
    x[N+1] = xt; y[N+1] = yt; r[N+1] = 0;
    
    vector<vector<edge>> G(N+2);
    for(int i = 0; i < N+2;i++){
        for(int j = i+1; j < N+2;j++){
            double d = c_dist(i,j);
            G[i].push_back(edge(i,j,d));
            G[j].push_back(edge(j,i,d));
        }
    }
    
    vector<double> dist(N+2,LINF*2);
    typedef pair<double,int> pdi;
    priority_queue<pdi,vector<pdi>,greater<pdi>> pq;
    dist[0] = 0; pq.push(pdi(0.0,0));
    while(pq.size()){
        pdi p = pq.top(); pq.pop();
        double d; int n; tie(d,n) = p;
        if(d > dist[n]) continue;
        for(edge& e:G[n]){
            if(dist[e.v] > dist[e.u] + e.c){
                dist[e.v] = dist[e.u] + e.c;
                pq.push(pdi(dist[e.v],e.v));
            }
        }
    }
    return dist[N+1];
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(12) << solve() << endl;
	return 0;
}


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

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static long mod = 1000000007;

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var a     = int.Parse(spl[1]);
        var b     = int.Parse(spl[2]);

        var y = Calc2(n);

        y -= CombinationMod2(n, a);
        if (y < 0) y += mod;

        y -= CombinationMod2(n, b);
        if (y < 0) y += mod;

        return y % mod;
    }

    static long Calc2(long n) {
        if (n == 0) return 0;

        long y = 1;//Calc(x);

        if (n > 1) {
            var v = ModPow(2, n - 1);
            y = y * ModPow(2, n - 1) + v-1;
            y %= mod;
        }
        return y;
    }

    static long CombinationMod2(long m, long n) {
        Func<long, long, long> ModPow = (x1, x2) => {
            long ans = 1;
            while (x2 > 0) {
                if (x2 % 2 == 1) {
                    ans = (ans * x1) % mod;
                }
                x1 = (x1 * x1) % mod;
                x2 /= 2;
            }
            return ans % mod;
        };

        var a = 1L;
        var b = 1L;
        for(long i=1; i<=n; i++) {
            a = (a * (m - i + 1)) % mod;
            b = (b * i) % mod;
        }

        long bb = ModPow(b, mod - 2);
        return (a * bb) % mod;
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % mod;
            }
            x1 = (x1 * x1) % mod;
            x2 /= 2;
        }
        return ans % mod;
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        function(S.substring(0,S.length()-1));
    }
    static void function(String S){
        int N = S.length();
        if(N%2==1){
            function(S.substring(0,N-1));
        }
        String s1 = S.substring(0,N/2);
        String s2 = S.substring(N/2,N);
        if(s1.equals(s2)){
            System.out.println(N);
            System.exit(0);
        }
        function(S.substring(0,N-2));
    }
}

Measured memory_bytes: 22996
from collections import deque

def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())


n, m = mapint_inp()
graph = [[] for _ in range(n)]
ans = [0]*n

for _ in range(m):
    a, b = mapint_inp()
    a -= 1; b -= 1
    graph[a].append(b)
    graph[b].append(a) 

q = deque([0])
visited = [False]*n
visited[0] = True
while q:
    now = q.popleft()
    for i in graph[now]:
        if visited[i]: continue
        visited[i] = True
        ans[i] = now
        q.append(i)

print("Yes")
for i in range(1, n):
    print(ans[i]+1)

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll XOR = a[0];
    for(int i = 1; i < n; i++) XOR = XOR^a[i];
    vector<ll> ans(n);
    rep(i,n) ans[i] = XOR^a[i];
    rep(i,n) printf("%d ", ans[i]);
}

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

int main(void){
    int N;
    bool flag=false;
    cin>>N;

    for(int i=0;i<15;i++){
        if(flag)break;
        int tmp=N;
            for(int j=0;j<26;j++){
                if(tmp==7*i+4*j){
                    flag=true;
                    break;
                }
            }

       
    }

    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
v = list(map(int, input().split()))

sorted_v = sorted(v)

upper_sum = sorted_v[0]
for i in range(1, N):
    upper_sum += sorted_v[i] * (2 ** (i - 1))

lower = 2 ** (N - 1)

ans = upper_sum / lower
print(ans)


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

int main() {
  string s;
  int w;
  cin >> s >> w;
  int n = s.size();
  string ans = "";
  for (int i = 0; i < n; ++i) {
    if (i % w == 0) ans += s[i];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s, t;

int main(){
	cin >> s >> n;
	int ans = 0;
	REP(i, n){
		cin >> t;
		string buf = t + t;
		if (buf.find(s) != -1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1212
chars = 'abcdefghijklmnopqrstuvwxyz'
while True:
    try:
        string = input()
    except:
        exit()

    for i in range(1, 27):
        t = string.translate(string.maketrans(chars, chars[i:] + chars[:i]))
        if 'the' in t or 'this' in t or 'that' in t:
            print(t)

Measured memory_bytes: 7444
N = gets.to_i
*A = $<.read.split
C = (0..18).map {[0]*19}
s = 0
A.each {|a|
  a = (a.to_r * 10**9).to_i
  i,j,r = 0,-1,0
  i += 1  while a[i] == 0
  a >>= i
  i = [i,18].min
  (j += 1; a,r = a.divmod 5)  while r == 0
  j = [j,18].min
  s += C[18-i,19].sum {_1[18-j,19].sum}
  C[i][j] += 1
}
p s

Measured memory_bytes: 35164
// Code for C - Tsundoku
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  vector<ll> A(N);
  vector<ll> B(M);

  REP(i, N) {
    cin >> A[i];
  }
  REP(i, M) {
    cin >> B[i];
  }

  vector<ll> a(N + 1);
  vector<ll> b(M + 1);

  REP(i, N) {
    a[i + 1] = a[i] + A[i];
  }

  REP(i, M) {
    b[i + 1] = b[i] + B[i];
  }

  ll max = 0;
  REP(i, N + 1) {
    ll x = a[i];

    if (x > K) {
      break;
    }

    ll left = 0;
    ll right = M + 1;
    while (right - left > 1) {
      ll mid = left + (right - left) / 2;
      if (x + b[mid] <= K) {
        left = mid;
      } else {
        right = mid;
      }
    }


    if (i + left > max) {
      max = i + left;
    }
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 9588
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
i = 0
while i != n:
    if a[i] > x:
        break
    else:
        x -= a[i]
        ans += 1
        i += 1
if x > 0 and i == n:
    ans -= 1
if ans < 0:
    ans = 0
print(ans)


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


int main(){
  ll n,x;
  cin >> x >> n;
  vector<ll> p(107,0);
  rep(i,0,n){
    ll a;
    cin >> a;
    p[a] = 1;
  }
  ll ans=0,sa=100000;
  rep(i,0,102){
    if(p[i])continue;
    if(abs(x-i)<sa){
      sa = abs(x-i);
      ans = i;
    }
  }
  cout << ans << endl;
}



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

using namespace std;
             
int a[100001];

int check (int x, int y) {
	if (x == 0) {
		if (y > 0) return 1;
		if (y < 0) return 2;
		if (y == 0) return 0; 
	}
	if (x == 2) {
		if (y > 0) return -1;
		return 2;
	}
	if (x == 1) {
		if (y < 0) return -1;
		return 1;
	}
	return -1;
}

int main () {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	for (int i = 1;i <= n;i ++) cin >> a[i];
	int ans = 0, last = 0;
	for (int i = 2;i <= n;i ++) {
		int len = a[i] - a[i - 1];
		int j = i;
		int foo = 0;
		if (len > 0) foo = 1;
		if (len < 0) foo = 2;
		while (j <= n && check (foo, a[j] - a[j - 1]) != -1) {
			foo = check (foo, a[j] - a[j - 1]);
			j ++;
		}
		i = j;
		last = i;
		ans ++;
	}
	if (last <= n) ans ++;
	cout << ans;                     
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    char a[200005],b[200005];
    int i,ans=0;
    cin>>a>>b;
    for(i=0;i<strlen(a);i++)
    {
        if(a[i]!=b[i])
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4016
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll a, b;
  cin >> a >> b;
  if (a > b) cout << "a > b" << endl;
  else if (a == b) cout << "a == b" << endl;
  else cout << "a < b" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = ceil(float(n/float(x))) * t;
  cout << ans << endl;
}

Measured memory_bytes: 3580
#!/usr/local/gnu/bin/bash
read n
s=(`sort -n`)
total=$((`echo ${s[@]} | tr ' ' +`))
if((total%10==0))
then
    for x in ${s[@]}
    do
        if(((total-x)%10!=0))
        then
            echo $((total-x))
            exit
        fi
    done
    echo 0
else echo $total
fi


Measured memory_bytes: 792
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#define re register
long long a[100005],sum;
int main()
{
	int n;
	scanf("%d",&n);
	for(re int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	long long all=1LL*n*(n+1)/2;
	if(sum%all!=0)
	{
		printf("NO");
		return 0;
	}
	long long k=sum/all;
	long long cnt=k;
	for(re int i=2;i<=n;++i)
	{
		if(a[i]-a[i-1]==k) continue;
		long long t=k-(a[i]-a[i-1]);
		if(t%n!=0||t<0)
		{
			printf("NO");
			return 0;
		}
		cnt-=t/n;
		if(cnt<0)
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 896
import collections
N = int(input())
A = list(map(int,input().split(" ")))
Q = int(input())
B = [list(map(int,input().split(" "))) for i in range(0,Q)]
ans = sum(A)
num = collections.Counter(A)
for i in range(0,Q):
    before, after = B[i][0], B[i][1]
    ans += num[before] * (after - before)
    num[after] += num[before]
    num[before] = 0
    print(ans)

Measured memory_bytes: 40388
from fractions import gcd                                                                   
                                                                                            
def main():                                                                                 
    N = int(input())                                                                        
    tt = [int(input()) for _ in range(N)]                                                   
    ans = tt[0]                                                                             
    for t in tt[1::]:                                                                       
        ans = ans*t//gcd(ans,t)                                                             
    print(ans)                                                                              
                                                                                            
                                                                                            
if __name__ == '__main__':                                                                  
    main()

Measured memory_bytes: 66028
#include <bits/stdc++.h>
using namespace std;
#define N 100010

int n, m, x, y;
vector<int> G[N];
int dp[N];

int dfs(int u)
{
	int& ans = dp[u];
	if (ans > 0) return ans;
	for (int j = 0; j < G[u].size(); j++)
		ans = max(ans, dfs(G[u][j]) + 1);
	return ans;
}

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
//	int size = 512 << 20; // 256MB  
//    char *p = (char*)malloc(size) + size;  
//    __asm__("movl %0, %%esp\n" :: "r"(p));
	
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &x, &y);
		G[x].push_back(y);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dfs(i));
	
	printf("%d\n", ans);
	

	return 0;
}


Measured memory_bytes: 8192
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n;cin>>n;
     double pi = 3.1415926535897932384;
     cout<<2 * pi * n<<endl;

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 3836
import sys
N,M = [int(n) for n in input().split()]
# N = int(input())
A = [set()]*N
anns = set([ i+1 for i in range(M)])
for i in range(N):
    tmp = [int(n) for n in input().split()]
    A[i] = set(tmp[1:])
    anns = anns & A[i]
print(len(anns))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
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; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int N;
    string S;
    cin>>N>>S;
    REP(i,S.size()){
        S[i]+=N;
        if('Z'-S[i]<0)S[i]-=26;
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
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; }

ll POW(ll a, ll n) {
    ll ret = 1;
    for (; n > 0; n >>= 1, a = a * a) {
        if (n % 2 == 1) ret = ret * a;
    }
    return ret;
}

int main(void) {
    ll n; cin >> n;
    n--;
    string s;
    do {
        s += 'a' + n % 26;
        n /= 26;
        n--;
    } while (n >= 0);
    REP(i, s.size()) cout << s[s.size() - 1 - i];
    cout << endl;
}

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


def read():
    A, B = map(int, input().strip().split())
    S = input().strip()
    return A, B, S


def solve(A, B, S):
    return "Yes" if S.count("-") == 1 and S[A] == "-" else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if(s >= a*b/2)
    {
        double h = 2*(a*b-s)/a;
        rad = atan2(h,a);
    }
    else
    {
        double w = s*2/b;
        rad = atan2(b,w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    cout << fixed << setprecision(10) << deg << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import defaultdict

N = int(input())
A = map(int, input().split())

d = defaultdict(int)
d[0] = 1

s, ans = 0, 0

for a in A:
    s += a
    ans += d[s]
    d[s] += 1

print (ans)

Measured memory_bytes: 45788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			StringBuilder[] threads = new StringBuilder[n];
			for (int i = 0; i < n; i++)
				threads[i] = new StringBuilder(sc.next());
			int[] depths = new int[n];
			for (int i = 0; i < n; i++) {
				int depth = 0;
				for (int j = 0; j < threads[i].length(); j++) {
					if (threads[i].charAt(j) == '.')
						depth++;
				}
				depths[i] = depth;
			}
			for (int i = 1; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (depths[i] == depths[j]) {
						replace(threads, i, j, depths[i], '|');
						break;
					}
					if (depths[i] > depths[j]) {
						replace(threads, i, j - 1, depths[i], ' ');
						break;
					}
				}
			}
			for (int i = 1; i < n; i++) {
				replace(threads, i, i, depths[i], '+');
			}
			for (int i = 1; i < n; i++)
				for (int j = 0; j < threads[i].length(); j++)
					if (threads[i].charAt(j) == '.')
						replace(threads, i, i, j + 1, ' ');
			for (StringBuilder thread : threads)
				System.out.println(thread.toString());
		}
		sc.close();
	}

	private static void replace(StringBuilder[] threads, int x, int y,
			int depth, char dst) {
		for (int i = x; i <= y; i++) {
			threads[i] = threads[i].replace(depth - 1, depth,
					Character.toString(dst));
		}
	}

}

Measured memory_bytes: 108684
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/14/20 20:57:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr unsigned long long MOD = 1e9+7;

unsigned long long mpow(unsigned long long x, unsigned long long p) {
  unsigned long long u = x;
  unsigned long long t = 1;
  while (p) {
    if (p&1)
      (t *= u) %= MOD;
    (u *= u) %= MOD;
    p>>=1;
  }
  return t;
}

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

  int n; cin>>n;
  vector<unsigned long long> A(n); for (auto& a:A) cin>>a;
  vector<array<int, 60>> bits(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (A[i]&(1ull<<j)) {
        bits[i][j]++;
      }
    }
  }
  for (int j = 0; j < 60; j++) {
    for (int i = n-2; i >= 0; i--) {
      bits[i][j] += bits[i+1][j];
    }
  }
  unsigned long long ans = 0;
  for (int j = 0; j < 60; j++) {
    unsigned long long cnt = 0;
    for (int i = 0; i < n-1; i++) {
      if (A[i]&(1ull<<j)) {
        cnt += n-1-i-bits[i+1][j];
      } else {
        cnt += bits[i+1][j];
      }
      cnt %= MOD;
    }
    ans += cnt * mpow(2, j) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


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

public class B
{
  static void Main()
  {
    Console.ReadLine();
 	var numList = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
    var leftSum = numList.Sum();
    var rightSum = 0;
    for (int i = 0; i < numList.Count()-1; i++)
    {
      var a = numList.ElementAt(i);
      rightSum += a;
      leftSum -= a;
      if(rightSum >= leftSum)
      {
        var aa = Math.Abs(rightSum - leftSum);
        var bb = Math.Abs((rightSum - a) - (leftSum + a));
        Console.WriteLine(Math.Min(aa, bb));
        break;
      }
    }
  }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
const int inf = pow(2, 30);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */







signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s = raw_input();

    int ans = inf;

    for(char e : s){
        int cnt = 0;
        string t = s;
        
        while(!(count(all(t), e) == t.size())){

            string tmp = "";
            rep(i,0,t.size() - 1){
                if(t[i] == e or t[i + 1] == e){
                    tmp += e;
                }else{
                    tmp += t[i];
                }
            }
            t = tmp;
            cnt++;

        }

        chmin(ans, cnt);
    

    }

    print(ans);
    




    











    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256