akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var S = sc.Next();
        int N = S.Length;
        long K = sc.NextInt();

        long ans = 0;

        var l = new List<long>();
        char c = '\0';
        for (int i = 0; i < N; i++)
        {
            if (S[i] != c)
            {
                l.Add(0);
                c = S[i];
            }

            l[l.Count - 1]++;
        }

        if (l.Count == 1)
        {
            Console.WriteLine((long) (K * N) / 2);
            return;
        }

        if (S[0] == S[N - 1])
        {
            ans += l[0] / 2;
            ans += l[l.Count - 1] / 2;
            ans += (long) (K - 1) * ((l[0] + l[l.Count - 1]) / 2);
            for (int i = 1; i < l.Count - 1; i++)
            {
                ans += (long) K * (l[i] / 2);
            }
        }
        else
        {
            foreach (long i in l)
            {
                ans += (long) K * (i / 2);
            }
        }

        Console.WriteLine(ans);
    }

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

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

namespace _97C
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());
            List<string> list = new List<string>();
            HashSet<string> hash = new HashSet<string>();

            for (int j = 1; j <= k; j++)
            {
                for (int i = 0; i < str.Length-j+1; i++)
                  {
              
                    hash.Add(str.Substring(i, j));
               
                   }
            }
            list = hash.ToList();
            list.Sort();
           
                Console.WriteLine(list[k-1]);

            
        }
    }
}


Measured memory_bytes: 14688
/*ALDS1_1D: Maximum Profit*/

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

#define N 200000

int main(void){
	int R[N] = {0}, i = 0, n, minv, maxv;

	scanf("%d", &n);

	while(i < n){
		scanf("%d", &R[i++]);
	}

	minv = R[0];
	maxv = R[1] - R[0];
	for(i = 1; i < n - 1; i++){
		if(R[i] < minv){
			minv = R[i];
		}
		if(maxv < R[i+1] - minv) {
			maxv = R[i+1] - minv;
		}
	}

	printf("%d\n", maxv);

	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N,K;
int A[MC] , B[MC];

LL solve(int z){
	LL ans = 0;
	int x = z;
	while(x != (x&-x)) x -= (x&-x);
	if(x == 0) ++x;
	repp(i,0,N){
		if(A[i] < x) ans += B[i];
		if(A[i] >= x) A[i] -= x;
	}
	return max(ans , z?solve(z-x):(LL)0);
}

int main(){
	cin >> N >> K;
	repp(i,0,N){
		cin >> A[i] >> B[i];
	}
	cout << solve(K) << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int n, x;
long long z, s;
map<long long, int> g;
int main() {
	cin >> n;
	g[s] = 1;
	for (int i = 0; i < n; i++) {
		cin >> x;
		z += g[s += x]++;
	}
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 12800
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define F first
#define S second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef vector<int> vi;
typedef pair<int, int> pii; 
typedef pair<int , pii> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n ;
    cin >> n ;
    cout << (n + 1)/2;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int check[30]={};
  int i,x;
  for(i=0;i<28;i++){
    cin >> x;
    check[x-1]++;
  }
  for(i=0;i<30;i++){
    if(check[i]==0) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int N, H, W;
    std::cin >> N >> H >> W;

    std::cout << (N-W + 1) * (N-H + 1) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2e5+5;
const double pi = acos(-1.0);
void init(){
	ios::sync_with_stdio(false);
	cin.tie(0);
}
int a[N];
int main()
{
	init();
	int n,x;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 4424
#define SUBMIT

#include <bits/stdc++.h>
using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(35897 932
)");
#endif
    ui64 ans = 0;
    long N, K;
    stream >> N >> K;

    for (int a = 1; a <= N; ++a) {
        i64 r = a / K;
        i64 b = (r + 1) * K - a;
        if (abs(a - b) % K != 0) continue;

        i64 c = min<i64>({a, b, K});
        i64 u = 1 + (N - b) / K;
        i64 v = 1 + (N - c) / K;
        ans += u * v;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readIntArray();
            var a = myRead.readLongArray();
            for (int i = s[1]; i < s[0]; i++)
            {
                var ans = "No";
                if (a[i - s[1]] < a[i])
                    ans = "Yes";
                WriteLine(ans);
                Out.Flush();
            }

        }



    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 46984
li = list(input())
str = []
for i in range(len(li)):
	if li[i] == '0':
		str.append('0')
	elif li[i] == '1':
		str.append('1')
	else:
		if len(str) != 0:
			str.pop()
		else:
			continue
print(''.join(str))

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    long long x;
    long long s, e, m;
    
    scanf("%lld", &x);
    s = 1;
    e = 1e5;
    //printf("[%d]\n", e);
    while(s < e) {
        m = (s + e) / 2;
        if(m * (m + 1) / 2 < x) s = m + 1;
        else e = m;
    }
    printf("%lld", s);
    return 0;
}

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


public class Hello
{
    public static void Main()
    {
        List<string> descending = new List<string>();
        string str;
        while (!((str = Console.ReadLine()) == null))
        {
            List<int> input = str.Split(' ').Select(int.Parse).ToList();
            List<int> order = input.OrderBy(x => -x).ToList();
            descending.Add(string.Join(" ",order));
        }

        foreach (string item in descending)
            Console.WriteLine(item);
    }

}



Measured memory_bytes: 18380
import bisect

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
print(ans)

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

int main(){
	int n;
  	cin >> n;
  	vector<vector<int>> a(n, vector<int>(n-1));
  	rep(i, n){
    	rep(j, n-1){
          	cin >> a[i][j];
      		a[i][j]--;
        }
      	reverse(a[i].begin(), a[i].end());
    }
  	vector<P> q;
  
  	auto check = [&](int i){
      	if(a[i].size() == 0) return;
      	int j = a[i].back();
      	if(a[j].size() == 0) return;
      	if(a[j].back() == i){
          	P p(i, j);
          	if(p.second < p.first) swap(p.first, p.second);
        	q.push_back(p);
        }
    };

  	rep(i, n){
      	check(i);
    }
  
  	int day = 0;
  	while(q.size() > 0){
  		day++;
      	sort(q.begin(), q.end());
      	q.erase(unique(q.begin(), q.end()), q.end());
      	vector<P> prevQ;
      	swap(prevQ, q);
      	for(P p : prevQ){
        	int i = p.first, j = p.second;
          	a[i].pop_back();
          	a[j].pop_back(); 	
        }
        for(P p : prevQ){
        	int i = p.first, j = p.second;
          	check(i);
          	check(j);
        }
    }
  	
  	rep(i, n){
    	if(a[i].size() != 0){
        	puts("-1");
          	return 0;
        }
    }
  
  	cout << day << endl;
}

Measured memory_bytes: 7556
h,w,k = map(int, input().split())

field = [input() for _ in range(h)]

ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        tmp = 0
        for i1 in range(h):
            for j1 in range(w):
                if (i >> i1) & 1: continue
                if (j >> j1) & 1: continue
                if field[i1][j1] != '#': continue
                tmp += 1
        if tmp == k:
            ans += 1

print(ans)

Measured memory_bytes: 73756
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        if(a>b)
            a=b;
        if(c>d)
            c=d;
        printf("%d\n",a+c);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>

#define PI (acos(-1.0))
#define RAD(v) ((v)*(PI/180.0))
#define RADIUS 16
#define EPS 1.0e-10

using namespace std;

int main(){
	while(true){
		int m1,m2;
		int sumv1=0, sumv2=0;
		double area1 = 0, area2 = 0;

		scanf("%d", &m1);
		if( m1 == 0 )
			break;
		for(int i = 0; i < m1 - 1; ++i){
			int v;
			scanf("%d", &v);
			sumv1+=v;
			area1 += 0.5 * RADIUS * RADIUS * sin( RAD(v) );
		}
		area1 += 0.5 * RADIUS * RADIUS * sin( RAD(360-sumv1) );
		
		scanf("%d", &m2);
		for(int i = 0; i < m2 - 1; ++i){
			int v;
			scanf("%d", &v);
			sumv2+=v;
			area2 += 0.5 * RADIUS * RADIUS * sin( RAD(v) );
		}
		area2 += 0.5 * RADIUS * RADIUS * sin( RAD(360-sumv2) );
		
		if( std::abs( area1 - area2 ) < EPS )
			cout << "0\n";
		else if( area1 > area2 )
			cout << "1\n";
		else
			cout << "2\n";
	}
	return 0;
}

Measured memory_bytes: 0
N,M,L = map(int, input().split())
INF = 10**18
# 初期化
d = [[INF]*N for i in range(N)]
for i in range(N):
    d[i][i] = 0
for i in range(M):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    # 多重辺の場合はMIN
    d[a][b] = c
    d[b][a] = c
# 最適化(わーしゃゆふよいど)
for k in range(N):
    for i in range(N):
        # 左右は対称だろう
        for j in range(i+1,N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            d[j][i] = d[i][j]

# 初期化2
d2 = [[INF]*N for i in range(N)]
for i in range(N):
    d2[i][i] = 0
for i in range(N):
    for j in range(N):
        # 給油できるところに辺を張る
        if d[i][j] <= L:
            d2[i][j] = 1
for k in range(N):
    for i in range(N):
        for j in range(i+1,N):
            d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j])
            d2[j][i] = d2[i][j]
            

#query
Q = int(input())
for i in range(Q):
    l  = list(map(int, input().split()))
    s = min(l)-1
    t = max(l)-1
    
    ans = d2[s][t]
    if ans == INF:
        ans = 0
    print(ans-1)

Measured memory_bytes: 61656
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n;
	cin >> n;

	int res;
	for ( ULL i = 1; pow( 3, i ) < n; i++ )
	{
		res = i;
	}
	cout << res + 1 << endl;

	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define INF 1e9
#define EXIST 1
int graph[200][200];
int dist[200];
int n;

void bfs() {
  queue<int> next;
  next.push(0);
  dist[0] = 0;
  
  while (!next.empty()) {
    int current = next.front();
    next.pop();
    for (int i = 0; i < n; i++) {
      if (graph[current][i] == EXIST && dist[i] > dist[current]+1) {
        next.push(i);
        dist[i] = dist[current]+1;
      }
    }
  }  
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    dist[i] = INF;
    int u, k, v; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      graph[u-1][v-1] = EXIST;
    }
  }
  
  bfs();
  
  for (int i = 0; i < n; i++) {
    cout << i+1 << " ";
    cout << (dist[i] == INF ? -1 : dist[i]) << endl;
  }
}



Measured memory_bytes: 3144
n = [int(i) for i in input().split()]
s = input()
a = set([""])
ans = set()
for i in s:
    b = a.copy()
    for j in a:
        if len(j) == 2:
            ans.add(j + i)
        else:
            b.add(j + i)
    a = b
print(len(ans))


Measured memory_bytes: 3316
N,M = map(int, input().split())
shop = []
for i in range(N):
    a,b = map(int, input().split())
    shop.append([a,b])

shop.sort()
ans = 0
for i in range(N):
    if M <= 0:
        break
    tmp = min(shop[i][1],M)
    ans += tmp * shop[i][0]
    M -= tmp
print(ans)


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

int Check(int jwelx[],int jwely[],int x,int y,int n){

  for(int i=0; i<n; i++){
    if(jwelx[i]==x && jwely[i]==y)
      return i;
  }
      
  return -1;
}


int main(){

  int n,m;
  int jwelx[20],jwely[20];
  int x,y,d;
  char angle;
  int sum;
  int tmp;

  while(cin >> n){
    if(n==0){ break; }

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

    cin >> m;
    sum=0;
    x=y=10;

    tmp = Check(jwelx,jwely,x,y,n);
    if(tmp!=-1){
      jwelx[tmp]=-1;
      sum++;
    }

    for(int i=0; i<m; i++){
      cin >> angle >> d;


      //  cout << "x:" << x << " y:" << y << endl;


      if(angle=='N'){
	for(int i=0; i<d; i++){
	  y++;

	  tmp = Check(jwelx,jwely,x,y,n);
	  if(tmp!=-1){
	    jwelx[tmp]=-1;
	    sum++;
	  }
	}
      }
      else if(angle=='E'){
	for(int i=0; i<d; i++){
	  x++;
	  
	  tmp = Check(jwelx,jwely,x,y,n);
	  if(tmp!=-1){
	    jwelx[tmp]=-1;
	    sum++;
	  }	  
	}
      }
      else if(angle=='S'){
	for(int i=0; i<d; i++){
	  y--;
	  
	  tmp = Check(jwelx,jwely,x,y,n);
	  if(tmp!=-1){
	    jwelx[tmp]=-1;
	    sum++;
	  }	  
	}
      }
      else{
	for(int i=0; i<d; i++){
	  x--;

	  tmp = Check(jwelx,jwely,x,y,n);
	  if(tmp!=-1){
	    jwelx[tmp]=-1;
	    sum++;
	  }
	}
      }

    }
    //for

    if(sum==n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

  }


  return 0;
}

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

using namespace std; 

int main()
{
	int sum=0,a,b,c=0;
	cin>>a>>b;
	if(b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	sum=a;
	c++;
	while(sum<b)
	{
		sum-=1;
		sum+=a;
		c++;
	}
	cout<<c<<endl;
	return 0;		
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    int i,j,count=0;
    cin>>S>>T;
    for(i=0;i<3;i++)
        {
            if(S[i]==T[i])
                count++;
        }
    cout<<count<<endl;
}


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

int main() {
    int a[4];
    for (int i = 0; i < 4; i++) {
        cin >> a[i];
    }
    int flag = 1;
    while (1) {
        // first Taka
        a[2] -= a[1];
        if (a[2] <= 0) break;
        a[0] -= a[3];
        if (a[0] <= 0) {
            flag = 0;
            break;
        }
    }
    if (flag == 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

namespace SCC{
    void visit(const vector<vector<int>>&G,vector<int>&vs,vector<int>&used,int v){
        used[v]=true;
        for(auto u:G[v]){
            if(!used[u])visit(G,vs,used,u);
        }
        vs.push_back(v);
    }

    void visit2(const vector<vector<int>>&T,vector<int>&used,vector<int>&comp,int k,int v){
        comp[v]=k;
        used[v]=true;
        for(auto u:T[v]){
            if(!used[u])visit2(T,used,comp,k,u);
        }
    }

    void decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
        vector<vector<int>>T(G.size());
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                T[v].push_back(i);
            }
        }
        comp.resize(G.size());

        vector<int>vs(G.size());
        vector<int>used(G.size());
        for(int i=0;i<G.size();i++){
            if(!used[i])visit(G,vs,used,i);
        }
        reverse(vs.begin(),vs.end());
        fill(used.begin(),used.end(),0);

        int K=0;
        for(auto v:vs){
            if(!used[v]){
                visit2(T,used,comp,K++,v);
            }
        }

        H.resize(K);
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                H[comp[i]].push_back(comp[v]);
            }
        }
        for(int i=0;i<K;i++){
            sort(H[i].begin(),H[i].end());
            H[i].erase(unique(H[i].begin(),H[i].end()),H[i].end());
        }
    }
}

signed main(){
    int N,M;
    scanf("%lld%lld",&N,&M);
    vector<vector<int>>G(N);
    rep(i,M){
        int a,b;
        scanf("%lld%lld",&a,&b);
        G[a].push_back(b);
    }

    vector<vector<int>>H;
    vector<int>comp;

    SCC::decompose(G,H,comp);

    int Q;
    scanf("%lld",&Q);
    while(Q--){
        int a,b;
        scanf("%lld%lld",&a,&b);
        printf("%lld\n",(int)(comp[a]==comp[b]));
    }
    return 0;
}

Measured memory_bytes: 5292
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long x = in.nextLong();
        long[] a = new long[n];
        long[] min = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = min[i] = in.nextLong();
        }
        long ans = Arrays.stream(min).sum();
        for(int k = 1; k < n; k++) {
            long[] tmp = new long[n];
            for (int i = n; i < n*2; i++) {
                tmp[i%n] = Math.min(min[i%n], a[(i-k)%n]);
            }
            ans = Math.min(ans, Arrays.stream(tmp).sum() + (long)k * x);
            min = Arrays.copyOf(tmp, tmp.length);
        }
        System.out.println(ans);
    }
}   

Measured memory_bytes: 50004
n,k=map(int,input().split())
chk=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        chk[j-1]+=1
ans=0
for i in chk:
    if i==0:
        ans+=1
print(ans)

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

int main() {
    int A;
    cin >> A;
    rep(i,10) {
        rep(j,10) {
            if(A==i*j) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){

  vector<int>l;

  int N,L,sum = 0;
  int ans = 0;
  int def = 10000000;

  cin >>N>>L;

  for(int i = 0;i<N;i++){
    l.push_back(L + i);
    sum += (L + i);
  }

  for(int i = 0;i<N;i++){
    if(abs((sum - l[i]) - sum) < def){
      ans = sum - l[i];
      def = abs((sum - l[i]) - sum);
    }
  }

  cout <<ans<<endl;
  return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
using ll = long long;
const ll INF = 1e18;

struct Edge {
	int s, t, w;
	Edge(int src, int tar, int wh) : s(src), t(tar), w(wh) {}
	int oth(int x) {
		return x == s ? t : s;
	}
};
using Graph = vector<vector<Edge>>;

// Find shortest paths from src to all other nodes.
// cost[i] is cost from src to node i
// prev[i] is previous node on cheapest path from src to i
// Complexity: O(m log n), Space: O(m log m)
pair<vector<ll>, vector<int>> djikstra(int src, const Graph& g) {
	int n = g.size();
	vector<ll> cost(n, INF);
	vector<int> prev(n, -1);

	priority_queue<pair<ll, int>> que;
	que.push({0, src});
	cost[src] = 0;
	
	while(! que.empty()) {
		int w = -que.top().first;
		int i = que.top().second;
		que.pop();
		if (w != cost[i]) continue;

		for (auto ed : g[i]) {
			int t = ed.oth(i);
			ll offer = w + ed.w;
			if (offer < cost[t]) {
				que.push({-offer, t});
				cost[t] = offer;
				prev[t] = i;
			}
		}
	}
	return {cost, prev};
}

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

	int n, m;
	cin >> n >> m;
	Graph g(3*n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		for (int j = 0; j < 3; ++j) {
			int jj = (j+1)%3;
			g[a + n*j].emplace_back(a + n*j, b + n*jj, 1);
		}
	}
	int s, t;
	cin >> s >> t;
	--s; --t;

	vector<ll> cost;
	vector<int> prev;
	tie(cost, prev) = djikstra(s, g);
	if (cost[t] >= INF) {
		cout << "-1\n";
	} else {
		cout << cost[t]/3 << '\n';
	}
}


Measured memory_bytes: 23680
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,a,c2=0,c4=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a%4==0)c4++;
		else if(a%2==0)c2++;
	}
	if(c4&&c4*2+1>=n)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=0;i<n;)
	{
		if(c4)
		{
			c4--;
			i+=2;
		}
		else if(c2)
		{
			c2--;
			i++;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	printf("%d", n*800-n/15*200);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int d = sc.nextInt();
            set.add(d);
        }

        System.out.println(set.size());
    }
}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);

    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i)a[j]++;
    }
    ll sum = 0;
    for(ll i = 1; i <= n; i++)sum += i * a[i];
    cout << sum << endl; 
}

Measured memory_bytes: 42328
s = list(input())
t = list(input())


def n(i):
    return ord(i) - 97


ss = set(s)
ts = set(t)
if not ts.issubset(ss):
    print(-1)
else:
    # mapping
    sp = s + s
    mp = [[-1] * 26 for _ in range(len(sp) + 1)]
    for i in range(len(sp) - 1, -1, -1):
        for j in range(26):
            if mp[i + 1][j] > -1:
                mp[i][j] = mp[i + 1][j] + 1
            mp[i][n(sp[i])] = 0
    i = 0
    im = 0
    for c in t:
        cn = n(c)
        i += mp[im][cn] + 1
        im = i % len(s)
    print(i)


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

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int num;
        cin >> num;
        if(num % 2 == 0){
            if(((num % 3) != 0) && ((num % 5) != 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int) (x).size())
#define ALL(x) x.begin(), x.end()

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long u64;
typedef vector<int> VI;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
template <typename T> void read(T & x) {
	int f = 1; char ch; x = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x *= f;
}

const int MaxN = 101234;


int n, m, a[MaxN], id[MaxN], ans[MaxN], s[MaxN], p; 
LL k, x[MaxN], y[MaxN];

void trans(int x[], int y[], int c[]) {
	static int t[MaxN];
	for (int i = 1; i <= n; i++)
		t[i] = x[y[i]];
	for (int i = 1; i <= n; i++)
		c[i] = t[i];
}

int main() {
	read(n);
	for (int i = 1; i <= n; i++) 
		read(x[i]), y[i] = x[i] - x[i - 1], ans[i] = id[i] = i;
	read(m); read(k);
	for (int i = 1; i <= m; i++) {
		int x; read(x); swap(id[x], id[x + 1]);
	}
	while(k) {
		s[++p] = k & 1; k >>= 1;
	}
	while(p) {
		trans(ans, ans, ans);
		if(s[p--]) 
			trans(ans, id, ans);
	}
	for (int i = 1; i <= n; i++) x[i] = y[ans[i]];
	for (int i = 1; i <= n; i++) x[i] += x[i - 1];
	for (int i = 1; i <= n; i++)
		printf("%lld.0\n", x[i]); 
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 998244353;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>                                                                                                              

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

using mint = modint<MOD>;
int main() {
    cin >> n>>t;
    vl A;
    rep(i,n){
        cin>>x;
        A.push_back(x);
    }

    mint dp[n+1][t+1];

    rep(i,n+1){
        rep(j,t+1){
            dp[i][j]=0;
        }
    }

    rep(i,n+1){
        dp[i][0]=i+1;
    }

    rep(i,n+1){
        for(ll j=1;j<=t;j++){
            if(i>0&&j>0)dp[i][j]=dp[i-1][j];
            if(i>0&&j>=A[i-1])dp[i][j]+=dp[i-1][j-A[i-1]];
        }
    }
    
    /*rep(i,n+1){
    	rep(j,t+1){
    		cout<<i<<" "<<j<<" "<<dp[i][j].a<<endl;
    	}
    }*/

    mint ans=0;
    rep(i,n){
        ans+=(dp[i+1][t]-dp[i][t])*(n-i);
    }

    cout<<ans.a<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    string s;
    cin>>s;

    sort(s.begin(),s.end());

    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
number_list = list(map(int,input().split()))

number_list.sort()

a = number_list[0]
b = number_list[1]
c = number_list[2]
counter = 0

if (b-a)%2==0:
    counter += (b-a)/2
    counter += (c-b)
    print(int(counter))

else:
    a = a + 1
    c = c + 1
    counter += (b-a)/2
    counter += (c-b)
    print(int(counter+1))


Measured memory_bytes: 3064
program abc155b
      implicit none
      integer::n,i
      integer,allocatable,dimension(:)::a

         read *,n
         allocate(a(n))
         read *,a(1:n)

         do i=1,n
            if (mod(a(i),2)/=0) then
               cycle
            else
               if (mod(a(i),3)==0 .or. mod(a(i),5)==0) then
                  cycle
               else
                  print *,'DENIED'
                  go to 10
               end if
            end if
         end do

         print *,'APPROVED'

10       stop
   end program abc155b

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, x;
  cin >> n >> x;
  int ans = 1, sum_val = 0;
  rep(i, 0, n) {
    int t;
    cin >> t;
    sum_val += t;
    if (sum_val <= x) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> s(n);
  for(int i=1;i<n;i++){
    int a;
    cin>>a;
    s[a-1]++;
  }
  for(int i=0;i<n;i++)
    cout<<s.at(i)<<endl;
}

Measured memory_bytes: 4056
#include <stdio.h>
int main(){
    int a,b,n,ans;
    while(scanf("%d%d%d",&a,&b,&n)!=EOF){
        ans=0;
        a%=b;
        a*=10;
    for(int i=0;i<n;i++){
        ans+=a/b;
        a%=b;
        a*=10;
    }
        printf("%d\n",ans);}
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
class A{
	public:
		int c,t;
};
int main() {
	int n,t;
	cin>>n>>t;
	A a[n];
	int ans=maxn;
	for(int i=0;i<n;i++){
		cin>>a[i].c>>a[i].t;
		if(a[i].t<=t){
			ans=min(ans,a[i].c);
		}
	}
	if(ans==maxn){
		cout<<"TLE"<<endl; 
	}else{
		cout<<ans<<endl;
	}
	
	return 0;
}


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

using namespace std;

#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()

typedef long long tint;

int main(){
	int n; cin >> n;
	vector<int> a (n);
	forn(i, n){
		cin >> a[i];
	}
	vector<int> dp (n);
	dp[1] = abs(a[1]-a[0]);
	dp[0] = 0;
	forsn(i, 2, n){
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 1024
N, L = map(int, input().split())
list_ = [L + i - 1 for i in range(1, N + 1)]
min_ = min(list_)
max_ = max(list_)
sum_ = sum(list_)

if min_ >= 0:
    print(sum_ - min_)
elif max_ <= 0:
    print(sum_ - max_)
else:
    print(sum_)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    char s;
    cin >> s;

    if (islower(s))
    {
        cout << "a" ;
    } else
    {
        cout << "A";
    }

    return 0;



    return 0;
}

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

using namespace std;

typedef long long ll;




int main()
{
    ll n,h,a,b;
    cin >> n >> h;
    vector<ll> v2;
    ll mx(0);
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        mx=max(mx,a);
        v2.push_back(b);
    }
    sort(v2.rbegin(),v2.rend());
    int i1(0),cnt(0);
    while(h>0)
    {
        if(i1<n && v2[i1]>mx)
        {
            cnt++;
            h-=v2[i1];
            i1++;
        }
        else
        {
            if(h>mx)
            {
                cnt += (h/mx);
                h-= (h/mx)*mx;

            }
            else
            {
                cnt++;
                break;
            }
        }
    }
    cout << cnt;
}


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



int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> c(n);
    rep(i,n) {
        int at;
        cin >> at;
        at--;
        a[i] = at;
        c[at]++;
    }

    ll count = 0;
    rep(i,n) {
        if (c[i] < 2) continue;
        count += (c[i] * (c[i]-1)) / 2;
    }

    rep(i,n) {
        ll ans = count;
        if (c[a[i]] > 1) {
            ans -= c[a[i]]-1;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5628
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

rs = [i if i != 10 else 0 for i in [10 - A%100%10, 10-B%100%10, 10-C%100%10, 10-D%100%10, 10-E%100%10]]
m = max(rs)

s = A + B + C + D + E + sum(rs) - m
print(s)


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

using namespace std;

int main(){
	
	
	int N;
	cin >> N;
	vector<int> vec(N);
	
	
	for(int i=0; i<N; i++){
		cin>>vec.at(i);
	}
	
	int res = 0;
	for(int i=0; i<N; i++){
		
		while(vec.at(i)%2 == 0){
			vec.at(i) = vec.at(i)/2;
			res++;
		}
		
	}
	
	cout << res << endl;
}


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

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

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

string grid[100][100];

int main(){
  rep(i,50)rep(j,100) grid[i][j]='#';
  for(int i=50;i<100;i++)rep(j,100) grid[i][j]='.';
  int a,b; cin >> a >> b;
  a--; b--;
  rep(i,50){
    rep(j,100){
      if(a==0) break;
      if(i%2==0&&j%2==0){
        grid[i][j]='.';
        a--;
      }
    }
    if(a==0) break;
  }
  for(int i=100-1;i>=50;i--){
    rep(j,100){
      if(b==0) break;
      if(i%2==0&&j%2==0){
        grid[i][j]='#';
        b--;
      }
    }
    if(b==0) break;
  }
  cout << 100 << " " << 100 << endl;
  rep(i,100){
    rep(j,100){
      cout << grid[i][j];
    }cout << endl;
  }
}

Measured memory_bytes: 3872
n = int(input())
s = [int(input()) for _ in range(n)]
s = sorted(s)
score = sum(s)
flag = False
if score % 10 != 0:
  flag = True
else:
  for i in s:
    if (score - i) % 10 != 0:
      score -= i
      flag = True
      break

if flag:
  print(score)
else:
  print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;

void trace(int A[],int N){
    int i;
    for(int i=0;i<N;i++){
        if(i>0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[],int N){
    int i, j, v;
    for(i=1;i<N;i++){
        v= A[i];
        j=i-1;
        while(j>=0 && A[j] > v ){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }

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

    int A[n];
    rep(i,n){
        cin >> A[i];
    }

    trace(A,n);
    insertionSort(A,n);

    return 0;


}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m;
    while(cin >> n >> m, n || m) {
        vector<int> h(n), w(m);
        rep(i,0,n) cin >> h[i];
        rep(i,0,m) cin >> w[i];
        
        map<int, int> mx, my;
        rep(i,0,n) {
            int temp = 0;
            rep(j,i,n) {
                temp += h[j];
                mx[temp]++;
            }
        }
        rep(i,0,m) {
            int temp = 0;
            rep(j,i,m) {
                temp += w[j];
                my[temp]++;
            }
        }

        int ans = 0;
        for(auto e : mx) {
            int val = e.first;
            if(my.count(val) == 0) continue;
            ans += (e.second * my[val]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 38820
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	vector<int> n(4);
	rep(i, 4){
		n.at(i) = s[i] - '0';
	}
	string a;
	rep(i, 1 << 3){
		a.clear();
		int ans = n[0];
		rep(j, 3){
			int temp = i & (1 << j);
			if(temp == 0){
				a.push_back('+');
				ans += n[j+1];
			}else{
				a.push_back('-');
				ans -= n[j+1];
			}
		}
		// if(i % 2 == 0){
		// 	a.push_back('+');
		// 	ans+= n[1];
		// }else{
		// 	a.push_back('-');
		// 	ans -= n[1];
		// }
		// if(i % 4 == 0 || i % 4 == 1){
		// 	a.push_back('+');
		// 	ans += n[2];
		// }else{
		// 	a.push_back('-');
		// 	ans -= n[2];
		// }
		// if(i < 4){
		// 	a.push_back('+');
		// 	ans += n[3];
		// }else{
		// 	a.push_back('-');
		// 	ans -= n[3];
		// }
		if(ans == 7){
			rep(i, 4){
				if(i != 0) cout << a[i-1];
				cout << n[i];
			}
			cout << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int dp[100];
    dp[0] = 2;
    dp[1] = 1;
    rep(i, 2, n + 1){
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
 
lst = [-1]*N
flag = False
 
for _ in range(M):
  s,c = map(int,input().split())
  if lst[s-1] != -1 and lst[s-1] != c:
    flag = True
  elif s == 1 and c == 0 and N != 1:
    flag = True
  else:
    lst[s-1] = c
 
    
if flag:
  print("-1")
elif N == 1 and (lst[0] == 0 or lst[0] == -1):
  print("0")
else:
  for i in range(N):
    if i == 0 and lst[i] == -1:
      lst[i] = 1
    elif lst[i] == -1:
      lst[i] = 0
  print("".join(map(str,lst)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin>>N;
    int a[N+1];
    a[0]=0;
    int ans=0;
    rep(i, 1, N+1) {
        cin>>a[i];ans+=abs(a[i]-a[i-1]);
    }
    ans+=abs(a[N]-a[0]);
    rep(i, 1, N+1) {
        cout<<ans-abs(a[i]-a[i-1])-abs(a[(i+1)%(N+1)]-a[i])+abs(a[(i+1)%(N+1)]-a[i-1])<<endl;
    }
}
int main()
{
    func();
}

Measured memory_bytes: 4032