akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private long[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = sc.NextLong();
            }
        }

        public void Solve()
        {
            Scan();
            long x = 0;
            foreach (long i in A)
            {
                x ^= i;
            }

            int cnt = 0;
            for (int i = 29; i >= 0; i--)
            {
                var b = 1 << i;
                foreach (var i1 in A)
                {
                    var u = i1 ^ (i1 - 1);
                    if ((x & ((u + 1) >> 1)) > 0)
                    {
                        if ((b & u) > 0)
                        {
                            x ^= u;
                            cnt++;
                            break;
                        }
                    }
                }
            }

            Console.WriteLine(x == 0 ? cnt : -1);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 15824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_8_c2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] large = { "A","B","C","D","E","F","G",
                "H","I","J","K","L","M","N","O","P","Q","R",
                "S","T","U","V","W","X","Y","Z"};
            string[] small = { "a","b","c","d","e","f","g",
                "h","i","j","k","l","m","n","o","p","q",
                "r","s","t","u","v","w","x","y","z"};

            int[] count = new int[26];
            string Text = "";
            string Line;
            while ((Line = Console.ReadLine()) != null)
            {
                Text += Line;
            }
            for (int i = 0; i < Text.Length; i++)
            {
                string s = Text[i].ToString();
                for (int j = 0; j < 26; j++)
                {
                    if (s == large[j] || s == small[j])
                    {
                            count[j] += 1;
                    }
                }
            }
            for (int i = 0; i < 26; i++)
            {
                Console.WriteLine("{0} : {1}", small[i], count[i]);
            }
        }
    }
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int A, B;
    cin >> A >> B;
    int result = max(A + B, max(A - B, A * B));
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


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

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

union = UnionFind(N)
for hint in hints:
    x = hint[0]
    y = hint[1]
    union.union(x, y)
for i in range(N+1):
    union.find(i)
print(len(set(union.par[1:])))


Measured memory_bytes: 87256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Distance2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> vectorX = new List<int>();
            List<int> vectorY = new List<int>();
            Console.ReadLine();

            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            foreach (string str in strs){
                vectorX.Add(int.Parse(str));
            }

            line = Console.ReadLine();
            strs = line.Split(' ');
            foreach (string str in strs)
            {
                vectorY.Add(int.Parse(str));
            }

            DistanceCalculator problem = new DistanceCalculator(vectorX, vectorY);

            Console.WriteLine(problem.GetDistance(1).ToString("F6"));
            Console.WriteLine(problem.GetDistance(2).ToString("F6"));
            Console.WriteLine(problem.GetDistance(3).ToString("F6"));
            Console.WriteLine(problem.GetChebyshevDistance().ToString("F6"));

        }
    }

    public class DistanceCalculator
    {
        private List<int> vectorX;
        private List<int> vectorY;

        public DistanceCalculator(List<int> vectorX, List<int> vectorY)
        {
            this.vectorX = vectorX;
            this.vectorY = vectorY;
        }

        public double GetDistance(int power)
        {
            double distance = 0;

            for (int i = 0; i < vectorX.Count; i++)
            {
                distance += Math.Pow(Math.Abs(vectorX[i] - vectorY[i]), power);
            }

            return Math.Pow(distance, (1.0 / power));
        }

        /// <summary>
        /// 2ベクトル間のチェビシェフ距離を取得する
        /// </summary>
        /// <returns>チェビシェフ距離</returns>
        public double GetChebyshevDistance()
        {
            double distance = 0;

            for (int i = 0; i < vectorX.Count; i++)
            {
                if (distance < Math.Abs(vectorX[i] - vectorY[i]))
                {
                    distance = Math.Abs(vectorX[i] - vectorY[i]);
                }
            }

            return distance;
        }

    }
}

Measured memory_bytes: 20052
#include<bits/stdc++.h>
using namespace std;
string n;
int k;
int ans;
bool isok(string s1,string s2){
	if(s1.size()>s2.size())
		return true;
	if(s1.size()<s2.size())
		return false;
	for(int i=0;i<s1.size();i++){
		if(s1[i]>s2[i])
			return true;
		if(s1[i]<s2[i])
			return false;
	}
	return true;
}
bool isok2(string s1,string s2)
{
	int cnt=s1.size();
	for(int i=0;i<cnt;i++){
		if(i>=s2.size())
			return true;
		if(s1[i]>s2[i])
			return true;
		if(s1[i]<s2[i])
			return false;
	}
}
void dfs(string cnt,int l){
	if(!isok(n,cnt))
		return;
	if(l==0){
		ans++;
		int a=cnt.size();
		int b=n.size();
		if(b-a-1>=0){
			ans+=(b-a-1);
			if(isok2(n,cnt))
				ans++;
			return ;
		}
		else
			return ;
	}
	else{
		char a;
		for(int i=1;i<=9;i++){
			a=i+'0';
			dfs(cnt+a,l-1);
		}
		dfs(cnt+'0',l);
	}
}
int main()
{
	cin>>n>>k;
	string cnt="";
	for(int i=1;i<=9;i++){
		char a=i+'0';
		dfs(cnt+a,k-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n: usize,
      cn: usize,
      d: [[usize;cn];cn],
      c: [[Usize1;n];n]
   }

   let mut cx = vec![vec![0; cn]; 3];
   for i in 0..n {
      for j in 0..n {
         cx[(i + j) % 3][c[i][j]] += 1;
      }
   }
   let mut ans = std::usize::MAX;
   for c0 in 0..cn {
      for c1 in (0..cn).filter(|&c1| c1 != c0) {
         for c2 in (0..cn).filter(|&c2| c2 != c0 && c2 != c1) {
            let mut x = 0;
            for k in 0..3 {
               for c in 0..cn {
                  x += cx[k][c]
                     * match k {
                        0 => d[c][c0],
                        1 => d[c][c1],
                        _ => d[c][c2],
                     };
               }
            }
            ans = std::cmp::min(ans, x);
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 4876
#include <bits/stdc++.h>
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 COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long X;

int main() {
    while (cin >> X) {
        long long tmp = 100;
        int res = 0;
        while (tmp < X) {
            ++res;
            tmp = tmp + tmp / 100;
        }
        cout << res << endl;
    }
}

















Measured memory_bytes: 3636
/*
** QuickSort
** 使用 quicksort 来排序数组 a，使用 mergesort 来排序数组 b。
** 对两个排序后的数组进行比较，如果不同则证明 quicksort 是不稳定排序。
** 因为 mergesort 本身是稳定排序。
*/

# include <cstdio>
# include <iostream>
# define SENTINEL 2000000000
using namespace std;

const int maxn = 100000 + 10;
int n;

struct Card {
    char s[3];
    int v;
} a[maxn], b[maxn], L[maxn / 2 + 2], R[maxn / 2 + 2];

int partition(Card c[], int p, int r) {
    int x = c[r].v;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (c[j].v <= x) {
            swap(c[++i], c[j]); // c++内置的swap是模板，更加好用
        }
    }
    swap(c[++i], c[r]);
    return i;
}

void quickSort(Card c[], int p, int r) {
    if (p < r) {
        int q = partition(c, p, r);
        quickSort(c, p, q - 1);
        quickSort(c, q + 1, r);
    }
}

void merge(Card c[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i].s[0] = c[left + i].s[0];
        L[i].v = c[left + i].v;
    }
    for (int i = 0; i < n2; i++) {
        R[i].s[0] = c[mid + i].s[0];
        R[i].v = c[mid + i].v;
    }
    L[n1].v = R[n2].v = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].v <= R[j].v) {
            c[k].s[0] = L[i].s[0];
            c[k].v = L[i].v;
            i++;
        }
        else {
            c[k].s[0] = R[j].s[0];
            c[k].v = R[j].v;
            j++;
        }
    }
}

void mergeSort(Card c[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(c, left, mid);
        mergeSort(c, mid, right);
        merge(c, left, mid, right);
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; i++) {
            scanf("%s %d", a[i].s, &a[i].v);
            b[i].s[0] = a[i].s[0];
            b[i].v = a[i].v;
        }
        quickSort(a, 0, n - 1);
        mergeSort(b, 0, n);

        bool isStable = true;
        for (int i = 0; i < n; i++) {
            if (a[i].s[0] != b[i].s[0]) {
                isStable = false;
                break;
            }
        }

        if (isStable)
            printf("Stable\n");
        else
            printf("Not stable\n");

        for (int i = 0; i < n; i++)
        {
            printf("%c %d\n", a[i].s[0], a[i].v);
        }
    }
    return 0;
}


Measured memory_bytes: 5548
a,b,c,d = map(int, input().split())
from fractions import gcd
num_c = b // c - (a - 1) // c
num_d = b // d - (a - 1) // d
num_cd = b // (c * d // gcd(c, d)) - ((a-1) // (c * d // gcd(c, d)))
print((b - a + 1) - (num_c + num_d - num_cd))

Measured memory_bytes: 5104
N = int(input())
A = list(map(int, input().split()))
k = 1
x = y = 0
c = A[0]
for i in A[1:]:
    if c < i:
        x = 1
    elif c > i:
        y = 1
    if x == 1 and y == 1:
        k += 1
        x = y = 0
    c = i
print(k)

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

void dfs(int u, vector<bool>& used, VI& path, VVI& G){
  used[u] = true;
  for(int to: G[u]){
	if(used[to]) continue;
	path.PB(to);
	dfs(to, used, path, G);
	return;
  }
}

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

  int N, M; cin >> N >> M;
  VVI G(N+1);
  REP(i,M){
	int u, v; cin >> u >> v;
	G[u].PB(v);
	G[v].PB(u);
  }
  
  vector<bool> used(N+1, false);

  VI p1, p2;
  used[1] = true;
  dfs(1, used, p1, G);
  dfs(1, used, p2, G);
  reverse(ALL(p2));
  p2.PB(1);

  cout << (SZ(p1) + SZ(p2)) << endl;
  bool sp = false;
  for(auto i: p2){
	cout << (sp?" ":"") << i;
	sp = true;
  }
  for(auto i: p1){
	cout << (sp?" ":"") << i;
	sp = true;
  }
  cout << endl;
  
  return 0;
}


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

int main(){
    
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if ((x+r) > W || (y+r) > H || (x-r) < 0 || (y-r) < 0){
        cout << "No\n";
    } else{
        cout << "Yes\n";
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

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

int gcd(int a,int b);

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>=13)
  {
    printf("%d",b);
  }
  else if(a>=6)
  {
    printf("%d",b/2);
  }
  else printf("0");
  return 0;
  
  
}

int gcd(int a,int b)
{
  int max,min,tmp;
  max = MAX(a,b);
  min = MIN(a,b);
  if(max%min==0) return min;
  else
  {
    tmp = min;
    min = max%min;
    max = tmp;
    return gcd(max,min);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

    vector<string> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<string> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];

    string res = "Yes";
    for(int i = 0; i+m-1 < n; i++){
        for(int j = 0; j+m-1 < n; j++){
            res = "Yes";
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(b[k][l] != a[i+k][j+l]) res = "No";
                }
            }
            if(res == "Yes") break;
        }
        if(res == "Yes") break;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val s = scala.io.StdIn.readLine

  s.substring(0, 2).toInt match {
    case ss if ss >= 1 && ss <= 12 =>
      // まだyy mmありえる
      s.substring(2, 4).toInt match {
        case sss if sss >= 1 && sss <= 12 =>
          println("AMBIGUOUS")
        case sss =>
          println("MMYY")
      }
    case ss =>
      // yy 以外ありえない
      s.substring(2, 4).toInt match {
        case sss if sss >= 1 && sss <= 12 =>
          println("YYMM")
        case sss =>
          println("NA")
      }
  }
}


Measured memory_bytes: 27436
#include<stdio.h>

int main(){
  int i,j,n,a,b,c,temp=0;
  
  scanf("%d %d %d", &a, &b, &c);
  
  for(i=0;i<1;i++){
      temp=a;
      a=b;
      b=temp;
      
      temp=a;
      a=c;
      c=temp;
    
  }
  
  printf("%d %d %d", a, b, c);
  
  return 0;
}


Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] > H[i+1]:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 14396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,k; cin >> n >> k;
    vector<int> p(n),c(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    ll ans = -INF;
    rep(i,n){
        ll now = p[i];
        ll score = c[p[i]];
        int cnt = 1;
        ll nowmax = score;
        while(now != i){
            now = p[now];
            score += c[now];
            nowmax = max(nowmax,score);
            cnt++;
        }
        if(k < cnt*3){
            ll now2 = p[i];
            ll score2 = c[now2];
            ll nowmax2 = score2;
            rep(j,k-1){
                now2 = p[now2];
                score2 += c[now2];
                nowmax2 = max(nowmax2,score2);
            }
            ans = max(ans,nowmax2);
            continue;
        }
        if(score > 0){
            int t = k/cnt;
            int s = k%cnt;
            ll score2 = score*(t-1);
            ll max2 = score2;
            rep(j,cnt+s){
                now = p[now];
                score2 += c[now];
                max2 = max(max2,score2);
            }
            ans = max(ans,max2);
        }
        else{
            ll now2 = p[i];
            ll score2 = c[now2];
            ll nowmax2 = score2;
            rep(j,cnt*2){
                now2 = p[now2];
                score2 += c[now2];
                nowmax2 = max(nowmax2,score2);
            }
            ans = max(ans,nowmax2);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

ll arr[2000050];

ll cal(ll a,int b) {
	if (b==0) return 1;
	if (b%2==1) return a*cal(a*a%MOD,b/2)%MOD;
	else return cal(a*a%MOD,b/2); 
}

ll f(int x,int y) {
	return arr[x+y]*cal(arr[x],MOD-2)%MOD*cal(arr[y],MOD-2)%MOD;
}

ll g(int x,int y) {
	ll sum=0;
	for (int i=1;i<=x+1;i++) (sum+=f(i,y))%=MOD;
	return sum;
}

int main(){  
	int r1, r2, c1, c2;  
	arr[0]=1;
	for (int i=1;i<2000010;i++) arr[i]=(arr[i-1]*(ll)i)%MOD;
	cin>>r1>>c1>>r2>>c2;
	ll ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1);
	ans%=MOD;
	if (ans<0) ans+=MOD;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        while (0 < n) {
            n -= 1000;
        }
        int result = Math.abs(n);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35600
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
P x[100],y[100];
bool z[100];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n)cin>>x[i].S>>x[i].F;
	f(i,n)cin>>y[i].F>>y[i].S;
	sort(x,x+n);
	sort(y,y+n);
	f(j,n){
		for(int i=n-1;i>=0;i--){
			if(x[i].S<y[j].F&&x[i].F<y[j].S&&!z[i]){
				z[i]=true;
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 100000000

using namespace std;

int N, A, B, C;
int l[8];


int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        if (a == 0 || b == 0 || c == 0) {
            return INF;
        } else {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
    }

    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;

    return min({ret0, ret1, ret2, ret3});
}

int main() {
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++) cin >> l[i];

    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
! AtCoder Beginner Contest 086 A
! [URL]      https://atcoder.jp/contests/abc086/tasks/abc086_a
! [compiler] fortran (gfortran v4.8.4)
! 
module ABC086

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public  :: ABC086_A


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC086_A

		! variables for this <subroutine>
		character( len=4, kind=1 ) :: stat
		integer( kind= INT32 )     :: a, b

		! STEP.01
		! read out the target positive integers
		read *, a, b

		! STEP.02
		! judge whether the product of `a` and `b` is even or odd
		if( mod( a*b, 2 ) .eq. 0 ) then
			stat = 'Even'
		else
			stat = 'Odd'
		end if

		! STEP.03
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) stat

		! STEP.END
		return

	end subroutine ABC086_A

end module ABC086


program main

	! <module>s to import
	use, non_intrinsic :: ABC086

	! require all variables to be explicitly declared
	implicit none

	call ABC086_A


end program main


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    int K;
    std::cin >> K;
    std::set<int> D;
    REP(i, K) {
        int d;
        std::cin >> d;
        D.insert(d);
    }

    for(int i = N; i <= 10 * N; i++) {
        bool ok  = true;
        auto num = i;
        while(num) {
            if(D.find(num % 10) != D.end()) {
                ok = false;
                break;
            }
            num /= 10;
        }
        if(ok) {
            std::cout << i << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,ll>;

int main(){
  int n;
  cin >> n;
  vector<vector<P>> v(n,vector<P>(0));
  for(int i=0; i<n-1; ++i){
    int a, b;
    ll c;
    cin >> a >> b >> c;
    --a; --b;
    v[a].push_back(make_pair(b,c));
    v[b].push_back(make_pair(a,c));
  }
  int q, k;
  cin >> q >> k;
  --k;
  vector<ll> d(n,-1);
  queue<P> que;
  que.push(make_pair(k,0));
  while(!que.empty()){
    int x;
    ll dis;
    tie(x,dis) = que.front();
    que.pop();
    d[x] = dis;
    for(auto p:v[x]){
      if(d[p.first] != -1) continue;
      que.push(make_pair(p.first, dis+p.second));
    }
  }
  
  for(int i=0; i<q; ++i){
    int q1, q2;
    cin >> q1 >> q2;
    --q1; --q2;
    printf("%lld\n", d[q1] + d[q2]);
  }
}

Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int get_len(ll x){
	int cnt = 0;
	while(x){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int fun(ll a, ll b){
	return max(get_len(a), get_len(b));
}
int main(void){
	ll n;
	cin >> n;
	int ans = 0x4f4f4f4f;
	for(ll i = 1; i <= sqrt(n); i++){
		if(n % i == 0){
		//	cout << n << " = " << i << " * " << n/i << endl;
			ans = min(ans, fun(i, n/i));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, p;
	cin >> a >> p;
	cout << (int)(p + 3 * a) / 2 << endl;
	return 0;
}

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

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

using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	int max_num = 0;

	for (int i = 1; i <= n; i++) {
		max_num += i;
		if (max_num >= n) {
			break;
		}
	}

	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (n == 2) {
		cout << 2 << endl;
		return 0;
	}

	int X = 0;
	
	X = max_num - n;
	int count = 0;

	for (int i = 1; i < n; i++) {
		if (i != X) {
			cout << i << endl;
			count += i;
		}
		if (count == n) {
			break;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}
void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    read(int , n , m);
    vector<int>v(n);
    for(int& i : v)cin>>i;
    sort(rall(v));
    int T = accumulate(all(v) , 0);
    for(int i = 0 ; i < m; ++i){
        if( 4 * m * v[i] < T){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}




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

int main(){
    int n;
    cin >> n;
    vector<string> W(n);
    copy_n(istream_iterator<string>(cin), n, W.begin());

    for (int i = 0; i < n - 1; i++){
        if (W[i][W[i].size() - 1] != W[i + 1][0]){
            puts("No");
            return 0;
        }
    }

    sort(W.begin(), W.end());
    puts(unique(W.begin(), W.end()) == W.end() ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int A,P; cin >> A >> P;
	P += A*3;
	cout << P/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>//３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラム

int main(void){

	int a,b,c;
	
	scanf("%d%d%d",&a,&b,&c);

	if(a<b&&b<c)
		printf("Yes\n");

	else 
		printf("No\n");

	return 0;
}

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

bool prime[1000003];
bool sieve() {
    memset(prime, true, sizeof(prime));
    for(int i = 2; i * i < 1000003; ++i){
        if(prime[i]){
            for(int j = 2 * i; j < 1000003; j += i){
                prime[j] = false;
            }
        }
    }
}
long long fact(int n) {
    long long ans = 1;
    for(int i = 2; i <= n; ++i) ans *= i;
    return ans;
}
int dig(long long x) {
    int ans = 0;
    long long n = x;
    while(n > 0) {
        ans += 1;
        n/=10;
    }
    return ans;
}
int main() { 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // double time = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    int x;
    cin >> x;
    for(int i = x; i <= 1000002; ++i) {
        if(prime[i]) {
            cout << i << endl;
            break;
        }
    }    
    
        
    // cout << "Execution-Time : " << (clock() - time) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 1280
mod = 10**9+7
M = 1000

fact = [1]*(M+1)
factinv = [1]*(M+1)
inv = [1]*(M+1)
for n in range(2,M+1):
    fact[n] = n*fact[n-1]%mod
    inv[n] = -inv[mod%n]*(mod//n)%mod
    factinv[n] = inv[n]*factinv[n-1]%mod

def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod

N,K = map(int,input().split())
a = list(map(int,input().split()))

dp = [[0]*(N+1) for i in range(K+1)]

for k in range(K):
    dp[k][0] = 1
    for n in range(1,N+1):
        for i in range(min(a[k]+1,n+1)):
            dp[k+1][n] += fact[a[k]]*factinv[a[k]-i]*fact[N-i]*factinv[N]*comb(n,i)*dp[k][n-i]
            dp[k+1][n] %= mod
ans = dp[-1][-1]
for i in range(K):
    ans *= comb(N,a[i])
    ans %= mod

print(ans)


Measured memory_bytes: 71820
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

using namespace std;

int main(void) {
	int n, m;
	cin >> n;
	vector<string>s(n);
	for (int i = 0; i < n; i++)cin >> s[i];
	cin >> m;
	vector<string>t(m);
	for (int i = 0; i < m; i++)cin >> t[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string st = s[i];
		int score = 0;
		for (int j = 0; j < n + m; j++) {
			if (j < n&&st == s[j]) {
				score++;
			}
			if (n <= j && st == t[j - n]) {
				score--;
			}
		}
		ans = max(ans, score);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int w, h;
int c[60][60];

void dfs(int y, int x) {
  if (c[y][x] == 0) {
    return;
  }

  c[y][x] = 0;

  for (int i = -1; i <= 1; i++) {
    for (int j = -1; j <= 1; j++) {
      if (c[y + i][x + j] == 1) {
        dfs(y + i, x + j);
      }
    }
  }
}

signed main() {
  while (cin >> w >> h, (w != 0 || h != 0)) {
    m0(c);
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        cin >> c[i][j];
      }
    }

    int cont = 0;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (c[i][j] == 1) {
          dfs(i, j);
          cont++;
        }
      }
    }

    cout << cont << endl;
  }
  return 0;
}



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

int main() {
  int h, w;
  std::cin >> h >> w;

  std::vector<std::vector<char>> a(h, std::vector<char>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      std::cin >> a[i][j];
    }
  }

  for (int j = 0; j < w + 2; j++) {
    std::cout << "#";
  }
  std::cout << std::endl;
  for (int i = 0; i < h; i++) {
    std::cout << "#";
    for (int j = 0; j < w; j++) {
      std::cout << a[i][j];
    }
    std::cout << "#";
    std::cout << std::endl;
  }
  for (int j = 0; j < w + 2; j++) {
    std::cout << "#";
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
#0-indexed
n = int(input())
L = [[]*n for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        x-=1
        L[i].append((x,y))
#print(L)
ans = 0
for i in range(1<<n):
    bit = [(i>>j)&1 for j in range(n)]
    #print(bit)
    flag = True
    for j in range(n):
        if bit[j]:
            for x,y in L[j]:
                if bit[x] != y:
                    flag = False
                    break
            if not flag:
                break
    if flag:
        ans = max(ans,sum(bit))
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int ran[10001];
int main(){
	while(true){
		int n,a,b,c,x;
		scanf("%d%d%d%d%d",&n,&a,&b,&c,&x);
		if(n==0) break;
		ran[0]=x;
		rep(i,10000) ran[i+1]=(a*ran[i]+b)%c;
		int cnt=0;
		int y[100];
		rep(i,n) scanf("%d",y+i);
		bool ok=false;
		int now=0;
		rep(i,10001){
			if(ran[i]==y[now]) now++;
			if(now==n){
				ok=true;
				printf("%d\n",i);
				break;
			}
		}
		if(!ok) printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1056
L,R=map(int,input().split())
ans = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        wai= i%2019
        waj = j%2019
        if(wai == 0 or waj==0):
            print(0)
            exit()
        ans = min (ans , (wai*waj)%2019)
print(ans)


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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	int n, m;
	while (cin >> n && n > 0) {
		vi v(10, 0);
		rep(i, n) {
			cin >> m;
			v[m]++;
		}
		rep(i, 10) {
			if (v[i] == 0) {
				cout << "-" << endl;
			}
			else {
				rep(j, v[i]) {
					cout << "*";
				}
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 1184
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)
z= 10 **18
if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if s > z:
      s=-1
      break
  print(s)

Measured memory_bytes: 21784
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias t = Tuple!(string, "name", long, "y");

void main()
{
    auto n = lread();
    auto s = sread();
    auto first = new long[](10);
    auto second = new long[](100);
    auto third = new long[](1_000);
    foreach (i; iota(n))
    {
        long idx1 = s[i] - '0';
        if (first[idx1])
            continue;

        foreach (j; iota(i + 1, n))
        {
            long idx2 = idx1 * 10 + s[j] - '0';
            if (second[idx2])
                continue;

            foreach (k; iota(j + 1, n))
            {
                long idx3 = idx2 * 10 + s[k] - '0';
                if (third[idx3])
                    continue;

                third[idx3] = 1;
            }
            second[idx2] = 1;
        }
        first[idx1] = 1;
    }
    third.sum.writeln();
}

auto getdisit(T)(T n)
{
    T i = 0;
    while (abs(n) >= 1)
    {
        n /= 10;
        i++;
    }
    return i;
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n,k; cin>>n>>k;
  vector<int> l(n);
  rep(i,n) cin>>l[i];
  sort(ALL(l),greater<int>());
  int ans=0;
  rep(i,k) ans+=l[i];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int main(void){
	int n=nextpint();
	long ans=0;
	long now=0;
	for(int i=0; i<n; i++){
		int a=nextpint();
		if(a==0){
			ans+=now/2;
			now=0;
		}else{
			now+=a;
		}
	}
	ans+=now/2;
	printf("%ld\n", ans);
}


Measured memory_bytes: 128
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, k, a[N], b[N], ans;
main() {
  file("lala");
  ios;
  cin >> n >> m >> k;
  fo(i, 1, n, 1) cin >> a[i];
  vi v;
  int s = 0;
  fo(i, 1, m, 1) cin >> b[i], s += b[i], v.eb(s);
  s = 0;
  fo(i, 0, n, 1) {
    s += a[i];
    if (s > k) break;
    int left = k - s;
    int id = ub(all(v), left) - v.begin();
//    cerr << "CH " << left << " " << v[id] << " " << v[id - 1] << " " << id << "\n";
    chmax(ans, i);
    if (v[id - 1] <= left) chmax(ans, i + id);
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int aa[10000];
string s;
int a,b=0,c=0;
signed main()
{
	cin>>a;
	rep(i,a){
		cin>>aa[i];
		b=b+aa[i];
		if(c<aa[i]){
			c=aa[i];
		}
	}
	if(c<b-c){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner scanner=new Scanner(System.in);
        char next =scanner.next().charAt(0);
        if(next=='z'){
            System.out.println("z");
        }
        int u=(int)next;
        u=u+1;
        char result=(char)u;
        System.out.println(result);
    }
}



Measured memory_bytes: 20692
#include<iostream>
#include<string>
#include<algorithm>
using ll = long long;
using namespace std;
int main(){
  string A,B; cin >> A >> B;

  if(A.length() > B.length()){
    cout << "GREATER" << endl; 
  } else if(A.length() < B.length()){
    cout << "LESS" << endl;
  } else if(A.at(0) > B.at(0)){
    cout << "GREATER" << endl;
  } else if(A.at(0) < B.at(0)){
    cout << "LESS" << endl;
  } else {
    cout << "EQUAL" << endl;
  }

  return 0;
}

Measured memory_bytes: 256