akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    set<pair<int, int>> nums;
    int ans = 0;
    for(size_t i = 0; i < as.size(); i++){
        auto a = as[i];
        auto ite = nums.lower_bound(pair<int, int>(a, -1));
        if(ite == nums.begin()){
            ans++;
        }else{
            ite--;
            nums.erase(ite);
        }
        nums.emplace(a, i);
        // auto ite = lower_bound(nums.begin(), nums.end(), pair<int, int>(a, -1));
    }
    cout << ans << '\n';
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    v1 b(n-1);
    rep(i, n-1){
        cin >> b[i];
    }
    int ans = b[0];
    for(int i = 1; i<n-1;i++){
        ans += min(b[i], b[i-1]);
    }
    if(n >=2) ans += b[n-2];
    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> v = new ArrayList<>();
        for(int i = 0; i < N; i++){
            v.add(sc.nextInt());
        }
        Collections.sort(v);
        double result = 0;
        double prev = v.get(0);
        for(int i = 1; i < N; i++){
            result = ((double)prev + (double)v.get(i)) / 2.0;
            prev = result;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e9
int const MaxSize = 1e5;
LL N, A, B;
LL h[MaxSize];

bool good(LL times) {
	LL remaining = times;

	//cout << times << endl;

	LP(i, 0, N)
	{
		LL afterB = (LL) h[i] - times * B;

		if (afterB > 0) {
			LL aTimes = afterB / (A - B);

			if (afterB % (A - B))
				aTimes++;

			remaining -= aTimes;

			if (remaining < 0)
				return false;
		}
	}

	return true;
}

LL bs(LL l, LL h) {
	if (l == h)
		return l;
	LL mid = (l + h) / 2L;

	if (good(mid)) {
		return bs(l, mid);
	} else {
		return bs(mid + 1, h);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	cin >> N >> A >> B;

	LP(i, 0, N)
		cin >> h[i];

	LL pos = 1e9;
	LL mt = (pos / B) + 1L;
	cout << bs(1, mt) << endl;

	return 0;
}


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

using namespace std;

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

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll mod=1000000007;

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			s=s*a%mod;
		a=a*a%mod;
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

ll fact[300000];

ll Way(int h,int w){
	return fact[h+w]*modInv(fact[h])%mod*modInv(fact[w])%mod;
}

int main(){
	fact[0]=1;
	FOR(i,1,300000)
		fact[i]=fact[i-1]*i%mod;
	int h=read(),w=read(),a=read(),b=read();
	ll ans=0;
	FOR(i,b,w)
		ans=(ans+Way(h-a-1,i)*Way(a-1,w-i-1))%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;
string S;

int main() {
	cin >> S;
	if (S.substr(0, 4) >= "2019" && S.substr(5, 2) > "04") {
		cout << "TBD" << endl;
	}
	else
	{
		cout << "Heisei" << endl;
	}

	return 0;
}

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

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

  if(b=='A') cout << 'T' << endl;
  if(b=='C') cout << 'G' << endl;
  if(b=='G') cout << 'C' << endl;
  if(b=='T') cout << 'A' << endl;
}

Measured memory_bytes: 256
/*
	************	************    ************	***      ***	************	***               ***
	************	************    ************	****     ***	************	 ***             ***
	***      ***	***      ***    ***      ***	*****    ***	***      ***	  ***           ***
	***      ***	***      ***    ***      ***	******   ***	***      ***	   ***         ***
	************	************    ************	*** ***  ***	************	    ***       ***
	************	************    ************	***  *** ***	************	     ***     ***
	***				***   ***       ***      ***	***   ******	***      ***	      ***   ***
	***				***    ***      ***      ***	***    *****	***      ***	       *** ***
	***				***     ***     ***      ***	***     ****	***      ***	        *****
	***				***      ***    ***      ***	***      ***	***      ***	         ***
*/

#define named(blockname) goto blockname; \
                         blockname##_skip: if (0) \
                         blockname:

#define break(blockname) goto blockname##_skip
// #include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define readarr(a,n) for (int i=0; i<n; i++) {cin>>a[i];}
#define printarr(a,n) for (int i=0; i<n; i++) {cout<<a[i]<<' ';}
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vint vector <int>
#define pb push_back
#define pf push_front
#define endl "\n"

signed main() {
	
	fast ;
	
	ll q ;
	// cin >> q ;
	q = 1 ;
	while(q--)
	{
		ll a,b,c,d ;
		cin>>a>>b>>c>>d ;
		ll n = c/b ;
		if (c%b>0)
			n++ ;
		ll m = a/d ;
		if (a%d>0)
			m++ ;
		if (n<=m)
			cout << "Yes" ;
		else
		cout << "No" ;
	}
	
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import java.io.*;
//fastest
class Main{
  static List dummy;

  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    StringBuilder builder = new StringBuilder();
    init();
    int i;
    for(i = n ; i>0; i--){
      String s = br.readLine();
      if(s.charAt(0)=='i'){
        insert(Integer.parseInt(s.substring(7)));
      }else if(s.charAt(6)=='F'){
        deleteFirst();
      }else if(s.charAt(6)=='L'){
        deleteLast();
      }else{
        delete(Integer.parseInt(s.substring(7)));
      }
    }
    List list = dummy.next;
    if(list != dummy){
      // System.out.printf("%d",list.data);
      builder.append(list.data);
      list = list.next;
    }
    while(list!=dummy){
      // System.out.printf(" %d",list.data);
      builder.append(' ').append(list.data);
      list = list.next;
    }
    System.out.println(builder);
    // Print_list();
  }
  static void init(){
    dummy = new List();
    dummy.next=dummy;
    dummy.previous=dummy;
  }
  //insert
  static void insert(int n){
    List list = new List(n);
    list.next=dummy.next;
    dummy.next.previous=list;
    dummy.next=list;
    list.previous=dummy;
  }
  //ノードの削除メソッド
  static void deleteNode(List delete){
    if( delete == dummy)return;
    delete.previous.next=delete.next;
    delete.next.previous=delete.previous;
  }
  //指定したノードの削除
  static void delete(int n){
    deleteNode(listSearch(n));
  }
  //firstnode削除
  static void deleteFirst(){
    deleteNode(dummy.next);
  }
  //lastnode削除
  static void deleteLast(){
    deleteNode(dummy.previous);
  }
  //keyを使ってノードを探索
  static List listSearch(int n){
    List cur = dummy.next;
    while(cur.data!=n && cur!=dummy){
      cur = cur.next;
    }
    return cur;
  }
  //printメソッド
  // static void Print_list(){
  //   List list = dummy.next;
  //   if(list != dummy){
  //     // System.out.printf("%d",list.data);
  //     builder.append(list.data);
  //     list = list.next;
  //   }
  //   while(list!=dummy){
  //     // System.out.printf(" %d",list.data);
  //     builder.append(' ').append(list.data);
  //     list = list.next;
  //   }
  //   System.out.println(builder);
  //   // System.out.println();
  // }
}
//listの構造体的役割
class List{
  public int data;
  public List next;
  public List previous;

  public List(){}
    public List(int n){
      this.data = n;
    }
  }



Measured memory_bytes: 126108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }

vll A[200000];
int main() {
    ll n,m; cin>>n>>m;

    ll h[n];
    rep(i,0,n){
        cin>>h[i];
    } 
    
    ll a[m],b[m];
    rep(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        A[a[i]].push_back(h[b[i]]);
        A[b[i]].push_back(h[a[i]]);
    } 
    rep(i,0,n){
        A[i].push_back(-1);
    }
    rep(i,0,n){
        sort(A[i].begin(),A[i].end());
    }
    ll ans=0;
    rep(i,0,n){
        if((A[i][A[i].size()-1]<h[i])) ans++;
    }
    cout<<ans<<endl;
/*
    rep(i,0,n){
        rep(j,0,A[i].size()){
            cout<<A[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    */

    


}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
	add utility Algorithm
*/

set<int> st[26];
int type[30000];
// type 2
int l[30000];
int r[30000];
// type 1
int idx[30000];
char c[30000];

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;

    REPinit(i, 0, Q) {
        cin >> type[i];
        if (type[i] == 1) {
            cin >> idx[i] >> c[i];
        }
        else {
            cin >> l[i] >> r[i];
        }
    }

    string initial = S;
    REPinit(i, 0, 26) {
        st[i].clear();
        st[i].insert(N);
    }

    REPinit(i, 0, N) {
        st[(int)(S[i] - 'a')].insert(i);
    }

    REPinit(i, 0, Q) {
        if (type[i] == 1) {
            st[(int)(S[idx[i] - 1] - 'a')].erase(idx[i] - 1);
            S[idx[i] - 1] = c[i];
            st[(int)(S[idx[i] - 1] - 'a')].insert(idx[i] - 1);
        }
        else {
            int ANS = 0;
            REPinit(j, 0, 26) {
                auto itr = st[j].lower_bound(l[i] - 1);
                if (*itr <= r[i] - 1) ANS++;
            }
            cout << ANS << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 25116
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	vector<int>f(n);
	vector<bool>flag(n,false);
	int ans = 0;
	rep(i, n) {
		while (h[i] > 0) {
			int r;
			for (r = i + 1;r < n;++r) {
				if (h[r] == 0)break;
			}
			for (int x = i;x < r;++x)--h[x];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/* **********************************JAI SAI RAM ************************************* */
// Help in Codeforces  Round Div2 of Devil.
//Well this is just a mere fun.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[200001];
void  solve()
{
  ll i,j,l,k,m,n,o,p,q,r,t,x,y;
  cin>>n>>k;
  for(i=1;i<=n;i++)
  {
      cin>>a[i];
      if(i>=k+1)
      {
          if(a[i]>a[i-k])
          {
              cout<<"Yes\n";
          }
          else 
          {
              cout<<"No\n";
          }
      }
  }

  return;
  if(x>=400&&x<=599)
  cout<<"8\n";
  if(x>=600&&x<=799)
  cout<<"7\n";
  if(x>=800&&x<=999)
  cout<<"6\n";
  if(x>=1000&&x<=1199)
  cout<<"5\n";
  if(x>=1200&&x<=1399)
  cout<<"4\n";
  if(x>=1400&&x<=1599)
  cout<<"3\n";
  if(x>=1600&&x<=1799)
  cout<<"2\n";
  if(x>=1800&&x<=1999)
  cout<<"1\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,k;
    n=1;
     t=n;
    while(t--)
    {
       solve();
       n++;
    }
    return 0;
}
    


Measured memory_bytes: 5172
N,K=map(int,input().split())
S=input()
S='.'+S
S=S+'.'
P=0
for i in range(N):
  if S[i+1]=='L':
    if S[i]=='L':
      P+=1
  else:
    if S[i+2]=='R':
      P+=1
print(min(N-1,P+K*2))

Measured memory_bytes: 67164
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma comment(linker, "/stack:256000000")
#pragma GCC optimize("O3")
#define ll long long
#define str string
#define rtn return
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define db long double
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define pll pair <ll, ll>
#define vi vector<ll>
#define vpll vector<pll>
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define loop1(i, n) for (int i=1;i<=n;++i)
#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

template<class T> void remin(T &a, T b) {a = min(a, b);}
template<class T> void remax(T &a, T b) {a = max(a, b);}
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

db dp[3005][3005], p[3000], rec[3000];
bool sol[3005][3005];
int n;

db solve(int i, int head) {
  if (head < 0) rtn 0;
  if (i == n) {
    if (head == 0) rtn 1;
    else rtn 0;
  }
  if (sol[i][head]) rtn dp[i][head];
  sol[i][head] = 1;
  dp[i][head] = 0;
  dp[i][head] += p[i] * solve(i + 1, head - 1);
  dp[i][head] += (1 - p[i]) * solve(i + 1, head);
  rtn dp[i][head];
}

int main() {
  FAST_IO;
  db ans = 0;
  cin >> n;
  rep(i, n) cin >> p[i];
  loop1 (i, n) {
    int tails = n - i;
    if (i > tails) {
      ans += solve(0, i);
    }
  }
  cout << fixed << setprecision(12) << ans;
  rtn 0;
}


Measured memory_bytes: 150272
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int a[110][110],h,w;
bool vis[110][110];
bool t[110][110];
int dx[6],dy[6]={-1,-1,0,0,1,1};
void SetDx(int y){
	int tmp1[6]={-1,0,-1,1,-1,0};
	int tmp2[6]={0,1,-1,1,0,1};
	if(y%2==0)lol(i,6)dx[i]=tmp1[i];
	if(y%2==1)lol(i,6)dx[i]=tmp2[i];
	return;
}
void DFS(int y,int x){
	vis[y][x]=true;
	SetDx(y);
	int ddx[6];
	lol(i,6)ddx[i]=dx[i];
	lol(i,6){
		int xx=x+ddx[i],yy=y+dy[i];
		if(xx<0||xx==w||yy<0||yy==h)continue;
		if(!vis[yy][xx])DFS(yy,xx);
	}
}
int main(){
	cin>>w>>h;h+=2,w+=2;
	lol(i,h)lol(j,w)a[i][j]=0,vis[i][j]=0;
	lol(i,h-2)lol(j,w-2){
		cin>>a[i+1][j+1];
		vis[i+1][j+1]=a[i+1][j+1];
	}
	DFS(0,0);
	lol(i,h)lol(j,w){
		t[i][j]=(!vis[i][j])|a[i][j];
	}
	int ans=0;
	lol(i,h)lol(j,w){
		if(!t[i][j])continue;
		SetDx(i);
		lol(k,6){
			int xx=j+dx[k],yy=i+dy[k];
			if(xx<0||xx==w||yy<0||yy==h)continue;
			if(!t[yy][xx])ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> ans;
    int tot = 0;
    int m;
    rep(i, n + 1) {
        tot += i;
        ans.push_back(i);
        if(tot >= n) {
            m = tot - n;
            break;
        }
    }
    rep(i, ans.size()) {
        if(i == 0 || i == m) continue;
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
ls = [0] * 1001001
for x in range(1, 101):
	for y in range(1, 101):
		for z in range(1, 101):
			ls[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
for i in range(1, N+1):
	print(ls[i])
	

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 16964
#include<bits/stdc++.h>
using namespace std;
int main(){
  int b,c='Z',d;
  d='Z'-'A'+1;
  char a[100000],e;
  e=a[100];
  cin>>b>>a;
  for(int i=0;i<10000;i++){
    if(a[i]==e)
      break;
    a[i]+=b;
    
    if(a[i]>c)
      a[i]-=d;
    
  }
  cout<<a<<endl;
  return(0);
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c;
	cin>>n>>c;
	long long int w[n+1],v[n+1];
	memset(w,0,sizeof(w));
	memset(v,0,sizeof(v));
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	long long int dp[n+1][c+1];
	memset(dp,0,sizeof(dp));
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=c;j++){
			if(w[i]<=j){
				dp[i][j]=max((v[i]+dp[i-1][j-w[i]]),(dp[i-1][j]));
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][c];
	return 0;
}

Measured memory_bytes: 79104
(defun calc (B C)
  (let ((result 0)
        (tmp (list nil)))
    (dolist (x B)
      (push (* x (read)) tmp))
    (setq tmp (cdr (reverse tmp)))
    (dolist (x tmp)
      (setq result (+ result x)))
    (+ result C)))

(defun main ()
  (let ((N (read))
        (M (read))
        (C (read))
        (B (list nil)))
    (dotimes (x M)
      (push (read) B))
    (setq B (cdr (reverse B)))
    (let ((count 0))
      (dotimes (x N)
        (let ((tmp (calc B C)))
          (when (> tmp 0)
            (incf count))))
      (print count))))

(main)

Measured memory_bytes: 12900
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;
using Graph = vector<vector<int>>;

int N, M, K;
Graph G, F;
vector<bool> seen;
map<int, int> v_to_comp, graph_size, fb_count;
queue<int> temp_v;
int vt_count;

void dfs(const Graph &graph, int v) {
    // 探索済みのチェックを入れる
    seen[v] = true;
    // 探索したvを記録しておく
    temp_v.push(v);

    // vから行ける各頂点について
    for (auto e : graph[v]) {
        if (seen[e]) {
            continue; // 探索済みなら飛ばす
        }

        // 再帰的に探索
        dfs(graph, e);
    }

    vt_count++; // 帰りがけに通った個数を数えていく
}

int main() {
    // 入力
    cin >> N >> M >> K;

    G.assign(N, vector<int>());
    F.assign(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);

        F[a].push_back(b);
        F[b].push_back(a);
    }
    for (int i = 0; i < K; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    // DFSして各連結要素の頂点数と、各頂点がどの連結成分に属するか求める
    int comp = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; v++) {
        if (seen[v]) {
            continue;
        }

        vt_count = 0; //頂点数は1回DFSの探索したときに数えられる（帰りがけ数）から、別の連結成分に移った時に数えなおす
        dfs(F, v);

        while (!temp_v.empty()) {
            v_to_comp.insert({temp_v.front(), comp});
            graph_size.insert({temp_v.front(), vt_count});

            temp_v.pop();
        }
        comp++;
    }

    // 友達ブロック関係の個数を各頂点について数える
    for (int v = 0; v < N; v++) {
        for (auto e : G[v]) {
            if (v_to_comp[v] == v_to_comp[e]) {
                fb_count[v]++; // 同じ友達関係の連結成分にいれば++
            }
        }
    }

    // 友達関係のグラフを探索
    seen.assign(N, false);
    for (int v = 0; v < N; v++) {
        if (seen[v]) {
            continue;
        }

        dfs(F, v);
    }

    // 出力
    for (int v = 0; v < N - 1; v++) {
        cout << graph_size[v] - fb_count[v] - 1 << ' ';
    }
    cout << graph_size[N - 1] - fb_count[N - 1] - 1 << endl;
}


Measured memory_bytes: 28672
import java.util.Scanner;

// MainT1P2018D
public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			final int N = in.nextInt();
			int d = 8*N + 1;
			int dr = (int)Math.sqrt(d);
			if (dr * dr != d) {
				System.out.println("No");
				return;
			}

			final int k = (1 + dr) / 2;

			final int[] startIdx = new int[k - 1];
			{
				int idx = 1;
				for (int i = 0; i < k - 1; ++i) {
					startIdx[i] = idx;
					idx += i + 1;
				}
			}

			System.out.println("Yes");
			System.out.println(k);
			{
				System.out.print(k - 1);
				for (int i = 0; i < k - 1; ++i) {
					System.out.printf(" %d", startIdx[i] + i);
				}
				System.out.println();
			}
			for (int i = 0; i < k - 1; ++i) {
				System.out.print(k - 1);
				for (int j = 0; j < i; ++j) {
					System.out.printf(" %d", startIdx[i] + j);
				}
				for (int j = i; j < k - 1; ++j) {
					System.out.printf(" %d", startIdx[j] + i);
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 60712
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
//#define F(i,n) for(ll i=0;i<n;i++)
//#define MOD 1000000007
#define MAX 200005
#define LM LLONG_MAX
#define sz size()
//#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
		const ll N=1e5;
		ll i,j,k;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
/* void DFS(ll x,ll col)
{
    cnt[col]++;
    visited[x]=col+1;
    
    for(auto p:v[x])
    {
        if(visited[p]==0)
        {
            DFS(p,col^1);
        }
        else if(visited[x]==visited[p])
        {
            ok=true;
        }
        
    }
}*/
 
void solve()
{

	ll n;
	cin>>n;
	string s;
	map<string,ll>m;
	for(ll i=0;i<n;i++)
	{
		cin>>s;
		m[s]++;
	}
	cout<<m.sz;
	
}

int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	vector<tuple<string, int, int>> a(n);
	FOR(i, 0, n - 1) {
		cin >> get<0>(a[i]);
		int point;
		cin >> point;
		get<1>(a[i]) = point * -1;
		get<2>(a[i]) = i + 1;
	}
	sort(ALL(a));
	FOR(i, 0, n - 1) {
		pv(get<2>(a[i]));
	}
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int num[100010];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>num[i];
	}
	sort(num,num+n);
	int a=num[n-1],b,co=0,minn=0x3f3f3f3f;
	b=a/2+(a%2==0?0:1);
	for(int i=0;i<=n;i++)
	{
		if(minn>abs(b-num[i]))
		{
			co=i;
			minn=abs(b-num[i]);
		}
	}
	cout<<a<<' '<<num[co];
	return 0;
}


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

int main() {
  int n,m,x; cin >> n >> m >> x;
  vector<int> fee(n + 1, 0);
  
 for(int i = 0; i < m; i++) {
    int temp; cin >> temp;
   fee.at(temp)++;
 }
  
 int ans = 0;
 for(int i = x; i > 0; i--){
  ans += fee.at(i); 
 }
  
  int ans2 = 0;
 for(int i = x; i < n; i++){
  ans2 += fee.at(i); 
 }
  
  if(ans < ans2) {
    cout << ans << endl;
  } else {
    cout << ans2 << endl;
  }
  
  return 0; 
}
  

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

const int INF =1001001001;
const ll BIG = 1000000007;

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n);//距離ごとの答えを持つ数列
    rep(sv,n){
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d){
            if(dist[v]!=INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v-1>=0) push(v-1, d+1);
            if(v+1<n) push (v+1, d+1);
            if(v==x) push(y, d+1);
            if(v==y) push(x,d+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i]/=2;
    for(int i=1;i<=n-1;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, mx = 0; cin >> n;
	map<string, int> m;
	rep(i, n){
		string s; cin >> s;
		mx = max(mx, ++m[s]);
	}
	for(auto i : m) if(i.second == mx) cout << i.first << endl;
	return 0;
}

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

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

    int k;
    cin >> k;
    int a = 7;
    for (int i = 1; i <= k; i++) {
        if (a % k == 0) {
            cout << i << endl;
            return 0;
        }
        a = a * 10 + 7;
        a %= k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3648
//package atcoder_edu_dp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
/*
State: dp[i][j] (ith day and jth activity) = mat[i][j]+dp[i-1][(j-1)==0?3:(j-1)] dp[i-1][(j+1>3)?1:(j+1)]
 */
    public static void main(String[] args)
    {
        FastReader sc=new FastReader();
        int n = sc.nextInt();
        int[][] mat = new int[n][3];
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                mat[i][j] = sc.nextInt();
            }
        }
        int[][] dp = new int[n+1][3];

        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++){
                dp[i][j] = mat[i-1][j] + Math.max(dp[i-1][(j-1<0)?2:(j-1)],dp[i-1][(j+1>2)?0:(j+1)]);
            }
        }
        System.out.println(Math.max(dp[n][0],Math.max(dp[n][1],dp[n][2])));

    }
}

Measured memory_bytes: 48424
#include <iostream>
#include <vector>
#include <climits>
#include <numeric>
#include <algorithm>
#include <utility>
using namespace std;

using LL = long long;

int main() {
    int N;
    cin >> N;
    
    vector<int> ABC(3);
    for(int i = 0; i < 3; i++) cin >> ABC[i];
    
    vector<int> l(N);
    for(int i = 0; i < N; i++) cin >> l[i];
    
    int ans = INT_MAX;
    
    for(int bit = 0; bit < (1 << (2 * N)); bit++) {
        vector<vector<int>> d(4, vector<int>());
        for(int i = 0; i < N; i++) d[(bit >> (2 * i) & 3)].push_back(l[i]);
        bool good = true;
        for(int i = 0; i < 3; i++) if(d[i].size() == 0) good = false;
        if(!good) continue;
        vector<int> cost(3, 0);
        for(int i = 0; i < 3; i++) {
            cost[i] += 10 * (d[i].size() - 1);
            cost[i] += abs(ABC[i] - accumulate(d[i].begin(), d[i].end(), 0));
        }
        ans = min(ans, accumulate(cost.begin(), cost.end(), 0));
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _fastio_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

struct factorization {
private :
	std::vector<int> table;
 
public :
	factorization(std::size_t n) : table(n + 2, 0) {
		for (int i = 2; i <= n; i++) if (table[i] == 0) {
			for (int j = i; j <= n; j += i) {
				if (table[j] == 0) table[j] = i;
			}
		}
	}
 
	std::map<int, int> operator() (int x) {
		std::map<int, int> fact;
		while (x > 1) {
			const int &factor = table[x];
			fact[factor]++; x /= factor;
		}
		return fact;
	}
 
};

constexpr std::size_t MAX = 1'000'005;

bool issc (const std::vector<int> &a) {
	int g = a[0];
	for (std::size_t i = 1; i < a.size(); i++) {
		g = std::gcd(a[i], g);
	}
	return (g == 1);
}

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	factorization fact(MAX);
	
	bool pc = true;
	std::set<int> st;
	for (int i = 0; i < n; i++) {
		std::map<int, int> mp = fact(a[i]);
		for (const auto &p : mp) {
			if (st.count(p.first)) pc = false;
		}
		for (const auto &p : mp) {
			st.emplace(p.first);
		}
	}
	
	if (pc) {
		std::cout << "pairwise coprime" << '\n';
	} else if (issc(a)) {
		std::cout << "setwise coprime" << '\n';
	} else {
		std::cout << "not coprime" << '\n';
	}
	
	return 0;
}

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

int a[101][101],b[51][51],n,m;

void rotate() {
  int c[m][m];
  for(int i=0; i<m; i++) {
    for(int j=0; j<m; j++) c[j][m-i-1]=b[i][j];
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<m; j++) b[i][j]=c[i][j];
  }
}

int main() {
  while(cin >> n >> m && n) {
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) cin >> a[i][j];
    }
    for(int i=0; i<m; i++) {
      for(int j=0; j<m; j++) cin >> b[i][j];
    }
    for(int i=0; i<n-m+1; i++) {
      for(int j=0; j<n-m+1; j++) {
	for(int k=0; k<4; k++) {
	  rotate();
	  bool ok=1;
	  int xx=-1,yy=-1;
	  for(int x=0; x<m; x++) {
	    for(int y=0; y<m; y++) {
	      if(b[x][y]==-1) continue;
	      if(a[i+x][j+y]!=b[x][y]) ok=0;
	      if(xx==-1) xx=i+x+1,yy=j+y+1;
	    }
	  }
	  if(ok) {
	    cout << yy << " " << xx << endl;
	    goto end;
	  }
	}
      }
    }
    cout << "NA" << endl;
  end:;
  }
  return 0;
}


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

// #define NDEBUG
#include<assert.h>
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  if(x >= 400 && x <= 599) puts("8");
  if(x >= 600 && x <= 799) puts("7");
  if(x >= 800 && x <= 999) puts("6");
  if(x >= 1000 && x <= 1199) puts("5");
  if(x >= 1200 && x <= 1399) puts("4");
  if(x >= 1400 && x <= 1599) puts("3");
  if(x >= 1600 && x <= 1799) puts("2");
  if(x >= 1800 && x <= 1999) puts("1");
  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
  // freopen("input.txt","r",stdin);
    FastIO;

    string s;
    while(cin>>s){
        int n = s.size();
        lli ans = 1 + n*1LL*(n-1)/2;
        vector<int>cnt(30,0);
        for(int i=0; i<n; i++){
            cnt[s[i]-'a']++;
        }
        for(int i=0; i<26; i++) ans -= cnt[i]*1LL*(cnt[i]-1)/2;

        cout<<ans<<endl;
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, sum = 0; sc(n)
    int s[n];
    for (int i = 0; i < n; i++) sc(s[i])
    for (int i = 0; i < n; i++) sum += s[i];
    if (sum % 10 == 0){
        sort(s, s + n);
        for (int i = 0; i < n; i++){
            if (s[i] % 10 != 0){
                sum -= s[i];
                break;
            }
        }
        if (sum % 10 == 0) sum = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt(), b = fs.nextInt(), c = fs.nextInt();
        String ans = "NO";
        for (int i = a; i <= 1000000; i += a) {
            if (i % b == c) {
                ans = "YES";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21076
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

#define MAX_N (10010)

bool prime[MAX_N + 1];

int main()
{
    vector<int> P;
    memset( prime, true, MAX_N + 1 );

    // ??¨??????????????????????????????
    for ( int i = 2; i <= MAX_N; i++ ) {
	if ( prime[i] ) {
	    P.push_back( i );	// ?´???°
	    int j = i * 2;
	    while ( j <= MAX_N ) {
		prime[j] = false;
		j += i;
	    }
	}
    }

    int n;
    int ans = 0;

    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
	int d;
	bool check = true;
	scanf("%d", &d);

	for ( int j = 0; j < P.size(); j++ ) {
	    if ( (P[j] * P[j]) > d ) {

		break;
	    }
	    if ( d % P[j] == 0 ) { // ???????????????
		check = false;
		break;
	    }
	}
	if ( check ) {
	    ans++;
	}
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1076
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll a;cin>>a;
  cout<<(a-30)/2<<endl;
  return 0;
}



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

int main (){
  int N,x;
  cin >> N >> x ;
  int S[101];
  for(int i=0;i<N;i++){
  cin >> S[i];
  }
  sort(S,S+N);
  int count = 0;
  for(int i=0;i<N;i++){
    x-=S[i];
    if(x<0){
      break;
    }
    
      count++;
    
  }
  if (x > 0){
    count--;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

before = [[-1] * 10]

for i in range(n):
  c = s[i]
  num = int(c)
  hoge = before[-1][::]
  hoge[num] = i
  before.append(hoge)

ans = 0
for i in range(10):
  now = before[-1][i]
  if now == -1:
    continue
  for j in range(10):
    now2 = before[now][j]
    if now2 == -1:
      continue
    for k in range(10):
      now3 = before[now2][k]
      if now3 == -1:
        continue
      ans += 1
print(ans)


Measured memory_bytes: 8932
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vi c;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      c.PB(tmp);
    }
    sort(c.begin(), c.end());
    int ab = INF;
    for (int i = 1; i < n; i++) {
      if (abs(c[i]-c[i-1]) < ab) {
        ab = abs(c[i]-c[i-1]);
      }
    }
    cout << ab << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define N 10000
 
int main(){
  unsigned short *A, *B;
 
  int C[MAX+1];
  int n, i, j;
  scanf("%d", &n);
 
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
 
  for ( i = 0; i <= MAX; i++ ) C[i] = 0;
 
  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }
 
  for ( i = 1; i <= MAX; i++ ) C[i] = C[i] + C[i - 1];
 
  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
 
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
 
  return 0;
}

Measured memory_bytes: 16236
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String str[] = {"SUN","7","MON","6","TUE","5","WED","4",
                "THU","3","FRI","2","SAT","1"};
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals(s)){
                System.out.println(str[i+1]);
            }
        }
    }
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// http://arc081.contest.atcoder.jp/tasks/arc081_a
/// </summary>
namespace _170821CS_MakeRectangle_Console {
    class Program {
        static void Main(string[] args) {
            //int[] map = { 3, 1, 2, 4, 2, 1 };
            //int[] map = { 1, 2, 3, 4 };
            //int[] map = { 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6 };
            //int[] map = Enumerable.Range(0, 100000).Select(x => x / 2).ToArray();
            int n = Convert.ToInt32(Console.ReadLine());
            string input = Console.ReadLine();
            var map = input.Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            long ans = Solve(map);
            Console.WriteLine(ans);
        }
        private static long Solve(int[] map) {
            var list = map.ToList();
            list.Sort();
            int p = 0;
            long[] ans = { 0, 0 };
            for(int i=list.Count - 1; i > 0; i--) {
                if(list[i] == list[i - 1]) {
                    ans[p++] = list[i--];
                }
                if (p == 2) break;
            }
            return ans[0] * ans[1];
        }
    }
}


Measured memory_bytes: 20192