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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll x,y; cin >> x >> y;
    out((x+y)%24);
}

Measured memory_bytes: 3652
N, Q = list(map(int, input().split()))
S = input()

n = [0]
for i in range(1,len(S)):
    n.append(n[-1])
    if S[i-1:i+1]=='AC': n[-1] += 1

for q in range(Q):
    l, r = list(map(int, input().split()))
    print(n[r-1]-n[l-1])

Measured memory_bytes: 6196
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
double d;
int main(){

  while(1){
    cin>>d;
    if(d==0.0)break;

    for(int i=1;i<=20000000;i++){

      double v = PI*(double)i;

      int A;
      double da;
      
      A=floor(v);
      da= abs( (double)A / (double)i  - PI );
      if( da <= d ){
        cout<<A<<'/'<<i<<endl;
        break;
      }
      
      A=ceil(v);
      da= abs( (double)A / (double)i  - PI );
      if( da <= d ){
        cout<<A<<'/'<<i<<endl;
        break;
      }
      
    }
  }
  return 0;
}

Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {
	int num[10000] = {};
	int sa = 0;
	std::cin >> num[0] >> num[1] >> num[2];
	std::sort(num, num + 3);
	sa = (num[2] - num[1]) + (num[2] - num[0]);
	if (sa % 2 == 0) {
		std::cout << sa / 2 << std::endl;
	}
	else {
		std::cout << (sa + 3) / 2 << std::endl;
	}
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int n;

void dfs(string s,char mx){
    if(s.size() == n){ cout << s << endl; return; }
    for(char c='a';c<=mx;c++) dfs(s+c,(c==mx) ? mx+1 : mx);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    dfs("",'a');
}

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

#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define for0(i, n) for (ll i = 0; i < n; ++i)
#define vll vector<ll>
#define fast std::ios_base::sync_with_stdio(false);
#define ll long long int
#define etc \
  ll t;     \
  cin >> t; \
  while (t--) solve();
#define ntc solve();
#define pb push_back
#define mp make_pair

void solve() {
  ll n;
  cin >> n;

  ll h[n][3];

  for0(i, n) for0(j, 3) cin >> h[i][j];

  ll dp[n][3] = {0};

  for0(i, 3) dp[0][i] = h[0][i];

  for1(i, n - 1) {
    dp[i][0] = h[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = h[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = h[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
  }

  cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}

int main() { fast ntc return 0; }

Measured memory_bytes: 8296
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int x=a[n-1];
  int y=0;
  //  cout<<x<<endl;
  rep(i,n)
    if(abs(x-2*a[i]) < abs(x-2*a[y]))
      y=i;
  cout<<x<<" "<<a[y]<<endl;

}


Measured memory_bytes: 768
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next()

    for (i in 0 until ss.length) {
        val s = ss[i]
        if (i % 2 == 0) {
            // odd
            if (s != 'R' && s != 'U' && s != 'D') {
                println("No")
                return
            }
        } else {
            // even
            if (s != 'L' && s != 'U' && s != 'D') {
                println("No")
                return
            }
        }
    }
    println("Yes")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33744
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
    optimizar_io
 	int a;

 	cin >> a;
 	cout << a + (a * a) + (a * a * a) << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	// your code goes here
	int N,W; cin>>N>>W;
	int weight,value;
	vector<ll> dp(W+1,0);
	for(int i = 0; i<N ; i++){
		cin>>weight>>value;
		if(weight <= W && weight >= 0)
			for(int i = W; i>= weight; i--){
				dp[i] = max(value + dp[i-weight], dp[i]);
			}
	}
	cout<<dp[W];
	return 0;
}


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

int main () {
  vector<vector<int>> A(3, vector<int>(3, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int N;
  cin >> N;
  
  vector<int> b(N,0);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  
  //空いてない:0、空いてる:1
  vector<vector<int>> stat(3, vector<int>(3, 0));
  
  //穴埋め
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b.at(i) == A.at(j).at(k)) {
          stat.at(j).at(k) = 1;
        }
      }
    }
  }
  
  bool win = false;
  
  //行チェック
  for (int i = 0; i < 3; i++) {
    //行
    if (stat.at(i).at(0) && stat.at(i).at(1) && stat.at(i).at(2)) {
      win = true;
    }
    //列
    if (stat.at(0).at(i) && stat.at(1).at(i) && stat.at(2).at(i)) {
      win = true;
    }
  }
  
  //斜め
  if (stat.at(0).at(0) && stat.at(1).at(1) && stat.at(2).at(2)) {
    win = true;
  }
  if (stat.at(0).at(2) && stat.at(1).at(1) && stat.at(2).at(0)) {
    win = true;
  }
  
  if (win) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back

// 非連結を消せば連結

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

  cout << n * (n - 1) / 2 - n / 2 << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (i + j == n + 1 - (n % 2)) continue;
      cout << i << " " << j << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
n = int(input())

a = list(map(int,input().split()))
back=0
back2=1
while back != back2:
  while 0 in a:a.remove(0)
  x=min(a)  
  t=a.index(x)
  for i in range(len(a)):
    a[i] = a[i] % x
  a[t]=x
  back2=back
  back=x

print(x)

Measured memory_bytes: 14224
#include<stdio.h>

#define MAX 100001

typedef struct{
  int parent;
  int right;
  int left;
}Tree;

Tree tree[MAX];
int n,D[MAX];

void count(int,int);

int main(){
  int i,j,d,v,c,left,right;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ )
    {
      tree[i].parent = -1;
      tree[i].right = -1;
      tree[i].left = -1;
    }

  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d",&v,&d);
      for( j = 0 ; j < d ; j++ )
	{
	  scanf("%d",&c);
	  if( j == 0 ) tree[v].left=c;
	  else tree[left].right = c;
	  left = c;
	  tree[c].parent = v;
	}
    }

  for( i = 0 ; i < n ; i++ ){
    if(tree[i].parent == -1) right =i;
  }

  count(right,0);

  for(i = 0 ; i < n ; i++ ){
printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,D[i]);
 if(tree[i].parent == -1 ) printf("root, [");
 else if(tree[i].left == -1 ) printf("leaf, [");
 else printf("internal node, [");  

 for(j = 0,c=tree[i].left;c!=-1;j++,c=tree[c].right){
   if(j) printf(", ");
   printf("%d",c);
 }
 printf("]\n");
  }

  return 0;
}

void count(int u,int p){
  D[u]=p;
  if(tree[u].right!=-1) count(tree[u].right,p);
  if(tree[u].left!=-1) count(tree[u].left,p+1);
}

Measured memory_bytes: 5292
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,to[100010],len[100010],sz[100010]; vector<int> g[100010];

void dfs(int nod, int f){
    sz[nod]=1;

    for (int nxt : g[nod]){
        if (nxt==f) continue;
        dfs(nxt,nod);
        if (to[nxt]!=0) to[nod]=nxt,len[nod]=1+len[nxt];

        if (to[nxt]==0) sz[nod]+=sz[nxt];
    }
}

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

    int i,x,y;
    for (i=1; i<N; i++){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    to[N]=N,len[N]=1;
    dfs(1,0);

    int cr=1,tot=0;
    while (len[1]-len[cr]+1<=(len[1]+1)/2){
        tot+=sz[cr];
        cr=to[cr];
    }

    if (tot<=N-tot) cout << "Snuke\n";
    else cout << "Fennec\n";

    return 0;
}


Measured memory_bytes: 13184
import itertools

N,A,B,C = map(int,input().split())
comb = [] #0:使用しない,1:竹Aの材料,2:竹Bの材料,3:竹Cの材料
L = []
for i in range(N):
  l = int(input())
  L.append(l)
  comb.append([0,1,2,3])

All_comb =  list(itertools.product(*comb))
min_MP = float('inf')
for i in range(len(All_comb)):
  tmp = All_comb[i]
  Non_material = []
  A_material = []
  B_material = []
  C_material = []
  for j in range(len(tmp)):
    if(tmp[j] == 0): Non_material.append(L[j])
    elif(tmp[j] == 1): A_material.append(L[j])
    elif(tmp[j] == 2): B_material.append(L[j])
    elif(tmp[j] == 3): C_material.append(L[j])
    a,b,c = len(A_material),len(B_material),len(C_material)
    if((a>=1)and(b>=1)and(c>=1)):
     sum_A,sum_B,sum_C = sum(A_material),sum(B_material),sum(C_material)
     MP = abs(A-sum_A)+abs(B-sum_B)+abs(C-sum_C) +10*(a+b+c-3)
     min_MP = min(MP,min_MP)

print(min_MP)
    

Measured memory_bytes: 10976
#include <stdio.h>
void print(int A[], int length){
  int i;
  for(i=0; i<length; ++i){
	printf("%d", A[i]);
	if(i<(length-1))
	  printf(" ");
  }
  printf("\n");
}

int main(){
  int length;
  int i, j;
  int key;

  scanf("%d", &length);
  int A[length];

  for(i=0; i<length; ++i){
	scanf("%d", &A[i]);
  }  
  print(A, length);
  for(j=1; j<length; ++j){
	key=A[j];
	i=j-1;
	while((i>=0)&&(A[i]>key)){
	  A[i+1]=A[i];
	  --i;
}
	A[i+1]=key;
	print(A, length);
}
  return 0;
}



Measured memory_bytes: 2040
<?php
    /*
        Problem URL : http://arc072.contest.atcoder.jp/tasks/arc072_a

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    // define('DEBUG', true);
    define('DEBUG', false);

    if (DEBUG) {
        $start = microtime(true);
    }

    fscanf(STDIN, "%d\n", $n);
    $a = explode(" ", trim(fgets(STDIN)));

    // var_dump($a);

    $score_a = 0;
    $score_b = 0;

    $tmp = 0;

    // 最初がマイナスの場合
    for ($i = 0; $i < $n; $i++) {
        $tmp += $a[$i];
        if ($i % 2 == 0) {
            if ($tmp >= 0) {
                $score_a += $tmp + 1;
                $tmp -= ($tmp + 1);
            }
        } else {
            if ($tmp <= 0) {
                $score_a += -($tmp - 1);
                $tmp += -($tmp - 1);
            }
        }
    }


    $tmp = 0;

    // 最初がプラスの場合
    for ($i = 0; $i < $n; $i++) {
        $tmp += $a[$i];
        if ($i % 2 != 0) {
            if ($tmp >= 0) {
                $score_b += $tmp + 1;
                $tmp -= ($tmp + 1);
            }
        } else {
            if ($tmp <= 0) {
                $score_b += -($tmp - 1);
                $tmp += -($tmp - 1);
            }
        }
    }

    // echo $score_a . PHP_EOL;
    // echo $score_b . PHP_EOL;

    echo min($score_a, $score_b) . PHP_EOL;



Measured memory_bytes: 14840
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([[[2, 1]], [[1, 1]], [[2, 0]]]), 2)

    def test_2(self):
        self.assertEqual(think([[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]), 0)

    def test_3(self):
        self.assertEqual(think([[[2, 0]], [[1, 0]]]), 1)

    def test_4(self):
        self.assertEqual(count_bits_one(1), 1)

    def test_5(self):
        self.assertEqual(count_bits_one(2), 1)

    def test_6(self):
        self.assertEqual(count_bits_one(3), 2)

    def test_7(self):
        self.assertEqual(count_bits_one(31), 5)


def solve():
    list_of_testimony = read()
    result = think(list_of_testimony)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_testimony = []
    for _ in range(n):
        list_of_x_y = []
        a = read_int(1)[0]
        for __ in range(a):
            list_of_x_y.append(read_int(2))
        list_of_testimony.append(list_of_x_y)
    return list_of_testimony


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    max_bits = 2 ** len(data)
    result = 0
    for bits in range(max_bits):
        # print(is_legal(bits, data), bits)
        if is_legal(bits, data):
            result = max(result, count_bits_one(bits))
    return result


def is_legal(bits, data):
    n = len(data)
    for i in range(n):
        if not is_honest(i, bits):
            continue
        for x, y in data[i]:
            if y == 1:
                if not is_honest(x - 1, bits):
                    return False
            else:
                if is_honest(x - 1, bits):
                    return False
    return True


def is_honest(i, bits):
    # print('is_honest', i, bits, (bits >> i) % 2 == 1)
    return (bits >> i) % 2 == 1


def count_bits_one(bits):
    count = 0
    while bits > 0:
        if bits % 2 == 1:
            count += 1
        bits //= 2
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5660
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  if(1 <= n && n <= 9)
    cout << n << endl;
  if(10 <= n && n <= 99)
    cout << 9 << endl;
  if(100 <= n && n <= 999)
    cout << n - 99 + 9 << endl;
  if(1000 <= n && n <= 9999)
    cout << 909 << endl;
  if(10000 <= n && n <= 99999)
    cout << n - 9999 + 909 << endl;
  if(n == 100000)
    cout << 90909 << endl;
  
  return 0;
}


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

void main_()
{
    int64_t N;
    cin >> N;

    int64_t ans = 1;
    for (int i = 1; i <= N; ++i) {
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  ll ans,n,t,x,b;
  ans=0;
  cin>>n>>x>>t;
  b=n/x;
  if(n%x){
    b++;
  }
  ans=b*t;
      cout<<ans<<endl;

}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

    public class Main {

        private static Scanner sc;

        public static void main(String[] args) {
            Main instance = new Main();
            sc = instance.new Scanner();
            instance.solve();
        }
        private void solve() {
            try {
                int H = sc.nextInt();
                int W = sc.nextInt();
                for(int i=0; i<H; i++){
                    String text = sc.next();
                    System.out.println(text);
                    System.out.println(text);
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        private class Scanner {
            String[] s;
            int i;
            BufferedReader br;
            String regex = " ";

            public Scanner() {
                s = new String[0];
                i = 0;
                br = new BufferedReader(new InputStreamReader(System.in));
            }

            @Override
            protected void finalize() throws Throwable {
                try {
                    super.finalize();
                } finally {
                    destruction();
                }
            }

            private void destruction() throws IOException {
                if (br != null) br.close();
            }

            public String next() throws IOException {
                if (i < s.length) return s[i++];
                String st = br.readLine();
                while (st == "") st = br.readLine();
                s = st.split(regex, 0);
                i = 0;
                return s[i++];
            }

            public int nextInt() throws NumberFormatException, IOException {
                return Integer.parseInt(next());
            }

            public Long nextLong() throws NumberFormatException, IOException {
                return Long.parseLong(next());
            }

            public Double nextDouble() throws NumberFormatException, IOException {
                return Double.parseDouble(next());
            }
        }
    }


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define MAX 20

int n, d;
int a[MAX][MAX];

int main() {
	cin >> n >> d;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= d; j++) {
			cin >> a[i][j];
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int now = 0;
			for (int k = 1; k <= d; k++) {
				int p = abs(a[i][k] - a[j][k]);
				now += p * p;
			}
			int s = sqrt(now);
			if (s * s == now) ans ++ ;
		}
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define INF INT_MAX/2

int main(){
	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	int colors[9] = { 0 };
	REP(i, N) { 
		cin >> A[i];
		int rate = A[i] / 400;
		rate = rate >= 8 ? 8 : rate;
		colors[rate]++;
	}
	int colmin = 0, colmax = 0;
	bool flag = true;//全員3200以上か？
	FOR(i, 0, 8) {
		if (colors[i] != 0) {
			colmin++;
			flag = false;
		}
	}
	colmax = colmin;
	if (colors[8] > 0) {
		colmin += flag ? 1 : 0;
		colmax += colors[8];
	}
	cout << colmin << " " << colmax << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <cstdint>

using namespace std;

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

  int64_t a[n];
  for(int i = 0;
      i < n;
      ++i)
    {
      cin >> a[i];
    }

  int64_t sum = 0;
  for(int i = 0;
      i < n;
      ++i)
    {
      if(a[i] == 0)
        {
          for(int i = 0;
              i < n;
              ++i)
            {
              sum += abs(a[i]);
            }
          cout << sum << endl;
          return 0;
        }
    }

  sum = 0;

  for(int i = 0;
      i < n - 1;
      ++i)
    {
      if(a[i] < 0)
        {
          a[i] = -a[i];
          a[i + 1] = -a[i + 1];
        }
    }

  if(a[n - 1] < 0)
    {
      int min = 1000000000;
      int min_pos = 0;
      for(int i = 0;
          i < n;
          ++i)
        {
          if(abs(a[i]) < min)
            {
              min = abs(a[i]);
              min_pos = i;
            }
        }
      for(int i = 0;
          i < n;
          ++i)
        {
          if(i != min_pos)
            sum += abs(a[i]);
          else
            sum += -abs(a[i]);
        }
      cout << sum << endl;
    }
  else
    {
      for(int i = 0;
          i < n;
          ++i)
        {
          sum += a[i];
        }
      cout << sum << endl;
    }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int a,b,c,box;
	cin >> a >> b >> c;
	if (a > b){
		box = a;
		a = b;
		b = box;
	}
	if (b > c){
		box = b;
		b = c;
		c = box;
	}
	if (a > b){
		box = a;
		a = b;
		b = box;
	}
	cout << a << " " << b << " " << c << endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n; cin >> n;
    vector<int> a(n), b; b.reserve(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] & 1) b.emplace_back(i);
    }

    if (n == 1) {
		cout << a[0] << '\n';
        if (a[0] == 1) cout << "1\n1";
        else cout << "2\n1 " << a[0] - 1;
        return 0;
    }
    if (b.size() > 2) return cout << "Impossible\n", 0;

    if (b.size() > 0) swap(a[0], a[b[0]]);
    if (b.size() > 1) swap(a[n-1], a[b[1]]);

    for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << '\n';
    cout << n - (a[0] == 1) << '\n';
    if (a[0] > 1) cout << a[0] - 1 << ' ';
    for (int i = 1; i < n-1; ++i) cout << a[i] << ' ';
    cout << a[n-1] + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		double[] x = new double[n];
		double[] y = new double[n];
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
		}
		for(int i=0; i<n; i++){
			y[i] = sc.nextInt();
		}
		
		double p1 = 0;
		double p2 = 0;
		double p3 = 0;
		double pi = 0;
		for(int i=0; i<n; i++){
			double d = Math.abs(x[i] - y[i]);
			p1 += d;
			p2 += Math.pow(d, 2);
			p3 += Math.pow(d, 3);
			if(d > pi){
				pi = d;
			}
		}
		
		p2 = Math.sqrt(p2);
		p3 = Math.cbrt(p3);
		
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(pi);
		
	}

}

Measured memory_bytes: 26588
suspection = [1,3,5,7,9,11,15,17,19,21,23,25]
word = ["that", "this"]
def code(word, a, b = 0)
  return word.split(//).map{|char|
    (((char.ord - "a".ord) * a + b) % 26 + "a".ord).chr}.join
end
26.times do |i|
  word << code(word[0], 1, i) << code(word[1], 1, i)
end
gets.to_i.times do
  state = gets
  i = 0
  while (word & (state.split(/\W+/).map{|tango| code(tango, suspection[i])})).size == 0
    i += 1
  end
  b = 0
  while (word[0..1] & (state.split(/\W+/).map{|tango| code(tango, suspection[i], b)})).size == 0
    b += 1
  end
  puts state.split(/\W+/).map{|tango| code(tango, suspection[i], b)}.join(" ")
end

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const int N = 1005, INF = 0x3f3f3f3f;
char c[N][N];
pii ex[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int h, w; cin >> h >> w;
    int ch, cw; cin >> ch >> cw;
    int dh, dw; cin >> dh >> dw;
    vvi d(h + 1, vi(w + 1, INF));
    FOR(i, 1, h) FOR(j, 1, w) {
        cin >> c[i][j];
    }
    deque <pii> dq;
    dq.push_back({ch, cw});
    d[ch][cw] = 0;
    while (!dq.empty()) {
        pii u = dq.front(); dq.pop_front();
        int x = u.fi, y = u.se, t = d[x][y];
        if (t != d[x][y]) continue;
        FOR(i, -2, 2) FOR(j, -2, 2) {
            int tx = x + i, ty = y + j;
            if (tx < 1 || tx > h || ty < 1 || ty > w || c[tx][ty] == '#') continue;
            if (abs(i) + abs(j) == 1 && t < d[tx][ty]) {
                d[tx][ty] = t;
                dq.push_front({tx, ty});
            }
            if (t + 1 < d[tx][ty]) {
                d[tx][ty] = t + 1;
                dq.push_back({tx, ty});
            }
        }
    }
    if (d[dh][dw] == INF) cout << -1 << endl;
    else cout << d[dh][dw] << endl;
}

Measured memory_bytes: 8616
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
	int n;
	while(cin >> n) {
		vector<int> a(n, 1);
		a[0] = 0;

		for(int i=1; i<(int)sqrt(n); i++) {
			if(a[i] == 1) {
				for(int j=i+1; (i+1)*j<=n; j++) { // 素数の倍数のフラグを消していく
					a[(i+1)*j-1] = 0;
				}
			}
		}

		int ans = 0;
		for(int i = 0; i<n; i++) {
			if(a[i] == 1) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 7084
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
using namespace std;
int x[100];
signed main() {
	int n,ans=10000000000000;
	cin >> n;
	f(i, n)cin >> x[i];
	f(i, 100) {
		int z = 0;
		i++;
		f(j, n) {
			z += (x[j] - i)*(x[j] - i);
		}
		i--;
		ans = min(ans, z);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N, A, B, C = gets.split.map(&:to_i)
Ls = readlines.map(&:to_i)

def go(i, a, b, c)
  return [a, b, c].min > 0 ? (A - a).abs + (B - b).abs + (C - c).abs - 30 : 1E9 if i == N
  i, l = i + 1, Ls[i]
  [go(i, a + l, b, c) + 10, go(i, a, b + l, c) + 10, go(i, a, b, c + l) + 10, go(i, a, b, c)].min
end

puts go(0, 0, 0, 0)

Measured memory_bytes: 1788
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and i%2and j%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
for i in range(50):
    for j in range(100):
        if b-1and i%2and j%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()

Measured memory_bytes: 4468
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9
now = 0
for i in range(n-k+1):
    ltor = abs(now - x[i]) + abs(x[i+k-1] - x[i])
    rtol = abs(now - x[i+k-1]) + abs(x[i+k-1] - x[i])
    tmp = min(ltor, rtol)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 14536
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,M,Q;
	int sum[510][510]={};

	cin >> N >> M >> Q;
	for(int i=0;i<M;i++)
	{
		int L,R;
		cin >> L >> R;
		sum[L][R]++;
	}

	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			sum[i][j]+=sum[i][j-1];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			sum[i][j]+=sum[i-1][j];
	

	for(int i=0;i<Q;i++)
	{
		int p,q;
		cin >> p >> q;
		cout << sum[q][q]-sum[p-1][q]-sum[q][p-1]+sum[p-1][p-1] << endl;
	}

	return 0;
}


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if(a[0] == 5 && a[1] == a[0] && a[2] == 7)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 3516
program prob7
    implicit none
    integer, allocatable :: count(:, :)
    integer :: ans(26)
    character(len=50) :: tmp
    integer :: n, i, j, inttmp

    read(*,*) n
    allocate(count(n, 26))

    do i = 1, n
        do j = 1, 26
            count(i, j) = 0
        end do
    end do

    do i = 1, n
        read(*,*) tmp
        do j = 1, len_trim(tmp)
            inttmp = ichar(tmp(j:j)) - ichar('a') + 1
            count(i, inttmp) = count(i, inttmp) + 1
        end do
    end do

    do j = 1, 26
        inttmp = 51
        do i = 1, n
            inttmp = tmin(inttmp, count(i, j))
        end do
        ans(j) = inttmp
    end do

    do j = 1, 26
        do i = 1, ans(j)
            write(*,'(a)',advance='no') char(ichar('a') + j - 1)
        end do
    end do
    write(*,*) 

    stop
contains
integer function tmin(a,b)
    implicit none
    integer :: a,b
    if(a > b) then
        tmin = b
    else
        tmin = a
    end if    
    return
end function tmin
end program prob7

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int maxn = 1e5;
#define m(a,b) memset(a,b,sizeof(a));
int main(){
	int n;
	char a[maxn+5][15];
	cin >> n;
	for(int i = 0;i<n;i++)
		cin >> a[i];
	map<char,int>mp;
	for(int i = 0;i<n;i++)
		mp[a[i][0]]++;
	LL pos1 , pos2 , pos3 , pos4 , pos5 ;
	pos1 = mp['M'];
	pos2 = mp['A'];
	pos3 = mp['R'];
	pos4 = mp['C'];
	pos5 = mp['H'];
	LL ans = pos1*pos2*pos3 + pos2*pos3*pos4 + pos1*pos2*pos5 + pos1*pos3*pos4 + pos1*pos2*pos4 + pos2*pos3*pos5 + pos3*pos4*pos5 + pos1*pos3*pos5 + pos1*pos4*pos5 + pos2*pos4*pos5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
from itertools import product

s = input()
n = len(s)
ans = 0
for pluses in product((True, False), repeat=n - 1):
    current_continuous_num = s[0]
    current_sum = 0
    for idx, is_plus in enumerate(pluses):
        if is_plus:
            current_sum += int(current_continuous_num)
            current_continuous_num = s[idx + 1]
        else:
            current_continuous_num += s[idx + 1]
    ans += current_sum + int(current_continuous_num)
print(ans)


Measured memory_bytes: 9184
N = int(input())
h = list(map(int, input().split()))

def knapsack_simple(N, h):
  dp = [float('inf')]*(N)
  dp[0] = 0

  for i in range(0, N-1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]))  # dp[i+1]をそのままにするかどうか
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]))  # dp[i+2]をそのままにするかどうか
  return dp[N-1]

print(knapsack_simple(N, h))

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long X) {
    for (long long a = 0; a < 4000; a++) {
        for (long long b = -4000; b < 4000; b++) {
            if (a * a * a * a * a - b * b * b * b * b == X) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    double ans = (n+1)/2;
    printf("%.10lf\n", ans/n);
    return 0;
}

Measured memory_bytes: 3720
N,A,B = map(int, input().split())

"""
MIN: (N - 1) * A + B
MAX: A + (N - 1) * B

MAX - MIN + 1
= (N - 1) * (B - A) - (B - A) + 1
= (N - 2) * (B - A) + 1
"""

if N == 1 and A != B:
    print(0)
elif A > B:
    print(0)
else:
    print((B - A) * (N - 2) + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int a,b,i,j,k,l,n,m;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> a >> b;
  
  if((a+b)%2 == 1){
    cout << "IMPOSSIBLE" <<endl;
    return 0;
  }

  cout << (a+b)/2 << endl;

  return 0;

}

Measured memory_bytes: 256
// Snuke Festival
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    vector<int> b(n);
    rep(i, n){
        cin >> b[i];
    }    
    vector<int> c(n);
    rep(i, n){
        cin >> c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    
    ll ans = 0;
    rep(i, n){
        auto iter1 = lower_bound(all(a), b[i]);
        auto iter2 = upper_bound(all(c), b[i]);
        ans += (ll) ((iter1 - a.begin()) * (c.end() - iter2));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
c = input().split(' ')
n = int(c[0])
count = 0

for i in range(n):
    val = input().split(' ')
    x = int(val[0])
    y = int(val[1])
    d = pow(x, 2) + pow(y, 2)
    D = pow(d, 0.5)
    if D <= int(c[1]):
        count += 1

print(count)

Measured memory_bytes: 9648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> MY(N);
  for (int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  vector<int> gard(N);
  for (int i=0;i<N;i++){
    cin >> gard.at(i);
  }
  vector<int> value(N);
  for (int i=0;i<N;i++){
    value.at(i)=MY.at(i)-gard.at(i);
  }
  sort(value.begin(), value.end());
  int total=0;
  for (int i=N-1;i>=0;i--){
    if(value.at(i)<=0){break;}
    total+=value.at(i);
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int X = (A); X <= (Y);++X)
#define _rep2(X, Y) for (int X = 0; X < (Y); ++X)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
using namespace std;
typedef long long ll;

const int MAX_N = 50, MAX_A = 50;
int N, A;
int x[MAX_N + 1];
ll dp[MAX_N + 1][MAX_N + 1][MAX_N * MAX_A + 1];

int main() {
    cin >> N >> A;
    rep(i, 1, N) cin >> x[i];

    rep(i, N) dp[i][0][0] = 1;

    rep(i, 1, N) {
        rep(j, 1, i) {
            rep(k, 1, N * A) {
                if (k < x[i]) {
                    dp[i][j][k] = dp[i - 1][j][k];
                } else {
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                }
            }
        }
    }

    ll ans = 0;
    rep(j, 1, N) {
        ans += dp[N][j][j * A];
    }

    cout << ans << endl;

    return 0;
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
   string s;
   cin>>s;
   /* map<char,int>mp;
   for(int i=0;i<s.size();i++){
        mp[s[i]]++;
   }
   for(auto c:mp)
       if(c.second>=3){
           cout<<"Yes";
           return ;
       }
   cout<<"No";
   */
   if(s[0]==s[1]&&s[1]==s[2])
           cout<<"Yes";
   else if(s[1]==s[2]&&s[2]==s[3])
           cout<<"Yes";
    else 
          cout<<"No";
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 1024
int preorder[40],inorder[40];
void recover(int fp,int lp,int fi,int li){
    int root=fi;
    for(;root<li;root++)if(preorder[fp]==inorder[root])break;
    if(fi<root)recover(fp+1,fp+(root-fi)+1,fi,root);
    if(root<li-1)recover(fp+(root-fi)+1,lp,root+1,li);
    printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
}
main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",preorder+i);
    for(i=0;i<n;i++)scanf("%d",inorder+i);
    recover(0,n,0,n);
    return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int ans=1;
	int n; cin>>n;
	map<int,int> mp;
	rep(i,0,n){
		int a; cin>>a;
		mp[a]++;
		if(mp[a]==3){
			cout<<0;
			return 0;
		}
	}
	if(mp[0]>1){
		cout<<0;
		return 0;
	}
	rep(i,0,n/2){
		ans*=2;
		ans=ans%MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
s = list(input())
l = []
r = []

for i in range(int((len(s)-1)/2)):
    l.append(s[i])

for i in range(int((len(s)+1)/2),len(s)):
    r.append(s[i])

lr = l.copy()
lr.reverse()

rr = r.copy()
rr.reverse()

sr = s.copy()
sr.reverse()

if l == lr and r == rr and s == sr:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
N=int(input())
l=input()
W=0
R=l.count("R")
ans=W+R
for i in range(N):
    W+=1 if l[i]=="W" else 0
    R-=1 if l[i]=="R" else 0
    ans=min(ans,min(W,R)+max(W,R)-min(W,R))
print(ans)

Measured memory_bytes: 9336
#include<stdio.h>
int main()
{
    int n;scanf("%d",&n);
    int a[n+10],i,j,count=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<n-1;i++)
    {
       if(a[i]>a[i-1])
       {
           if(a[i]<a[i+1])count++;
       }
       else if(a[i]<a[i-1])
       {
           if(a[i]>a[i+1])count++;
       }
    }
    printf("%d",count);
}


Measured memory_bytes: 1732
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
m = 7 % K
cnt = 1
d = 10 % K
while True:
    if m == 0:
        break
    cnt += 1
    m = (m+7*d)%K
    d = d*10%K
print(cnt)

Measured memory_bytes: 63296
// abc146_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  cin>>s;
  if(s=="SUN")cout<<7;
  if(s=="MON")cout<<6;
  if(s=="TUE")cout<<5;
  if(s=="WED")cout<<4;
  if(s=="THU")cout<<3;
  if(s=="FRI")cout<<2;
  if(s=="SAT")cout<<1;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
es=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    es[a].append(b)
    es[b].append(a)
ans=0
for i in range(n):
    f=1
    for v in es[i]:
        if h[i]<=h[v]:
            f=0
            break
    if f:
        ans+=1
print(ans)

Measured memory_bytes: 92824
n, x = map(int, input().split())
a = [int(x) for x in input().split()]

res = 0
for i in range(n-1):
    eat = max(a[i] + a[i+1] - x, 0)
    res += eat
    if eat > a[i+1]:
        a[i+1] = 0
        a[i] = eat - a[i+1]
    else:
        a[i+1] -= eat

print(res)

Measured memory_bytes: 14052
import sys
n = int(input())


wl = []
end = ""
for _ in range(n):
    w = input()
    wl.append(w)
    if end == "" or w[0] == end:
        end = w[-1]
    else:
        print("No")
        sys.exit()
    
if len(wl) != len(set(wl)):
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
    int x,y,z,temp;
    scanf("%d%d%d",&x,&y,&z);
    if(x>=y&&x>=z)temp=x;
    else if(y>=x&&y>=z)temp=y;
    else if(z>=x&&z>=y)temp=z;
    printf("%d\n",x+y+z-temp);
    return 0;
}


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

int main(){
	int n, cr, cl;
	cin >> n;
    
	cr = n/10 % 10;
	cl = n/100 % 10;
	if(cr == cl && (cr == n % 10 || cl == n / 1000)) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
    if(b==1){
      cout<<0<<endl;
      return 0;
    }
	int i = 0;
	int ans = 0;
	while (a + (a - 1)*i < b) {
		i++;
		if (a + (a - 1)*i >= b) {
			ans = i;
			break;
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
おしりから、Xがとった場合のYの最小値とるか。
前提のYが変わりうるか
Xで終わるパターンとYで終わるパターンのDPとか

おしりとる
おしり-1とる
おしり-2とる
どこかで一定の値になる？

100 100
10 50 100 150 200

n   A200=100
n-1 A150 B200=50
n-2 A100 B150 A200=50
n-3 A50 B150 A200=50
n-4 A10 B150 A200=50

100 100
10 50 10000 1500 200
n A200=100
n-1 A1500 B200 =1300
n-2 A10000 B1500 A200=1300
n-3 A50 B200=150
n-4 A10 B200=190

どうせ最後の値をとる？
*/
int main(){
  ll N,Z,W; cin>>N>>Z>>W;
  vector<ll> A(N,0);
  for(ll i=0; i<N; i++)cin>>A[i];
  ll a=abs(A[N-1]-W);
  if(N==1){
    cout<<a<<endl;
    return 0;
  }
  ll b=abs(A[N-2]-A[N-1]);
  cout<<max(a,b)<<endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line
int N, M;
int a[1100], b[1100], c[1100];
int dist[110][110];
const int INF = 1e9;
int main()
{
	cin >> N >> M;
	rep(i,N){
		rep(j,N) dist[i][j] = INF;
		dist[i][i] = 0;
	}

	rep(i,M){
		cin >> a[i] >> b[i] >> c[i];
		--a[i], --b[i];
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}
	
	rep(k,N){
		rep(i,N){
			rep(j,N){
				chmin(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < M; i++){
		if(c[i] > dist[a[i]][b[i]]) ++res;
	}
	cout << res << endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int w;
    cin >> s >> w;
    string ans;
    for (int i = 0; i < s.length(); i += w) {
        ans += s[i];
    }
    cout << ans << endl;;

}


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

int main(){
    int mon,man;
    while(1){
        cin >> mon;
        if(mon == 0){
            break;
        }
        mon = 1000 - mon;
        man = 0;
        if(mon >= 500){
            man += mon / 500;
            mon = mon % 500;
        }
        if(mon >= 100){
            man += mon / 100;
            mon = mon % 100;
        }
        if(mon >= 50){
            man += mon / 50;
            mon = mon % 50;
        }
        if(mon >= 10){
            man += mon / 10;
            mon = mon % 10;
        }
        if(mon >= 5){
            man += mon / 5;
            mon = mon % 5;
        }
        man += mon;
        cout << man << endl;
    }
}

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

int main()
{
  int N, A, B;
  int sum, num;
  int some_sums = 0;

  cin >> N >> A >> B;
  for (int i = 1; i <=N; i++)
  {
    sum = 0;
    num = i;
    for (int k = 0; k < 5; k++)
    {
      sum += num % 10;
      num /= 10;
    }
    if (A <= sum && sum <= B)
      some_sums += i;
  }
  cout << some_sums << endl;
}

Measured memory_bytes: 256