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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Edge {
    ll a, b, c;
};

Edge E[2005];
ll S[1005];
ll U[1005];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, M) {
        cin >> E[i].a >> E[i].b >> E[i].c;
        E[i].c *= -1;
        E[i].a--;
        E[i].b--;
    }

    memset(U, 0, sizeof(U));
    U[N - 1] = true;
    REP(i, N + 1) {
        REP(j, M) {
            ll a = E[j].a;
            ll b = E[j].b;
            if (U[b])
                U[a] = true;
        }
    }

    REP(i, N) {
        S[i] = INF;
    }
    S[0] = 0;
    REP(i, N + 1) {
        REP(j, M) {
            ll a = E[j].a;
            ll b = E[j].b;
            S[b] = std::min(S[b], S[a] + E[j].c);
        }
    }

    REP(i, M) {
        ll a = E[i].a;
        ll b = E[i].b;
        ll cost = E[i].c + S[a];
        if (S[b] > cost && U[b]) {
            cout << "inf" << endl;
            return 0;
        }
    }
    cout << -S[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		sc.close();
		if(A.length() > B.length()) {
			System.out.println("GREATER");
		}else if(A.length() < B.length()) {
			System.out.println("LESS");
		}else {
			int l = A.length();
			for(int i = 0; i < l; i++) {
				if(A.charAt(i) > B.charAt(i)) {
					System.out.println("GREATER");
					System.exit(0);
				}else if(A.charAt(i) < B.charAt(i)) {
					System.out.println("LESS");
					System.exit(0);
				}
			}
			System.out.println("EQUAL");
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> ii;

char x;

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

  cin >> x;
  x += 1;
  string s = "";
  s += x;
  cout << s << endl;

  return 0;
}


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

using namespace std;


int main(){

    int N;
    cin >> N;
    
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    int a = -1;
    int b,c;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0 && a == -1) {
            a = x[i];
            b = y[i];
            c = h[i];
        }
    }
    
    int cx = 0;
    int cy = 0;
    int H = 1;
    int ll = 0;
    
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            
            H = c + abs(i - a) + abs(j - b);
            ll = 0;
            
            for (int k = 0; k < N; k++) {
                if (h[k] == max(0, H-abs(i-x[k])-abs(j-y[k]))) {
                    cx = i;
                    cy = j;
                    ll += 1;
                }else{
                    break;
                }
            }
            
            if (ll == N) {
                break;
            }
        }
        if (ll == N) {
            break;
        }
    }
    
    cout << cx << " " << cy << " " << H << endl;
    

}


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

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("gymnastics.in","r",stdin );
#define outF freopen("gymnastics.out" , "w" , stdout ) ;
#define sum(a)a * (a + 1 ) / 2
#define ll long long

const double eps = 1e-9 , PI = acos(-1) ;
const int N = 101, oo = 1e17 , M = 1e5 + 5, mod = 1<<30 , K = 12;
int n , val[N] , wt[N];
ll dp[2][M];/*
ll knapsack(int idx , int w){
    if(w < 0)
        return -oo;
    if(idx == n)
        return 0 ;
    ll &ret = dp[idx][w] ;

    if(~ret)
        return ret ;

   ll first = knapsack(idx + 1 , w);
   ll second = knapsack(idx + 1 , w - wt[idx]) + val[idx];
   ret = max(first , second);
   return ret ;


}

void print(int idx , int w){
    if(idx == n || w < 0)
        return ;
    int first = knapsack(idx + 1 , w);
    int sefcond = knapsack(idx + 1 , w - wt[idx]) + val[idx];
    if(first == knapsack(idx , w)){
        cout << "Left item " << idx << endl ;
        print(idx + 1 , w);
        return ;}
    else cout << "Take item " << idx << endl ;
    print(idx + 1 , w - wt[idx]);




}*/
int32_t main(){

    //inF;
    // Dont Forget memset
    memset(dp , -1 , sizeof dp);

    //calculate constraints please!!!

    int W ;
    fastio;
    cin >> n >> W ;
    for(int i = 0 ; i < n ; i++)
        cin >> wt[i] >> val[i];

    for(int i = 0 ; i <= W ; i++)
        dp[n & 1][i] = 0 ;

    for(int i = n - 1 ; i >= 0 ; i--){
        for(int j = 0 ; j <= W ; j++){

            ll first = dp[(i + 1) & 1][j];
            ll second = -1 ;
            if(j >= wt[i])
                second = dp[(i + 1) & 1][j - wt[i]] + val[i];
            dp[i & 1][j]= max(first , second);
        }
    }
    cout << dp[0][W];
     return 0 ;
}



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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int A, B;
    cin >> A >> B;
    
    cout << max(0, A - 2*B) << endl;

    return 0;
}

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

int main(){
  int N;
  
  cin >> N;
  int L[N];
  
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  
  int ans=0;
  sort(L,L+N);
  
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      for(int k=j+1; k<N; k++){
        if(L[i]<L[j]+L[k]&&L[j]<L[k]+L[i]&&L[k]<L[i]+L[j])
          ans++;
        else
          break;
        }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

struct edge { int from, to; double dist; };

struct UnionFind {
	vector<int> vec;
	UnionFind(int n) { vec.resize(n, -1); };

	bool unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return false;
		if (vec[a] > vec[b]) swap(a, b);
		vec[a] += vec[b];
		vec[b] = a;
		return true;
	}
	bool same(int a, int b) { return find(a) == find(b); }
	int find(int x) { return vec[x] < 0 ? x : vec[x] = find(vec[x]); }
	int size(int x) { return -vec[find(x)]; };
};

signed main() {
	int n;
	while (cin >> n && n) {
		vector<edge> graph;
		using tup = tuple<double, double, double, double>;
		vector<tup> v(n);
		rep(i, n) {
			double x, y, z, r; cin >> x >> y >> z >> r;
			v[i] = tup(x, y, z, r);
		}

		UnionFind uf(n);
		rep(i, n) rep(j, i + 1, n) {
			auto a = v[i], b = v[j];
			double d = hypot(hypot(get<0>(a) - get<0>(b), get<1>(a) - get<1>(b)), get<2>(a) - get<2>(b)) - get<3>(a) - get<3>(b);
			if (d <= 0) uf.unite(i, j);
			else graph.push_back(edge{ i, j, d });
		}

		double ans = 0;
		sort(all(graph), [](edge e1, edge e2) {return e1.dist < e2.dist; });
		for (auto& e : graph) if (!uf.same(e.from, e.to)) {
			uf.unite(e.from, e.to);
			ans += e.dist;
		}

		printf("%.3f\n", ans);
	}
}

Measured memory_bytes: 3376
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string A,B;
	cin>>A>>B;
	if(A.length()==B.length())
	{
		puts(A==B?"EQUAL":A>B?"GREATER":"LESS");
	}
	else
	{
		puts(A.length()>B.length()?"GREATER":"LESS");
	}
	return 0;
}


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

    vector<int> shiro(N+1,0);
    int cnt = 0;
    for (int i=1; i<N+1; i++) {
        if (S.at(i-1)=='.') cnt++;
        shiro.at(i)=cnt;
    }

    int ans = N;
    for (int i=0; i<N+1; i++) {
        int now = (i-shiro.at(i))+(shiro.at(N)-shiro.at(i));
        ans = min(now, ans);
    }

    cout << ans << endl;

}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
	cout << (n%1000 ? 1000-n%1000 : 0) << "\n";

    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cctype>

int main(){
    
    char ch;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n') break;
        else if(islower(ch)) printf("%c",toupper(ch));
        else if(isupper(ch)) printf("%c",tolower(ch));
        else printf("%c",ch);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin() (a).end()
void solve()
{
	ll h, n ;
	cin >>h>> n;
	ll sum = 0 ;
	for(int i = 0 ; i< n ;i++){
		ll temp;cin>> temp;
		sum += temp;
	}
	if(sum >= h)cout<<"Yes\n";
	else cout<<"No\n";

return ;
}
int main()
{
	solve();
return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
  minj = i
  for j in range(i,N):
    if A[minj]>A[j]:
      minj = j
  _=A[minj]
  if minj != i:
    A[minj]=A[i]
    A[i]=_
    cnt+=1
print(*A)
print(cnt)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.println(
				a.substring(0, 1).toUpperCase() + b.substring(0, 1).toUpperCase() + c.substring(0, 1).toUpperCase());
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[100010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	bool ans=true;
	for(ll i=n-2;i>=0;i--){
		if(ch[i+1]<ch[i]){
			ch[i]--;
		}
		if(ch[i+1]<ch[i]){
			ans=false;
		}
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int a[10]={0};
	 for(int i=0;i<4;i++)
	 {
	 	 int t;
	 	 cin>>t;
	 	 a[t]++;
	 }
	 if(a[1]&&a[7]&&a[9]&&a[4])
	 printf("YES\n");
	 else
	 printf("NO\n");
 } 

Measured memory_bytes: 256
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,*L = map(int, read().split())
L.sort()
print(sum(L[len(L)-K:]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{

ll n ;
cin>>n;

ll ans = 0 ;
ll prev = 0;
for(ll index = 0; index < n;index++)
{
    ll c;
    cin>>c;

    if(c<prev)
    {
        ans+=(prev-c);
    }
    prev = max(prev,c);
}

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


Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, a;
  cin >> n >> a;
  n %= 500;
  if (n <= a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int d, n, i;
    scanf("%d%d", &d, &n);
    for(i = 1; n != 0; i++)
    {
        if(i % 100 != 0)
            n--;
        if(!n) break;
    }
    while(d--)
        i *= 100;
    printf("%d", i);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

        int a,b;

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

        if(a<b)
           cout << "a < b" << endl;
        else if(a>b)
           cout << "a > b" << endl;
        else
           cout << "a == b" << endl;

        return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;


int N,C;
int s[100000], t[100000], c[100000];
int sm[200002];
int tt[200002];
int main()
{
    scanf("%d%d", &N,&C);
    for(int i=0;i<N;i++)
        scanf("%d%d%d", &s[i],&t[i],&c[i]);
    for(int i=1;i<=C;i++)
    {
        for(int j=0;j<200002;j++) tt[j]=0;
        for(int j=0;j<N;j++) if(c[j]==i) tt[s[j]*2-1]++,tt[t[j]*2]--;
        for(int j=1;j<200002;j++) tt[j]+=tt[j-1];
        for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++;
    }
    int mx=0;
    for(int j=0;j<200002;j++)if(mx<sm[j])mx=sm[j];
    printf("%d\n",mx);
}


Measured memory_bytes: 2944
import math

N = int(input())

rootN = int(math.sqrt(N))

ans = 0
for i in range(1,rootN if (rootN ** 2) == N else rootN+1):
    if N%i==0 and ((N//i)-1) > i:
        ans += (N//i) - 1
        
print(ans)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[51];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	ll ret=0;
	FOR(x,1000000) {
		FOR(i,N) {
			if(A[i]>=N) {
				ll del=A[i]/N;
				ret += del;
				A[i] -= del*N;
				FOR(j,N) if(i!=j) A[j] += del;
			}
		}
	}
	
	
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;

ll sum[N];

int main()
{ 

IOS;

ll n;cin>>n;

ll p=1e9+7;

vl a(n+1);

FOR(i,n)cin>>a[i+1];

vl dp(n+1);

dp[0]=1;

for(int i=1;i<=n;i++){
  if(a[i]!=a[i-1]){
    sum[a[i]]+=dp[i-1];
    sum[a[i]]%=p;
  }
  dp[i]=sum[a[i]]%p;
}

cout<<dp[n]<<endl;


return 0;
 
}



Measured memory_bytes: 7988
#include <stdio.h>

int main(){
  int a[200200],i,maxr,minr,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  minr = a[0];
  maxr = a[1] - a[0];
  for(i=1;i<n;i++){
    if(maxr<=a[i]-minr) maxr = a[i] - minr;
    if(minr>=a[i]) minr = a[i];
  }
  printf("%d\n",maxr);
  return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1LL << 32;
const ll INF = 1e18+7;

signed main()
{
    int s;
    cin >> s;
    map<int, int> m;
    m[s] = 1;
    int i = 1;
    auto f = [&](int p){
        return p % 2 ? 3 * p + 1 : p / 2;
    };
    while(++i){
        int val = f(s);
        if(m.find(val) != m.end()){
            cout << i << endl;
            return 0;
        }
        m[val] = i;
        s = val;
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];

            long ans = (long)(Math.Ceiling(W / 2.0) * Math.Ceiling(H / 2.0) + Math.Floor(W / 2.0) * Math.Floor(H / 2.0));
            if (1 == H || 1 == W) ans = 1;
            WriteLine(ans.ToString());

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>                                                         
using namespace std;
int main()
{
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    if(i!=s.size()-1){
      if((i+1)%2!=0)
        cout << s.at(i);
    }
  }
  if(s.size()%2!=0)
    cout << s.at(s.size()-1);
  cout << endl;
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);int b = int.Parse(s[1]);int c = int.Parse(s[2]);
            
            Console.WriteLine(b-a==c-b ? "YES":"NO");
        }
    }
}


Measured memory_bytes: 11092
int main()
{
  int k;
  char s[101];
  scanf("%d %s", &k, &s);
  int dig = 0, i;
  for (i = 0; s[i] != '\0'; i++)
    dig++;
  if (dig <= k)
    printf("%s", s);
  else
  {
    for (i = 0; i < k; i++)
      printf("%c", s[i]);
    printf("...");
  }
}

Measured memory_bytes: 1720
//https://codeforces.com/gym/291121/problem/B

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf
#define se(a) a.begin(),a.end()
#define fill(a,n) for(int i = 0; i < n; i++)cin>>a[i]

ll solve(vi a,vi t,int index,int k){
    if(index >= a.size())return 0;
    int l1 = 0,l2 = 0;
    if(t[index] == 0 && index <= a.size() - k){
        
        for(int i = index; i < index+k; i++){
            l1 += a[i];
        }
        l1 = l1 + solve(a,t,index+k+1,0);
        l2 = solve(a,t,index+1,k);
    }
    else{
        l1 = a[index] + solve(a,t,index+1,k);
    }
    return max(l1,l2);
}

int main()
{
    string r;
    cin>>r;
    int ans = 0;
    for(int i = 0; i < r.size(); i++){
        int temp = 0;
        if(r[i] == 'R'){
            while(i < r.size() && r[i] == 'R'){
                temp++;
                i++;
            }
        }
        ans = max(ans,temp);
    }
    cout<<ans<<nl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[]args) {
		Scanner scn = new Scanner(System.in);
		int[]a=new int[scn.nextInt()];
		for(int i=0;i<a.length;i++)a[i]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[]a) {
		int[]dp=new int[a.length];
		for(int i=1;i<a.length;i++) {
			int f1 = i-1>=0?(Math.abs(a[i]-a[i-1])+dp[i-1]):Integer.MAX_VALUE, f2=i-2>=0?(Math.abs(a[i]-a[i-2])+dp[i-2]):Integer.MAX_VALUE;
			dp[i]=Math.min(f1, f2);
		}
		return dp[a.length-1];
	}
	
}


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

class Program
{
    static void Main()
    {
        var X = ReadLine().Split().Select(int.Parse).ToArray();
        // var N = int.Parse(ReadLine());

        if (X[0] < X[2]) WriteLine(X[0] < X[2] && X[2] < X[1] ? "Yes" : "No");
        else WriteLine(X[1] < X[2] && X[2] < X[0] ? "Yes" : "No");
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    int N, K;

    std::cin >> N >> K;

    int i = K - 1;
    int num = 1;
    double p = 0.0;
    if (N >= K) {
        p += 1.0 / N * (N - i);
        
    }
    while (i > 1) {
        if (i / 2 > N) {
            num++;
            i = i / 2;
            continue;
        }
        int tmp_i = i / 2;
        p += std::pow(0.5, num) * (std::min(i, N) - tmp_i) / N;
        i = tmp_i;
        num++;
    }
    if (i == 1 && K != 1) {
        p += std::pow(0.5, num) * 1.0 / N;
    }
    std::cout << std::setprecision(11) <<  p << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    string s;
    while(n!=0)
    {
        ll r=n%26;
        if(r==0)
        {
            r=26;
            n--;
        }
        s.push_back('a'+r-1);
        n=n/26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll temp = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> a.at(i);
    temp ^= a.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    cout << (temp ^ a.at(i)) << " ";
  }
  cout << "\n";
}


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

class Program
{
    const long mod = 1000000007;
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        var G = new List<int>[N];
        var d = new int[N];
        for (int i = 0; i < G.Length; i++)
        {
            G[i] = new List<int>();
        }
        for (int i = 0; i < N - 1; i++)
        {
            var line = ReadLine().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            G[a].Add(b);
            G[b].Add(a);
            d[a]++;
            d[b]++;
        }

        var ans = new int[N];

        var q = new Queue<Pair>();
        var used = new bool[N];
        ans[0] = K;
        used[0] = true;
        q.Enqueue(new Pair(0, K + 1));
        while (q.Count != 0)
        {
            var v = q.Dequeue();
            int f = 0;
            foreach (var u in G[v.v])
            {
                if (!used[u])
                {
                    f++;
                    ans[u] = K - 1 - f;
                    q.Enqueue(new Pair(u, ans[v.v]));
                    used[u] = true;
                }
            }
        }
        foreach (var l in G[0])
        {
            ans[l] += 1;
        }
        var c = 1L;
        foreach (var i in ans)
        {
            c = c * i % mod;
        }
        WriteLine(c);


    }
}

struct Pair
{
    public int v;
    public int parsk;
    public Pair(int V, int P)
    {
        v = V;
        parsk = P;
    }
}

Measured memory_bytes: 32268
fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    var extra = 0L
    if (n > 1) {
        for (i in 1..a.lastIndex) {
            if (a[i] < a[i - 1]) {
                val needed = a[i - 1] - a[i]
                a[i] += needed
                extra += needed
            }
        }
    }
    println(extra)
}

Measured memory_bytes: 71620
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long ll;

int N;
ll A[100010];
ll sum = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 1; i <= N; i++)scanf("%lld",A + i);

    A[0] = A[N + 1] = 0;
    for(int i = 0; i <= N; i++)sum += labs(A[i] - A[i + 1]);
    for(int i = 1; i <= N; i++)
    {
        if((A[i - 1] <= A[i] && A[i] <= A[i + 1]) || (A[i - 1] >= A[i] && A[i] >= A[i + 1]))printf("%lld\n",sum);
        else printf("%lld\n",sum - 2 * min(abs(A[i - 1] - A[i]),abs(A[i] - A[i + 1])));
    }
    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
int main()
{int i,a;
scanf("%d",&a);
for(i=1;i<=a;i++){
if(i%3==0||i%10==3||
           i/10==3||i/100==3||i/1000==3||
           i%100/10==3||i%1000/100==3)
printf(" %d",i);}
puts(""); return 0;}

Measured memory_bytes: 608
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    int a,b,c;
    int cnt5 = 0, cnt7 = 0;
    cin >> a >> b >> c;
    if(a == 5) cnt5++;
    else if(a == 7) cnt7++;

    if(b == 5) cnt5++;
    else if(b == 7) cnt7++;

    if(c == 5) cnt5++;
    else if(c == 7) cnt7++;

    if(cnt5 == 2 && cnt7 == 1){
        cout << "YES" << endl;;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import math
N,D = map(int,input().split())
li = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        sum = 0
        for a,b in zip(li[i],li[j]):
            sum += (a-b)**2
        sum = math.sqrt(sum)
        if sum.is_integer():
            cnt += 1
print(cnt)

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

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<int> s[m];
    vector<int> p(m);
    for(int i = 0; i < m; i++){
        cin >> k.at(i);
        for(int j = 0; j < k.at(i); j++){
            int sin;
            cin >> sin;
            sin--;
            s[i].push_back(sin);
        }
    }
    for(int i = 0; i < m; i++) cin >> p.at(i);
    int nbit[n];
    int pown = 1 << n;
    int res = 0;
    for(int i = 0; i < pown; i++){
        for(int j = 0; j < n; j++){
            if(i&(1<<j)) nbit[j] = 1;
            else nbit[j] = 0;
        }
        bool can = true;
        for(int j = 0; j < m; j++){
            int c = 0;
            for(int l = 0; l < k.at(j); l++){
                if(nbit[s[j].at(l)] == 1) c++;
            }
            if(c%2 != p.at(j)) can = false;
        }
        if(can == true) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,x;cin>>N>>x;
  vector<long>A(N);for(long i=0;i<N;i++)cin>>A[i];
  long ans=0;
  
  for(int i=1;i<N;i++){
    long over=A[i-1]+A[i]-x;
    over*=(over>0);
    A[i-1]-=(over>A[i]?over-A[i]:0);
    A[i]=(over>A[i]?0:A[i]-over);
    ans+=over;
  }
  cout<<ans;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
flg = False
for i in range(m-1,n)[::-1]:
    if s[i] == t[-1] or s[i] == '?':
        cnt = 0
        while cnt < m:
            if s[i-cnt] == t[-(cnt+1)] or s[i-cnt] == '?':
                cnt += 1
                if cnt == m:
                    flg = True
            else:
                break

        if flg:
            break
if not flg:
    print('UNRESTORABLE')
    quit()
ans = ''
cnt2 = 0
for k in range(n):
    if i-cnt < k <= i:
        ans += t[cnt2]
        cnt2 += 1
    else:
        if s[k] == '?':
            ans += 'a'
        else:
            ans += s[k]
print(ans)

Measured memory_bytes: 38384
N, X = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

A.sort()

result = 0

for a in A:
    if X >= a:
        X -= a
        result += 1
    else:
        break

if result == N and X != 0:
    result -= 1

print(result)


Measured memory_bytes: 3060
mod = 10 ** 9 + 7
N, K = map(int, input().split())
ans, R, L = 1, N * (N + 1) // 2, N * (N + 1) // 2
for i in range(N + 1 - K):
    R, L = R - i, L - (N - i)
    ans = (ans + R - L + 1) % mod
print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define pb(v) push_back(v)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int ,int>;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int>> loc(3);
    set<int> rr, gg, bb;
    rep(i, n) {
        if (s[i]=='R') {loc[0].push_back(i); rr.insert(i);}
        if (s[i]=='G') {loc[1].push_back(i); gg.insert(i);}
        if (s[i]=='B') {loc[2].push_back(i); bb.insert(i);}
    }

    ll ans = 0;
    rep(i, n-2) FOR(j, i+1, n-1) {
        int r=0, g=0, b=0;
        if (s[i]=='R') r++;
        else if (s[i]=='G') g++;
        else if (s[i]=='B') b++;
        if (s[j]=='R') r++;
        else if (s[j]=='G') g++;
        else if (s[j]=='B') b++;

        if (r==2||g==2||b==2) continue;
        else {
            if (r&&g) {
                auto it = lower_bound(all(loc[2]), j+1);
                if (it!=loc[2].end()) ans += loc[2].end()-it;
                if (bb.count(j+(j-i))) ans--;
            } else if (r&&b) {
                auto it = lower_bound(all(loc[1]), j+1);
                if (it!=loc[1].end()) ans += loc[1].end()-it;
                if (gg.count(j+(j-i))) ans--;
            } else {
                auto it = lower_bound(all(loc[0]), j+1);
                if (it!=loc[0].end()) ans += loc[0].end()-it;
                if (rr.count(j+(j-i))) ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3832
#include <stdio.h>

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, T, A, i, minV = (int)(1e9 + 1), oldminV, maxP = 0, minVc, maxPc, ans;
	scanf("%d%d", &N, &T);
	for(i = 0; i < N; i++){
		scanf("%d", &A);
		if(A < minV){
			minV = A;
			minVc = 1;
		}
		else if(A == minV){
			minVc++;
		}
		else if(maxP < A - minV){
			maxP = A - minV;
			maxPc = 1;
			ans = 1;
			oldminV = minV;
		}
		else if(maxP == A - minV){
			if(minV == oldminV){
				minVc--;
				ans += min(minVc, maxPc);
			}
			else{
				oldminV = minV;
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A < C)
    {
        if (B < C)
            cout << 0 << endl;
        else
        {
            if (D > B)
                cout << B - C << endl;
            else
            {
                cout << D - C << endl;
            }
        }
    }
    else
    {
        if (D < A)
            cout << 0 << endl;
        else
        {
            if (B > D)
                cout << D - A << endl;
            else
            {
                cout << B - A << endl;
            }
        }
    }
}

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


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	point = 0;

		while ((point = parseNum()) != 0) {
			int[][]	map     = new int[point][point];
			int		route   = parseNum();
			for (int i = 0; i < point; i++) {
				for (int j = 0; j < point; j++) {
					map[i][j] = -1;
				}
			}

			for (int n = 0; n < route; n++) {
				int[]	dist = parseDist();
				map[dist[0]][dist[1]] = dist[2];
				map[dist[1]][dist[0]] = dist[2];
			}

			System.out.println(dijkstra(0, map));
		}
	}

	private static int dijkstra(int start, int[][] map) {
		int			res  = 0;
		int[]		cost = new int[map.length];
		boolean[]	used = new boolean[map.length];

		for (int n = 0; n < map.length; n++) {
			cost[n] = Integer.MAX_VALUE;
		}
		cost[start] = 0;

		while(true) {
			int	cur = -1;
			for (int n = 0; n < map.length; n++) {
				if (!used[n] && (cur == -1 || cost[n] < cost[cur])) {
					cur = n;
				}
			}

			if (cur == -1) {
				break;
			}
			used[cur]  = true;
			res       += cost[cur];

			for (int n = 0; n < map.length; n++) {
				if (map[n][cur] != -1) {
					cost[n] = Math.min(cost[n], map[n][cur]);
				}
			}
		}

		return res;
	}

	private static int[] parseDist() {
		int[]	dist  = null;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			String[]	split = strIn.split(",");
			dist    = new int[3];
			dist[0] = Integer.parseInt(split[0]); 
			dist[1] = Integer.parseInt(split[1]); 
			dist[2] = Integer.parseInt(split[2]) / 100 - 1; 
		}
		
		return dist;
	}

	private static int parseNum() {
		int		num   = 0;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			num = Integer.parseInt(strIn); 
		}
		
		return num;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

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

int main(void){
    int m,f,r;
    while(true){
       cin >> m >> f >> r;
       if ((m == -1) && (f == -1) && (r == -1)){
          break;
       }
       else if ((m + f < 30) || (m == -1) || (f == -1)){
          cout << "F" << endl;
       }
       else if (m + f >= 80){
          cout << "A" << endl;
       }
       else if ((m + f >= 65) && (m + f < 80)){
          cout << "B" << endl;
       }
       else if ((m + f >= 50) && (m + f < 65)){
          cout << "C" << endl;
       }
       else if ((m + f >= 30) && (m + f < 50)){
          if (r >= 50){
            cout << "C" << endl;
          }
          else {
            cout << "D" << endl;
          }
       }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int a, b, c;
	std::vector<int> cr(3, 0), ct(3, 0);
	for (int i = 0; i < n; ++i) {
		ct = cr;
		cin >> a >> b >> c;
		cr[0] = max(ct[1] + a, ct[2] + a);
		cr[1] = max(ct[0] + b, ct[2] + b);
		cr[2] = max(ct[1] + c, ct[0] + c);
	}
	cout << max(cr[0], max(cr[1], cr[2]));
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int x = in.nextInt();


		if (n == 1) {
			if (x == 1) {
				out.println("Yes");
				out.println(1);
			} else {
				out.println("No");
			}

			return;
		}

		if (n == 2) {
			if (x == 2) {
				out.println("Yes");
				for (int i=1; i<=3; i++) {
					out.println(i);
				}
			} else {
				out.println("No");
			}

			return;
		}

		if (x == 1 || x == 2*n-1) {
			out.println("No");
		} else {
			out.println("Yes");

			ArrayList<Integer> ans = new ArrayList<>();

			if (x == 2) {
				ans.add(2*n-1);
				ans.add(1);
				ans.add(2);
				ans.add(2*n-2);

				int m = n;
				int p = 3;
				for (int i=0; i<m-3; i++) {
					ans.add(0, p);
					p++;
				}

				while (p != 2*n-2) {
					ans.add(p);
					p++;
				}

			} else if (x == 2*n-2) {
				ans.add(1);
				ans.add(2*n-2);
				ans.add(2*n-1);
				ans.add(2);

				int m = n;
				int p = 3;
				for (int i=0; i<m-2; i++) {
					ans.add(0, p);
					p++;
				}
				while (p != 2*n-1) {
					ans.add(p);
					p++;
				}

			} else {
				ans.add(1);
				ans.add(x);
				ans.add(2*n-1);
				ans.add(2);

				int m = n;
				int p = 3;
				if (p == x) p++;
				for (int i=0; i<m-2; i++) {
					ans.add(0, p);
					p++;
					if (p == x) p++;
				}
				while (p != 2*n-1) {
					ans.add(p);
					p++;
					if (p == x) p++;
				}
			}


			for (int i=0; i<2*n-1; i++) {
				out.println(ans.get(i));
			}
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll inf = 1e15 + 10;
const ll maxn = 1e5 + 163;
const ll alf = 26;
const ll dlm = 1e9+7;
const ll del = 10979 ;
const int eps = 1e-7 ;
const int maxq = 1e2+132 ;

int n,m;
vector<int> top;
int t[maxn],mark[maxn] ;
vector<int> g[maxn] ;

int dfs(int v){
    mark[v] = 1;
    for(int j=0;j<g[v].size();j++){
        int u = g[v][j] ;
        if(mark[u])continue;
        dfs(u) ;
    }
    top.push_back(v) ;
}
int dp[maxn];
int deg_in[maxn ] ;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int v,u;
        cin>>v>>u ;
        g[v].push_back(u);
        deg_in[u] ++ ;

    }
    for(int i=1;i<=n;i++){
        if(mark[i])continue;
        dfs(i);
    }

    reverse(top.begin(),top.end()) ;
    int ans = 0 ;
    for(int i=0;i<top.size();i++){
        int v= top[i] ;
        ans = max(ans,dp[v]) ;
        for(int j=0;j<g[v].size();j++){
            int u = g[v][j] ;
            dp[u] = max(dp[v]+1 , dp[u] ) ;
         }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8824
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int max = 0, second = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(A[i] >= max) {
				second = max;
				max = A[i];
			}
			else if(A[i] > second)
				second = A[i];
		}
		for(int i = 0; i < N; i++)
			System.out.println(A[i] == max ? second : max);

	}

}

Measured memory_bytes: 84444
#include<bits/stdc++.h>
using namespace std;
int n,l,sum,ans=1001;
int a[101];
int main() {
	scanf("%d%d",&n,&l);
	for(int i=1; i<=n; i++) {
		a[i]=l+i-1;
	//	printf("%d\n",a[i]);
		sum+=a[i];
	}
	for(int i=1; i<=n; i++) {
		if(abs(a[i])<abs(ans))ans=a[i];
	}
	printf("%d",sum-ans);
}

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

using namespace std;

int main(){

int n, l;
cin >> n >> l;
vector<string> strlist(n);

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

sort(strlist.begin(), strlist.end());
string gattai="";
for(i=0;i<n;i++){
	gattai = gattai + strlist[i];
}
cout << gattai;


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define model l,mid,num<<1
#define moder mid+1,r,num<<1|1
#define bug(k)  cout<<"text :"<<t<<endl
#define lowbit(k) k&-k
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int M=1e5+5;
map <string,int> ma;
int n,x;
int arr[M];
int bits_gcd(int a,int b)
{
    return b==0?a:bits_gcd(b,a%b);
}
int main()
{
     int ans;
     int t;
     while(cin>>n>>x)
     {
         ans=INT_MAX;
         for(int i=1;i<=n;++i)
         {
             scanf("%d",&t);
             if(t>x)t^=x,x^=t,t^=x;
             arr[i]=x-t;
         }
         int ans=arr[1];
         for(int i=2;i<=n;++i)
         {
             ans=bits_gcd(ans,arr[i]);
         }
         cout<<ans<<endl;
     }
}

Measured memory_bytes: 640
public class Main {
    public static void main(String[] args) {
        var sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.close();
        int p = 998244353;
        var f = new long[k];
        f[0] = 1;
        for (int i = 1; i < k; i++) f[i] = (f[i - 1] * i) % p;
        var fi = new long[k];
        fi[k - 1] = inv(f[k - 1], p);
        for (int i = k - 1; i > 0; i--) fi[i - 1] = (fi[i] * i) % p;
        long ans = 1;
        for (int i = 1; i < k; i++) if ((ans <<= 1) >= p) ans -= p;
        for (int i = 0; i < Math.min(n - 1, k); i++) {
            ans -= (((f[k - 1] * fi[i]) % p) * fi[k - 1 - i]) % p;
        }
        System.out.println((ans %= p) < 0 ? ans + p : ans);
    }

    public static long inv(long a, long p) {
        long b = p;
        long u = 1, v = 0;
        while (b >= 1) {
            long t = a / b;
            a -= t * b;
            long tmp;
            tmp = a; a = b; b = tmp;
            u -= t * v;
            tmp = u; u = v; v = tmp;
        }
        u %= p;
        return u < 0 ? u + p : u;
    }
}

Measured memory_bytes: 43532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int n = a/b;
    int m = a%b;
    if(m==0)
        cout<<"0"<<endl;
    else 
        cout<<"1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
#include<time.h>
#include<vector>
#include<set>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
using  namespace std;
stack<int>m;
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d\n",(1800*m+100*n)*1<<m);
    return 0;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n, m,res=0;
	cin >> n;
	map<string, int> mp;
	REP(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	REP(i, m) {
		string s;
		cin >> s;
		mp[s]--;
	}
	FOREACH(x, mp) {
		res = max(res, x.second);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		while(true){
			String w = sc.nextLine();
		//break	
			if(w.equals("-")){
				break;
			}
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0;i<m;i++){
				int h = Integer.parseInt(sc.nextLine());
				String store1 = w.substring(0,h);
				String store2 = w.substring(h);
				w=store2+store1;
			}
			System.out.println(w);
		}
	}
}

Measured memory_bytes: 26476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=0;
const ll mod=1e9+7;
ll ksm(ll a,ll n)
{
    a%=mod;
    ll ans=1,base=a;
    while(n)
    {
        if(n&1)
            ans=(ans*base)%mod;
        base=(base*base)%mod;
        n>>=1;
    }
    return ans%mod;
}
ll fa(int x)
{
    ll sum=1;
    for(int i=2;i<=x;i++)
        sum=(sum*i)%mod;
    return sum;
}
ll C(ll a,ll b)
{
    return fa(b)*ksm(fa(a)*fa(b-a),mod-2)%mod;
}
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    int a=(2*y-x)/3;
    int b=(2*x-y)/3;
    if((x+y)%3==0&&x*2>=y&&y*2>=x)
        printf("%lld\n",C(a,a+b));
    else printf("0\n");
    return 0;
}


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

using namespace std;

const int MAXN = 505;
const int MOD = 1000000007;

int add(int x, int y) { return ((x += y) >= MOD) ? x - MOD : x; }
int sub(int x, int y) { return ((x -= y) < 0) ? x + MOD : x; }
int mul(int x, int y) { return (long long) x * y % MOD; }

int N, X;
int cnt[MAXN];
int C[MAXN][MAXN];
int pw[MAXN][MAXN];
int dp[MAXN][MAXN];
int ndp[MAXN][MAXN];

int main() {
   ios_base::sync_with_stdio(false);
   for (int i = 0; i < MAXN; ++i) {
      pw[i][0] = 1;
      for (int j = 1; j < MAXN; ++j) {
         pw[i][j] = mul(pw[i][j - 1], i);
      }
   }
   for (int i = 0; i < MAXN; ++i) {
      C[i][0] = 1;
      for (int j = 1; j <= i; ++j) {
         C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
      }
   }
   cin >> N >> X;
   for (int i = 0; i < N; ++i) {
      int L;
      cin >> L;
      ++cnt[L];
   }
   dp[0][0] = 1;
   for (int len = X; len > 0; --len) {
      for (int numSeg = 0; numSeg <= X; ++numSeg) {
         for (int totLen = 0; totLen <= X; ++totLen) {
            if (dp[numSeg][totLen] == 0) continue;
            for (int addSeg = 0; totLen + addSeg * len <= X; ++addSeg) {
               int newSeg = numSeg + addSeg;
               int newLen = totLen + addSeg * len;
               ndp[newSeg][newLen] = add(ndp[newSeg][newLen], mul(dp[numSeg][totLen], C[newSeg][numSeg]));
            }
         }
      }
      for (int numSeg = 0; numSeg <= X; ++numSeg) {
         for (int totLen = 0; totLen <= X; ++totLen) {
            dp[numSeg][totLen] = ndp[numSeg][totLen];
            ndp[numSeg][totLen] = 0;
         }
      }
      for (int numSeg = 0; numSeg <= X; ++numSeg) {
         for (int totLen = 0; totLen <= X; ++totLen) {
            if (dp[numSeg][totLen]) {
               dp[numSeg][totLen] = mul(dp[numSeg][totLen], pw[totLen - numSeg * (len - 1)][cnt[len]]);
            }
         }
      }
   }
   int ans = 0;
   for (int numSeg = 0; numSeg <= X; ++numSeg) {
      for (int totLen = 0; totLen <= X; ++totLen) {
         if (dp[numSeg][totLen]) {
            int emptySpace = X - totLen;
            if (emptySpace < numSeg - 1) continue;
            int curValue = mul(dp[numSeg][totLen], C[emptySpace + 1][numSeg]);
            if (emptySpace & 1) {
               ans = sub(ans, curValue);
            } else {
               ans = add(ans, curValue);
            }
         }
      }
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 4352