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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int d = scanner.nextInt();
        final int t = scanner.nextInt();
        final int s = scanner.nextInt();

        if (s * t >= d) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 32844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		System.out.println((n-1)*(m-1));
	}
}


Measured memory_bytes: 22228
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (n, x) = (sc.nextInt(), sc.nextInt())
    val ls = Vector.fill(n)(sc.nextInt())

    var sum = 0
    var count = 1
    ls.foreach { l =>
      sum += l
      if (sum <= x) count += 1
    }
    count.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


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

#define ll long long
ll mod=1000000007;

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

ll calculateNcr(ll n, ll r){

    if(n-r<r) r=n-r;

    ll p=1, k=1;

    while (r)
    {
        p=((p%mod)*(n%mod))%mod;
        k=((k%mod)*(r%mod))%mod;

        n--;
        r--;
    }

    k = power(k,mod-2);

    return ((p%mod)*(k%mod))%mod;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, a, b;
    cin >> n >> a >> b;

    ll res = (power(2,n)%mod) -1 - (calculateNcr(n,a)%mod) - (calculateNcr(n,b)%mod);

    while (res<0)
    {
        res = (res+mod)%mod;
    }
    
    cout << res << "\n";

    return 0;
}

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

int main(){
  int N,T,c[100],t[100];
  cin>>N>>T;
  for (int i(0);i<N;i++) cin>>c[i]>>t[i];
  int mini(10000000);
  for (int i(0);i<N;i++){
    if (t[i]<=T) mini=min(mini,c[i]);
  }
  if (mini==10000000) cout << "TLE" << endl;
  else cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    300256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
int n, a[N], dp[N];
void solve()
{
    cin >> n;
    for( int i = 0; i < n; i ++ )
        cin >> a[i];
    dp[1] = abs( a[0] - a[1] );
    for( int i = 2; i < n; i ++ )
    {
        dp[i] = min( dp[i - 1] + abs( a[i] - a[i - 1] ), dp[i - 2] + abs( a[i] - a[i - 2] ) );
    }
    cout << dp[n - 1];
}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}














Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
    ll n ; cin >> n ;
    vll a(n),b(n),h(n,-1) ;
    for(auto &i:a) cin >> i ;
    for(auto &i:b) cin >> i ;
    for(int i=0;i<n;i++) if(i==0||a[i-1]<a[i]) h[i] = a[i] ;
    for(int i=n-1;i>=0;i--){
        if(i==n-1||b[i]>b[i+1]){
            if(h[i]!=-1&&h[i]!=b[i]){
                cout << 0 << endl ;
                return 0 ;
            }
            h[i] = b[i] ;
        }
    }
    ll mx = 0 ;
    for(int i=0;i<n;i++){
        chmax(mx,h[i]) ;
        if(mx!=a[i]){
            cout << 0 << endl ;
            return 0 ;
        }
    }
    mx = 0 ;
    for(int i=n-1;i>=0;i--){
        chmax(mx,h[i]) ;
        if(mx!=b[i]){
            cout << 0 << endl ;
            return 0 ;
        }
    }
    ll ans = 1 ;
    for(int i=0;i<n;i++){
        if(h[i]!=-1) continue ;
        ans = ans*min(a[i],b[i])%mod ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    char d=a[0]-32,e=b[0]-32,f=c[0]-32;
    cout<<d<<e<<f;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
typedef pair<int,int> P;
P s[200000];
int n;int h;
int main(){
	cin >> n >> h;
	REP(i,n) {
		cin >> s[i * 2].fi >> s[i * 2 + 1].fi;
		s[i * 2].sc = 0;s[i * 2 + 1].sc = 1;
	}
	sort(s,s + n * 2);

	int c = 0;int p = n * 2 - 1;
	while(h > 0) {
		if(s[p].sc == 0) {
			c += (h + s[p].fi - 1) / s[p].fi; 
			h = 0;
		}else{
			c++;
			h -= s[p].fi;
		}
		p--;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

struct DJset {
	vi parent;
	vi rank;

	DJset(int n) : parent(n), rank(n,1) {
		rep(i,0,n) {
			parent[i] = i;
		}
	}

	int find(int u) {
		if(parent[u] == u) return u;
		return parent[u] = find(parent[u]);
	}

	void merge(int u, int v) {
		u = find(u); v = find(v);
		if(u == v) return;
		if(rank[u] > rank[v]) swap(u,v);
		parent[u] = v;
		if(rank[u] == rank[v]) rank[v]++;
	}
};

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vi p(n);
	rep(i,0,n) {
		cin >> p[i];
		p[i]--;
	}
	DJset s(n);
	rep(i,0,m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		s.merge(x,y);
	}
	int ret = 0;
	rep(i,0,n) {
		int a = s.find(i);
		int b = s.find(p[i]);
		if(a == b) ret++;
	}
	cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int H,W;
		
		
		
		while(true){
			H = as.nextInt();
			W = as.nextInt();
			
			if(H==0 && W==0){
				break;
			}
			
			for(int i=0;i<H;i++){
				
				for(int j=0;j<W;j++){
					System.out.print("#");
				}
				
				System.out.println();
				
			}
			
			System.out.println();
		}
		
		

	}

}

Measured memory_bytes: 34608
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>
#define INF 1000000005

using namespace std;

const long long MOD = 1000000007;

int n;
double dp[4010];
double coin;
double score;

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    dp[0] = 1;
    //dp[i] = propability that there are i heads
    for(int i = 0; i < n; i++){
        cin >> coin;
        for(int j = i; j >= 0; j--){
            dp[j + 1] += coin * dp[j];
            dp[j] = (1 - coin) * dp[j];
            
        }
    }
    
    double answer = 0;
    
    for(int heads = 0; heads <= n; heads++){
        int tails = n - heads;
        if(heads > tails){
            answer += dp[heads];
        }
    }
    
    cout << setprecision(10) << answer;
    
    
}



Measured memory_bytes: 384
import sys

class DLLNode:
    __slots__ = ['prev', 'next', 'data']

    def __init__(self, prev, next, data):
        self.prev = prev
        self.next = next
        self.data = data

root = DLLNode(None, None, None)
cur = root.next = DLLNode(root, None, None)

def insert(x, cur):
    cur.prev.next = cur.prev = cur = DLLNode(cur.prev, cur, x)
    return cur

def move(x, cur):
    d = int(x)
    if d > 0:
        for _ in range(d):
            cur = cur.next
    else:
        for _ in range(-d):
            cur = cur.prev
    return cur

def erase(_, cur):
    cur.next.prev = cur.prev
    cur.prev.next = cur = cur.next
    return cur

C = {'0': insert, '1': move, '2': erase}
sys.stdin.readline()
for query in sys.stdin:
    cur = C[query[0]](query[2:], cur)

ans = []
it = root.next
while it.next:
    ans.append(it.data)
    it = it.next

sys.stdout.writelines(ans)



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

task_list = []

for i in range(n):
    a, b = map(int, input().split())
    task_list.append((a, b))

task_list = sorted(task_list, key=lambda x: x[1])

current = 0

for task in task_list:
    current += task[0]
    if current > task[1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 74712
#include <stdio.h>

int main(void)
{
	int ka, ki;
	char ku;
	

	while (1){

		scanf("%d %c %d", &ka, &ku, &ki);

		if (ku == '+'){
			printf("%d\n", ka + ki);
		}
		else if (ku == '-'){
			printf("%d\n", ka - ki);
		}
		else if (ku == '*'){
			printf("%d\n", ka * ki);
		}
		else if (ku == '/'){
			printf("%d\n", ka / ki);
		}
		else break;
	}
	return 0;
}

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

bool solve() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for ( int i = 0; i < N; i++ ) {
        ll xmax = A + (N-1-i)*D - i*C;
        ll xmin = A + (N-1-i)*C - i*D;
        if ( xmin <= B && B <= xmax ) return true;
    }
    return false;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

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

  
int main() {
	long long int n = 2;
	int N, i, num = 1;
	cin >> N;
	int con = N;
	int c[32];

	if (N == 0) { 
		printf("0");
		return 0;
	}

	for (i = 0; con != 0; i++) {
		if (con % n != 0) {
			c[i] = 1;
			con -= num;
		}
		else c[i] = 0;
		n *= 2;
		num *= (-2);
	}
	for (i = i - 1; i >= 0; i--) {
		printf("%d", c[i]);
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Map<String,Set<Long>>m=new TreeMap<String,Set<Long>>();String k;for(Scanner s=new Scanner(System.in);s.hasNext();m.get(k).add(s.nextLong()))if(!m.containsKey(k=s.next()))m.put(k,new TreeSet<Long>());k="";for(String x:m.keySet()){k+=x+"\n";for(long i:m.get(x))k+=i+" ";k=k.replaceAll(" $","\n");}System.out.print(k);}}

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

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    char c;
    int al[30];
    memset(al,0,sizeof(al));
    while(~scanf("%c",&c))
    {
        if(isalpha(c))
        {
            if(isupper(c))
                c=tolower(c);
            al[c-'a']++;
        }

    }
    for(int i=0; i<26; i++)
    {
        cout<<(char)(i+'a')<<" : "<<al[i]<<endl;
    }
}



Measured memory_bytes: 3160
#include <cstdio>
#include <algorithm>

using namespace std;

struct lunch{
  int w,s;
  char name[21];

  bool operator < (const lunch &l)const{
    if(w != l.w){
      return w < l.w;
    }else{
      return s < l.s;
    }
  }
};

lunch N[10],ans[10];
int n;

void make(){
  for(int i = 0 ; i < n ; i++){
    ans[i] = N[i];
  }
}

bool check(int &G){
  int Ws1 = 0,Ws2 = 0;
  for(int i = 0 ; i < n ; i++){
    if(N[i].s < Ws2) return false;
    Ws1 += (i+1)*N[i].w;
    Ws2 += N[i].w;
  }
  G = Ws1;

  return true;
}

int main(){
  while(scanf("%d" ,&n) ,n){
    for(int i = 0 ; i < n ; i++){
      scanf("%s %d %d" ,N[i].name ,&N[i].w ,&N[i].s);
    }
    sort(N,N+n);

    int G = 0,t;

    do{
      if(check(t)){
	if(G < t){
	  make();
	  G = t;
	}
      }
    }while(next_permutation(N,N+n));

    for(int i = n-1 ; i >= 0 ; i--){
      printf("%s\n" ,ans[i].name);
    }
  }

  return 0;
}

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

int cnt(vector<int> a, int b) { return count(a.begin(), a.end(), b); }

int main() {
    vector<int> a{1,3,5,7,8,10,12}, b{4,6,9,11}, c{2};
    int x, y;
    cin >> x >> y;

    if ( (cnt(a, x) and cnt(a, y)) or (cnt(b, x) and cnt(b, y)) or (x == y) ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


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

int main() {
  int a,b;
  cin>>a>>b;
  if ((a==1 && b==2)||(a==2 && b==1)){
    cout<<3<<endl;
  }
  else if ((a==1 && b==3)||(a==3 && b==1)){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

int main(void) {

	int i, j, k, n;
	int a, b;
	int num;
	int matrix[100][100];
	int vector[100];

	scanf("%d %d", &a, &b);//???,???

	for (i = 0; i < a; i++) {
		for (j = 0; j < b; j++) {
			scanf("%d", &matrix[i][j]);
		}
	}
	for (j = 0; j < b; j++) {
		scanf("%d", &vector[j]);
	}


	for (i = 0; i < a; i++) {
		num = 0;
		for (j = 0; j < b; j++) {
			num += matrix[i][j] * vector[j];
		}
		printf("%d\n", num);
	}


	return 0;

}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

string s, t;

int main() {
	cin >> s >> t;
	cout << (t.substr(0, t.size() - 1) == s ? "Yes" : "No") << ln;
}

Measured memory_bytes: 3616
package main

import "fmt"

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}

func main() {
    var a, b int
    fmt.Scan(&a, &b)
    if a == b {
        fmt.Println(a + b)
    } else {
        fmt.Println(max(a, b) * 2 - 1)
    }
}


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	vector<int>v(N + 2);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		v[L]++;
		v[R + 1]--;
	}
	for (int i = 1; i <= N + 1; i++)v[i] += v[i - 1];
	for (int i = 1; i <= N; i++)K += v[i] == M;
	cout << K << endl;
}


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

const int MAXN = 15;
int mat[15][15], n, m, tot;
int f[1 << 15], g[1 << 15][15];
void gmax(int & x, int y) { x < y ? x = y : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	memset(mat, 0xcf, sizeof mat);
	for (int i = 1, b, e, v; i <= m; ++i) {
		std::cin >> b >> e >> v, --b, --e;
		tot += mat[b][e] = mat[e][b] = v;
	}
	const int U = 1 << n;
	memset(g, 0xcf, sizeof g);
	const int NINF = **g;
	for (int i = 0; i != U; ++i)
		for (int j = 0; j != n; ++j) if (i >> j & 1)
			for (int k = j + 1; k != n; ++k) if (i >> k & 1)
				gmax(f[i], f[i] + mat[j][k]);
	for (int i = 0; i != U; ++i) if (i >> n - 1 & 1) g[i][n - 1] = f[i];
	for (int i = 0; i != U; ++i) {
		for (int j = 0; j != n; ++j) if (g[i][j] != NINF) {
			for (int k = 0; k != n; ++k) if ((~i >> k & 1) && mat[j][k] != NINF) {
				int iu = U - 1 - i - (1 << k);
				for (int l = iu; ; l = l - 1 & iu) {
					gmax(g[i | 1 << k | l][k], g[i][j] + mat[j][k] + f[l | 1 << k]);
					if (!l) break;
				}
			}
		}
	}
	std::cout << tot - g[U - 1][0] << std::endl;
	return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer p;
  
  for(p=nil->next;p!=nil;p=p->next){
    if(p->key==key)return p;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
    
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
   if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer p = nil->prev;
  // printf("cccccccbbbbbbbbb\n");
  if ( p == nil ) {printf("bbbbbbbbb\n");return;}
  deleteNode(p);
}

void delete(int key){
  /* your code */
  NodePointer x;
  x = listSearch(key);
  if(x==NULL)return;
  deleteNode(x);
  
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* 

   your code 


  */
  
 x->prev = nil;
 x->next = nil->next;
 nil->next->prev = x;
 nil->next = x;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s %d ", com, &key);
    // printf("com:%s key:%d \n", com, key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' )deleteLast();
      } else {
	delete(key); nd++; 
      }
      //printf("deleteeeeeeeee\n");
      size--;
    }
    // printf("%d %d aaaaaaaaaa\n",i,key);
  }
 
  printList();
  return 0;
}



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

using namespace std;

const int MAX = 1e5+10;

int stones[MAX], dp[MAX];

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

    int n;
    cin >> n;

    for(int i=0; i<n; i++) cin >> stones[i];

    dp[0] = 0;
    dp[1] = abs(stones[1]-stones[0]);

    for(int i=2; i<n; i++) 
        dp[i] = min(dp[i-1] + abs(stones[i]-stones[i-1]), dp[i-2] + abs(stones[i]-stones[i-2]));

    cout << dp[n-1] << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define no_answer { cout << "NO\n"; exit(0); }

using namespace std;

const int Nmax = (1<<17);

int N, A, B, ans[Nmax];

void solve(int N, int A, int B, int mask, int pos = 0)
{
    if(N == 2)
    {
        ans[pos] = A & mask;
        ans[pos+1] = B & mask;
        return;
    }

    int bit = ((A ^ B) & mask);
    bit &= (-bit);
    mask ^= bit;

    int bt;
    for(bt=1; !(mask & bt); bt <<= 1);

    solve(N>>1, A, A ^ bt, mask, pos);
    solve(N>>1, A ^ bt, B, mask, pos + (N>>1));

    int i;
    if(B & bit)
        for(i = pos + (N>>1); i < pos + N; ++i) ans[i] ^= bit;
    else for(i = pos; i < pos + (N>>1); ++i) ans[i] ^= bit;
}

int main()
{
  //  freopen("input", "r", stdin);

    cin >> N >> A >> B;

    if((__builtin_popcount(A ^ B) & 1) ^ 1) no_answer;

    solve((1<<N), A, B, (1<<N) - 1);

    cout << "YES\n";
    for(int i=0; i<(1<<N); ++i) cout << ans[i] << ' ';

    return 0;
}


Measured memory_bytes: 1536
//ITP1_6_B_19140837_小島優希也.cpp
//学習番号19140837 氏名　小島優希也

#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<bool> spade(13, true);
    vector<bool> heart(13, true);
    vector<bool> club(13, true);
    vector<bool> diamond(13, true);
    for (int i = 0; i < n; i++) {
        string suit;
        int rank;
        cin >> suit >> rank;
        if (suit == "S") {
            spade.at(rank - 1) = false;
        }
        else if (suit == "C") {
            club.at(rank - 1) = false;
        }
        else if (suit == "D") {
            diamond.at(rank - 1) = false;
        }
        else {
            heart.at(rank - 1) = false;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (spade.at(i)) {
            cout << "S" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (heart.at(i)) {
            cout << "H" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (club.at(i)) {
            cout << "C" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (diamond.at(i)) {
            cout << "D " << i + 1 << endl;
        }
    }
    return 0;
}




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

def calc(a):
    if a < 0:
        return 0
    ans = 0
    for i in range(50):
        loop = 2 ** (i+1)
        cnt = (a // loop) * (loop // 2)
        cnt += max(0, a % loop+1 - loop // 2)
        if cnt % 2 == 1:
            ans += 2 ** i
    return ans

print(calc(B) ^ calc(A-1))

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint a, b, m;
llint x[100005], y[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> m;
	for(int i = 1; i <= a; i++) cin >> x[i];
	for(int i = 1; i <= b; i++) cin >> y[i];
	
	llint u, v, c, ans = inf;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> c;
		ans = min(ans, max(0LL, x[u]+y[v]-c));
	}
	sort(x+1, x+a+1);
	sort(y+1, y+b+1);
	
	ans = min(ans, x[1]+y[1]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func findK(a, b int) string {
	sum := a + b
	if sum%2 == 1 {
		return "IMPOSSIBLE"
	}
	return strconv.Itoa(sum / 2)
}

func main() {
	a, b := nextInt(), nextInt()
	r := findK(a, b)
	fmt.Println(r)
}


Measured memory_bytes: 640
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt
 
    // 0 0が入力された
    if(!width && !height){
      break;
    }
 
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
     
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];
 
        switch(c){
        case 'S':
          start = pos(x, y);
          break;
        case 'G':
          goal = pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1][elem[c - 1].length] = pos(x, y);
          break;
        }
      }
    }
 
     
    var bestElement = -1;
    var distance = Infinity;
     
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
       
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;
 
      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
       
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = fmin(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
       
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
         
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
         
      }
       
    }
     
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
 
    i++;
  }
   
 
}
 
function dist(from, to){
  return fabs((from >> 11) - (to >> 11)) + fabs((from & 2047) - (to & 2047));
}
 
function fmin(a1, a2){
  return a1 > a2 ? a2 : a1;
}
 
function pos(a, b){
  // 2^10 = 1024なので、下位10ビットでy座標を、上位ビットでx座標を表す
  return (a << 11) + b;
}

function fabs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 51448
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;
 
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,a[3999],b[3999][3999],ans=LLINF;
    cin>>n>>x;
    rep(i,n) cin>>a[i];
    rep(i,n) b[i][0]=a[i];
    rep(k,n){
        ll sec=0;
        rep(i,n){
         if(k==0){
                sec+=a[i];
                continue;
          }
         ll s=i-k;
         if(s<0) s+=n;
         b[i][k]=min(b[i][k-1],a[s]);
         sec+=b[i][k];
        }
        ans=min(ans,sec+k*x);
}
    cout<<ans<<endl;
    return 0;
}

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

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

const int MAX_N = 100100;
const long long INF = LONG_LONG_MAX;
vector<pair<long long, long long> > Glaph[MAX_N]; //i=from <to,cost> 
 
vector<long long> dijkstra(int start){
    vector<long long> distance(MAX_N, INF);
    distance[start] = 0;//start->i
    priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> que; //min heap <cost,to> costでソートするためGの逆
    que.push(make_pair(0, start));
    while(!que.empty()){
        auto p = que.top(); //<cost,to>
        que.pop();
        //目的地1を更新できないならとばす
        if(distance[p.second] < p.first) continue;
        //目的地１(p.second)から伸びるedgeの先の目的地２(edge.first)をそれぞれ更新する
        for (auto edge: Glaph[p.second]){ //edge<to,cost> 
            //目的地２の元のcost > 更新された目的地１のコスト + edgeのコスト なら更新してキューに追加
            if(distance[edge.first] > distance[p.second] + edge.second){
                 distance[edge.first] = distance[p.second] + edge.second;
                 que.push(make_pair(distance[edge.first],edge.first));
            }
        }
    }
    return distance;
}
 
int main(){
    int N, Q, K;
    cin >> N;
    int a,b,c;
    rep(i, N-1){
        cin >> a >> b >> c;
        a--, b--;
        Glaph[a].push_back(make_pair(b, c));
        Glaph[b].push_back(make_pair(a, c));
    }
    cin >> Q >> K;
    K--;
    auto distancesFromK = dijkstra(K);
    for(auto r : distancesFromK){

    }
    /*
    rep(i,10){
        cout << distancesFromK[i] << endl;
    }
    */
    int x,y;
    rep(i,Q){
        cin >> x >> y;
        x--,y--;
        cout << distancesFromK[x]+distancesFromK[y] << endl;
    }
    return 0;
}

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

int main() {
  int n,ans;
  cin >> n;
  vector<int> x(n);
  vector<int> p(100);
  for(int i=0;i<n;i++) cin >> x.at(i);
  for(int i=1;i<101;i++) {
    for(int j=0;j<n;j++) {
      p.at(i-1)+= (i-x.at(j))*(i-x.at(j));
    };
  };
  ans=99999999;
  for(int i=0;i<100;i++) {
    if(ans>p.at(i)) ans=p.at(i);
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,c,d;
    cin >> a >> b >> c>>d;
    if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) cout << "Yes" << endl;
    else cout << "No" << endl; 



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,l=0;
    cin >> n >> k;
    int x;
    for(int i=0;i<n;i++){
        cin >> x;
        l += min(x,k-x) * 2;
    }
    cout << l << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        c -= b;
        if(c <= 0) break;
        a -= d;
    }
    if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3628
class tree:
    def __init__(self, node, children):
        self.node = node
        self.children = children
        self.feature = None
        self.parent = None
        self.depth = 0


def set_feature(info_list):
    for info in info_list:
        if info.depth == 0:
            info.feature = 'root'
        else:
            if len(info.children) == 0:
                info.feature = 'leaf'
            else:
                info.feature = 'internal node'

def get_root_node(info_list):
    cand_nodes = []
    remove_node = []
    for info in info_list:
        if len(info.children) != 0:
            cand_nodes.append(info.node)
            remove_node.extend(info.children)
    if len(cand_nodes) == 1:
        return cand_nodes[0]
    elif len(cand_nodes) == 0:
        return info_list[0].node
    else:
        co_value = (set(cand_nodes) ^ set(remove_node)) & set(cand_nodes)
    return co_value.pop()
    
def set_parent(info_list):
    for info in info_list:
        if info.feature == 'root':
            info.parent = -1
        children = info.children
        for child in children:
            info_list[child].parent = info.node

def set_depth(child, depth, node_infos):
    if len(node_infos[child].children) == 0:
        node_infos[child].depth = depth
    else:
        depth += 1
        children = node_infos[child].children
        for child in children:
            info_list[child].depth = depth
            set_depth(child, depth, node_infos)
        

N = int(input())
info_list = [0] * N
for i in range(N):
    info = [int(i) for i in input().split()] 
    node_num = info.pop(0)
    nchild = info.pop(0)
    info_list[node_num] = tree(node_num, info)

root_node = get_root_node(info_list)
set_depth(root_node, 0, info_list)

for info in info_list:
    if info.depth == 0:
        info.feature = 'root'
    else:
        if len(info.children) == 0:
            info.feature = 'leaf'
        else:
            info.feature = 'internal node'

for info in info_list:
    if info.feature == 'root':
        info.parent = -1
    children = info.children
    for child in children:
        info_list[child].parent = info.node

for info in info_list:
    print('node {}: parent = {}, depth = {}, {}, {}'.format(
        info.node, info.parent, info.depth, info.feature, info.children
    )
)






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

int main(void) {
	int n, a[200000];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int k = 1;
	// searching for k valued block
	for(int i = 0; i < n; i++) {
		if (a[i] == k)
			k++;
	}
	if (k == 1) cout << -1;
	else cout << n - (k - 1);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if (a + b < 10) {
        cout << a + b << endl;
    } else {
        cout << "error" << endl;
    }
}




Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**6)
s=input()
t=input()
ls=len(s)
lt=len(t)
dp=[[0]*(lt+1) for i in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
                                                                                                    
ans=""
def rec(i,j):
  if i==0 or j==0:
    return 
  global ans
  if s[i-1]==t[j-1]:
    ans+=s[i-1]
    rec(i-1,j-1)
  elif dp[i-1][j]>=dp[i][j-1]:
    rec(i-1,j)
  else:
    rec(i,j-1)
rec(ls,lt)
print(ans[::-1])

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

//ａをbで割る
long long mod_div(long long a,long long b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

typedef long long ll;
typedef pair<ll,ll> P;

ll n,k;
ll nikai[111111];

int main(){

	nikai[0] = 1;
	REP(i,111110)nikai[i+1] = (nikai[i] * 2) % MOD;

	cin >> k >> n;

	for(ll i = 2;i <= 2*k;i++){
		ll ans = 0;
		bool eq = false;
		ll pairNum = 0;
		for(ll j = 1;j <= k;j++){
			ll tmp = i - j;
			if(j == tmp)eq = true;
			else if(tmp <= k && j < tmp)pairNum++;
		}
		ll nokori = k - 2 * pairNum - eq;
		for(ll j = 0;j <= pairNum;j++){
			if(n < j || nokori + j == 0)continue;
			ll tmp = nikai[j] * combination((n - j) + (nokori + j - 1), (n - j)) % MOD;
			tmp = tmp * combination(pairNum, j) % MOD;
			ans = (ans + tmp) % MOD;
		}
		if(eq)for(ll j = 0;j <= pairNum;j++){
			if(n < j + 1)continue;
			ll tmp = nikai[j] * combination((n - j - 1) + (nokori + j - 1), (n - j - 1)) % MOD;
			tmp = tmp * combination(pairNum, j) % MOD;
			ans = (ans + tmp) % MOD;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

bool vec_eq(vector<int> a, vector<int> b) {
    if (a.size() != b.size()) return false;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

int main(int argc, const char * argv[]) {

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

    int n; cin >> n;
    vector<vector<int>> alphs(n, vector<int>(26, 0));
    
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        for (int j = 0; j < s.size(); j++) {
            alphs[i][s[j] - 'a']++;
        }
    }
    
    sort(alphs.begin(), alphs.end());
    
    vector<int> v(26, 0);
    for (int i = 0; i < 26; i++) {
        v[i] = alphs[0][i];
    }
    
    int64_t ans = 0;
    int64_t cnt = 1;
    for (int i = 1; i < n; i++) {
        if (vec_eq(v, alphs[i])) {
            cnt++;
        } else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            for (int j = 0; j < 26; j++) {
                v[j] = alphs[i][j];
            }
        }
    }
    
    ans += cnt * (cnt - 1) / 2;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s;
    cin >> s;
    int ans = 0, sum = 0;
    rep(i, 0, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            sum++;
        } else {
            ans = max(ans, sum);
            sum = 0;
        }
    }
    ans = max(ans, sum);
    cout << ans << "\n";
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N % 1000 == 0) {
			System.out.println(0);
		} else {
			System.out.println(1000 - N % 1000);
		}
	}
}


Measured memory_bytes: 35712
n = int(input())
s = str(input())

R = []
G = []
B = []
for i in range(n):
  if s[i] == "R":
    R.append(i+1)
  elif s[i] == "G":
    G.append(i+1)
  else:
    B.append(i+1)

  
ans = 0

for i in range(len(R)):
  for j in range(len(G)):
    temp = 0
    if 2*R[i] - G[j] >0 and 2*R[i] - G[j] <= n:
      if s[2*R[i] - G[j] -1] == "B":
        temp += 1
    if 2*G[j] - R[i] >0 and 2*G[j] - R[i] <= n:
      if s[2*G[j] - R[i]-1] == "B":
        temp += 1
    if (R[i]+G[j])%2 == 0:
      if s[(R[i]+G[j])//2-1] == "B":
        temp += 1
    ans += len(B)- temp

print(ans)


Measured memory_bytes: 9296
#include<stdio.h>

int main(){

	int H,W,i,j;	

	while(1){
		scanf("%d %d\n",&H,&W);
		if(H==0 && W==0) break;

	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(i==0 || i==H-1 || j==0 || j==W-1)
				printf("#");
			else
				printf(".");
		}
		printf("\n");
	}

	printf("\n");


	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b; 
  if((a+b)%2 == 1){
    c=a+b+1;
  }else{
    c=a+b;
  }
  cout<< c/2 << endl;
}

Measured memory_bytes: 3572
#include <stdio.h>
int main(void){
  // Your code here!
  int x,i;
  i=1;
 
  while(scanf("%d",&x) !=EOF)
  {
      if(x == 0)break;
  printf("Case %d: %d\n",i,x);
  i++;
  }
  return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

int main() {
    ll n, m; cin >> n >> m;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    sort(ALL(a));
    Vp vp(m);
    rep(i, 0, m) cin >> vp[i].se >> vp[i].fi;
    sort(ALL(vp));
    reverse(ALL(vp));
    // rep(j, 0, n) cout << a[j] << " ";
    // coel;
    ll r = 0;
    rep(i, 0, m){
        // cout << vp[i].fi << "  ";
        ll m = r;
        rep(j, m, min(n, m+vp[i].se)){
            if(a[j]>=vp[i].fi) break;
            a[j] = vp[i].fi;
            r++;
        }
        // rep(j, 0, n) cout << a[j] << " ";
        // coel;
    }
    ll ans = 0;
    rep(i, 0, n) ans += a[i];
    co(ans);
    
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;
#define ll long long

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if(K > A) {
        cout << 0 << " " << max(0LL, B - (K - A)) << endl;
    } else {
        cout << A - K << " " << B << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int N;
    int res=0;
    vector<int> A;
    cin>>N;
    A.resize(N);
    for(int i=0;i<N;i++){
        cin >>A.at(i);
    }
    sort(A.begin(),A.end(),greater<int>());
    vector<bool> dp(A[0],true);
    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1])dp[A[i]-1]=false;
    }
    for(int i=1;i<N;i++){
        for(int j=2;A[i]*j<=A[0];j++){
            dp[A[i]*j-1]=false;
        }
    }

    for(int k=0;k<N;k++){
        res+=dp[A[k]-1];
    }
    cout<<res;
}

Measured memory_bytes: 3992
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]

ans = 0
for m in range(1, N+1):
    if m <= K:
        continue
    maxlen, mod = divmod(N, m)
    ans += maxlen * (m - K)
    
    ans += max(0, N - m * maxlen - K + 1)
    if K == 0:
        ans -= 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int k; long long n;
    cin >> k;
    queue<long long> q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }
    while (k > 0) {
        n = q.front();
        if (n % 10 == 0) {
            q.push(10 * n); q.push(10 * n + 1);
        }
        else if (n % 10 == 9) {
            q.push(10 * n + 8); q.push(10 * n + 9);
        }
        else {
            q.push(10 * n + n % 10 - 1); q.push(10 * n + n % 10); q.push(10 * n + n % 10 + 1);
        }
        q.pop();
        k--;
    }
    cout << n << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,mx,mn;
int p[200010];
bool vis[200010],cir[200010],_is[200010];
int mex[200010],cnt_tree=0;
struct node{int y,nxt;
}g[200010];int h[200010],tot=0;
void dfs(int x)
{
    for (int i=h[x];i;i=g[i].nxt) if (!cir[g[i].y]) dfs(g[i].y);
    for (int i=h[x];i;i=g[i].nxt) if (!cir[g[i].y]) _is[mex[g[i].y]]=1;
    for (mex[x]=0;_is[mex[x]];mex[x]++);
    for (int i=h[x];i;i=g[i].nxt) _is[mex[g[i].y]]=0;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) 
    {
        scanf("%d",&p[i]);
        g[++tot]=node{i,h[p[i]]};h[p[i]]=i;
    }
    int x=1;
    while (!vis[x]) vis[x]=1,x=p[x];
    while (!cir[x]) cir[x]=1,x=p[x];
    mx=0;mn=2147483647;
    for (int i=1;i<=n;i++)
    if (cir[i])
    {
        dfs(i);cnt_tree++;
        mx=max(mx,mex[i]);mn=min(mn,mex[i]);
    }
    if (mx==mn&&(cnt_tree&1)) printf("IMPOSSIBLE");else printf("POSSIBLE");
}

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

int main()
{    
    string s,t,u;
    int a,b;   
    cin >> s >> t >> a >> b >> u;

    if( s == u)
        --a;
    else
        b--;
    printf("%d %d\n",a,b);

}

Measured memory_bytes: 256