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

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
  visited[v] = true;
  for(int v2 = 0; v2 < n; v2++){
    if(graph[v][v2] == false) continue;
    if(visited[v2] == true) continue;
    dfs(v2);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  for(int i = 0; i < m; i++){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    for(int j = 0; j < n; j++)
      visited[j] = false;
    dfs(0);
    bool bridge = false;
    for(int j = 0; j < n; j++)
      if(visited[j] == false)
        bridge = true;
    if(bridge) ans++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
#include <sstream>
#include <unordered_map>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;

ll gcd(ll a,ll b){ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);       
} 

ll lcm(ll a,ll b){  
    return (a*b)/gcd(a, b);
}  

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


Measured memory_bytes: 3632
import java.util.Arrays;
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;

class Graph2 {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}

	
	static int time = 1;
	
	public void dfs(int idx, int[] discover, int[] finish, int[] visited) {
		
		
		discover[idx] = time;
		time++;
		visited[idx] = 1;
		
		LinkedList<Integer> list = adjList.get(idx);
		
		for (int i = 0; i < list.size(); i++) {
			int next = list.get(i);
			
			if (visited[next] == 0) {
				dfs(next, discover, finish, visited);
			}
			
			
		}
		
		finish[idx] = time;
		time++;
	}
	 
	public int getTotalVertex() {
		return totalVertex;
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		
		int[] discover = new int[g.getTotalVertex()];
		int[] finish = new int[g.getTotalVertex()];
		int[] visited = new int[g.getTotalVertex()];
		
		g.dfs(0, discover, finish, visited);
		
		for (int i = 0; i < g.getTotalVertex(); i++) {
			if (visited[i] == 0) {
				g.dfs(i, discover, finish, visited);
			}
		}
		
		
		for (int i = 0; i < g.getTotalVertex(); i++) {
			System.out.println(i + 1 + " " + discover[i] + " " + finish[i]);
		}
		
		
	}
}



Measured memory_bytes: 28176
#include <iostream>
 #include <string>
 using namespace std;
 
 struct Array {
     int key;
     int next = 0;
     int pre = 0;
 };
 
 int main(void) {
     int n;
     Array a[1000000];
     string order;
     int value;
     int start, end;
     
     cin >> n;
     
     start = 0;
     end = -1;
     a[0].next = 0;
     a[0].pre = 0;
     for(int i = 0; i < n; ++i) {
         cin >> order;
         if(order.find("insert") == 0) {
             cin >> value;
             ++end;
             if(end != 0) {
                 a[end -1].next = end;
                 a[end].pre = end - 1;
                 a[end].next = start;
                 a[start].pre = end;
             } else {
                 a[end].pre = 0;
                 a[end].next = 0;
             }
             a[end].key = value;
         } else if(order.find("delete") == 0 && order.length() == 6) {
             cin >> value;
             int j = end;
             while(j != start) {
                 if(a[j].key == value) {
                     a[a[j].pre].next = a[j].next;
                     a[a[j].next].pre = a[j].pre;
                     if(j == end) {
                         end = a[end].pre;
                     }
                     break;
                 }
                 j = a[j].pre;
             }
             
             if(a[start].key == value && j == start) {
                 a[a[start].pre].next = a[start].next;
                 a[a[start].next].pre = a[start].pre;
                 start = a[start].next;
                 if(start == end) {
                     start = 0;
                     end = -1;
                 }
             }
             start = a[end].next;
         } else if(order.find("deleteFirst") == 0) {
             if(start == end) {
                 start = 0;
                 end = -1;
             } else {
                 end = a[end].pre;
                 a[end].next = start;
                 a[start].pre = end;
             }
         } else if(order.find("deleteLast") == 0) {
             if(start == end) {
                 start = 0;
                 end = -1;
             } else {
                 start = a[start].next;
                 a[end].next = start;
                 a[start].pre = end;
             }
             
         }
     }
    
    
     int j = end;
     while(j != start) {
         cout << a[j].key << ' ';
         j = a[j].pre;
     }
     cout << a[start].key << endl;
     
     return 0;
}
    




Measured memory_bytes: 14944
#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define ll long long
#define maxn 100
int a[maxn],n;
ll ans;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	fo(i,1,n){
		cin>>a[i];	
	}
	fo(i,1,n){
		fo(j,i+1,n){
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll p,cnt=0,mn=n+1;
    rep(i,n){
        cin>>p;
        if(p<mn){
            mn=p;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = new string(Console.ReadLine().Where((v, i) => i % 2 == 0).ToArray());
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    set<tuple<string, ll, ll>> r;

    string s;
    int p;

    for (int i = 0; i < n; i++)
    {
        cin >> s >> p;
        p *= -1;
        r.insert(make_tuple(s, p, i + 1));
    }

    for (auto x : r)
    {
        cout << get<2>(x) << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  char line[1002];
  int sum;
  int i=0;
  while(1){
	fgets(line, sizeof(line), stdin);
	/* ここでsscanfで数値として,変数に代入しようとすると, 数値が大きすぎるため失敗する */
	/* なのでsscanfは使えない */
	sum=0;						/* 初期化 */
	i=0;
	while((line[i]!='\n')){		/* 各桁を足す */
	  sum+=line[i]-'0';
	  ++i;
	}
	if(sum==0)
	  break;
	else
	  printf("%d\n", sum);
  }
	return 0;
  }



Measured memory_bytes: 2100
import java.util.*;

class Main{
	static final int nbits = 32;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		BitSet bs = new BitSet(nbits);
		for(int i = 0; i < nbits; i++){
			if((x & (1 << i)) != 0) bs.set(i);
		}
		printBitSet(bs);
		System.out.print("\n");
		bs.flip(0, nbits);
		printBitSet(bs);
		System.out.print("\n");
		bs.flip(0, nbits);
		BitSet bsa = new BitSet(nbits);
		for(int i = 0; i < nbits - 1; i++){
			if(bs.get(i)) bsa.set(i + 1);
		}
		printBitSet(bsa);
		System.out.print("\n");
		bsa = new BitSet(nbits);
		for(int i = 0; i < nbits - 1; i++){
			if(bs.get(i + 1)) bsa.set(i);
		}
		printBitSet(bsa);
		System.out.print("\n");
	}
	static void printBitSet(BitSet bs){
		for(int i = nbits - 1; i >= 0; i--){
			if(bs.get(i)) System.out.print(1);
			else System.out.print(0);
		}
	}
}



Measured memory_bytes: 26404
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll LCM(ll x,ll y){
	if(x>y) swap(x,y);
	for(ll i=1;;i++){
		if((i*x)%y==0) return i*x;
	}
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<LCM(a,b)<<endl;
	return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	string a,b,c;
	while(cin>>a>>b>>c){
		cout<<a[0]<<b[1]<<c[2]<<endl;
	}
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var sum = ar.Sum()-ar[0];
        var dif = ar[0];
        var min = Abs(sum-dif);
        for(var i = 1; i < num; i++)
        {
            min = Min(min,Abs(sum - dif));
            dif += ar[i];
            sum -= ar[i];
        }
        WriteLine(min);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 30300
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int x[9];
  while(cin>>x[0]>>x[1]>>x[4]){
    int sum = x[4]*3;
    x[2] = sum - x[0] - x[1];
    x[8] = sum - x[0] - x[4];
    x[6] = sum - x[4] - x[2];
    x[3] = sum - x[0] - x[6];
    x[5] = sum - x[2] - x[8];
    x[7] = sum - x[8] - x[6];

          for(int i=0; i<3; i++){
            for(int j=0; j<2; j++){
              cout<<x[i*3+j]<<" ";
            }
            cout<<x[i*3+2]<<endl;
          }
          
    

    //cout<<"i : "<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
pair<int,int>p[100005];
bool occur[100005];
bool tmp[100005];
void solve(){
	cerr<<"show:-----\n";
	for(int i=1;i<=n;i++){
		if(tmp[p[i].second])occur[i]=true;
		else cerr<<i<<" "<<p[i].second<<endl;
		tmp[p[i].second]=true;
	}
	multiset<int>S;
	int now=k+1,sum=0,cnt=0,ans=0;
	for(int i=1;i<=k;i++){
		sum+=p[i].first;
		if(occur[i])S.insert(p[i].first);
		else cnt++;
	}
	for(int diftype=cnt;diftype<=k;diftype++){
//		cerr<<diftype<<" "<<sum<<" "<<now<<endl;
		ans=max(ans,sum+diftype*diftype);
		while(now<=n&&occur[now])now++;
		if(S.empty())break;
		if(now==n+1)break;
		sum-=*S.begin();
		S.erase(S.begin());
		sum+=p[now].first;
		now++;
	}
	cout<<ans<<endl;
}
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>p[i].second>>p[i].first;
	sort(p+1,p+n+1);
	reverse(p+1,p+n+1);
	solve(); 
	return 0;
}

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

namespace ABC_practice
{
    public class Program
    {

        #region templete

        private static void WL(string s) { WriteLine(s); }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
        /// <summary>
        /// 最小公約数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }

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

        #endregion

        public void Solve()
        {
            var cin = new Scanner();
            var H = cin.nextInt();
            var W = cin.nextInt();
            var a = new string[H];
            for (int i = 0; i < H; i++)
            {
                a[i] = cin.next();
            }

            var ans = new string[H + 2];
            ans[0] = new string('#', W + 2);
            ans[H + 1] = new string('#', W + 2);
            for (int i = 1; i <= H; i++)
            {
                ans[i] = "#" + a[i-1] + "#";
            }
            for (int i = 0; i < H+2; i++)
            {
                WriteLine($"{ans[i]}");
            }
        }

    }
}


#region console in

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

#endregion

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

int main() {

	int a, b; cin >> a >> b;
	string ans;
	if (a + b == 15) {
		ans = "+";
	}
	else if (a * b == 15) {
		ans = "*";
	}
	else {
		ans = "x";
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/arc100/tasks/arc100_a

//参考：
//https://drken1215.hatenablog.com/entry/2019/12/22/122300

//ポイント：
//|x−B1|+|x−B2|+⋯+|x−BN| を最小にする x は
//B1,B2,…,BN のメディアン(中央値)
//詳細：
//https://drken1215.hatenablog.com/entry/2019/06/15/114700

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = 0;

void solve(){
	for(LL i=0;i<N;i++) A[i] -= (i+1LL);
	sort(A,A+N);
	for(LL i=0;i<N;i++){
		ans += abs(A[i] - A[N/2]);
	}
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

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

int main(){
    vector<int>a(5);
    int k, dis;
    for (int i = 0; i < 5; i++) {
        cin >> a.at(i);
    }
    cin >> k;
    bool ans = 1;
    for (int i = 0; i < 4; i++) {
        for (int j = i; i + j < 5; j++) {
            dis = abs(a.at(i) - a.at(j));
            if (dis > k) {
                ans = 0;
                break;
            }
        }
    }
    if (ans) {
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    
    
    
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
int main(){

  int i,j,n,temp,count=0;
  int a[MAX];

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

  //printf("Array has been sorted\n");

  for(i=n-1;i>0;i--){
    for(j=0;j<i;j++){
      if(a[j]>a[j+1]){
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
        count++;
      }
    }
  }
  for(i=0;i<n-1;i++){
  printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",count);

  return 0;

}

Measured memory_bytes: 2744
#!/usr/bin/env python3
n,m = map(int,input().split())
flag = [0]*n
pena = [0]*n
ans = 0
for i in range(m):
    p,s = map(str,input().split())
    if flag[int(p)-1]==0: 
        if s == "WA" : pena[int(p)-1] += 1 
        else : 
            flag[int(p)-1]=1
            ans += pena[int(p)-1]
#print(flag,pena)
print(sum(flag),ans)


Measured memory_bytes: 53336
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll A, B, N;
    cin >> A >> B >> N;
    ll minn = min(B - 1, N);
    ll ans = A * minn / B - A * (minn / B);
    putout(ans);
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#define rep(i, start, end) for (int i = start; i < end; ++i)
using namespace std;
typedef long long ll;

string s;
string ans = "Yes";

int main() {
   cin >> s;

   rep(i, 0, s.length()) {
      if ((s[i] == 'L' && i % 2 == 0) | (s[i] == 'R' && i % 2 == 1)) {
         ans = "No";
         break;
      }
   }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n,k;
    cin >> n >> k;
    int hab[n]={};
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
          	a--;
            hab[a]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(!hab[i])ans++;
    }
    cout << ans;

    
}

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

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i=0;i<q;i++)
    cin >> a.at(i);
  
  vector<int> b(n);
  
  for(int i=0;i<q;i++){
    b.at(a.at(i)-1)++;
  }
  
  for(int i=0;i<n;i++){
    if(q-b.at(i)<k)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  
}

Measured memory_bytes: 1408
char ch[2][3]={"RG","BY"};i,j,n,m;main(k){scanf("%d%d%d",&n,&m,&k);for(;n/++i;puts(""))for(j=0;m/++j;)putchar(ch[(i+j+2000)/k%2][(i-j+2000)/k%2]);}

Measured memory_bytes: 384
<?php
fscanf(STDIN, "%s", $D);

if($D == 25) {
  echo 'Christmas';
}else if ($D == 24) {
  echo 'Christmas Eve';
}else if ($D == 23) {
  echo 'Christmas Eve Eve';
}else if ($D == 22) {
  echo 'Christmas Eve Eve Eve';
}

Measured memory_bytes: 3576
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 210000;
const ll INF = 1e18;

vector<int> ad[MAXN];
vector<int> dl[MAXN];
int lb[MAXN];
int rb[MAXN];
ll a[MAXN];

ll rmq[MAXN * 4];
ll dd[MAXN * 4];
int n, m;

ll ans;


void add(int v, int tl, int tr, int l, int r, ll d) {
	if (r <= tl || tr <= l)
		return;
	if (l <= tl && tr <= r) {
		dd[v] += d, rmq[v] += d;
		return;
	}
	int m = (tl + tr) >> 1;
	add(v * 2 + 1, tl, m, l, r, d);
	add(v * 2 + 2, m, tr, l, r, d);
	rmq[v] = max(rmq[v * 2 + 1], rmq[v * 2 + 2]) + dd[v];
}

ll get(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return -INF;
	if (l <= tl && tr <= r)
		return rmq[v];
	int m = (tl + tr) >> 1;
	return max(get(v * 2 + 1, tl, m, l, r), get(v * 2 + 2, m, tr, l, r)) + dd[v];
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> lb[i] >> rb[i] >> a[i];
		++rb[i];
		ad[lb[i]].push_back(i);
		dl[rb[i]].push_back(i);
	}
	++n;
	for (int i = 1; i < n; ++i) {
		for (int x: ad[i])
			add(0, 0, n, 0, lb[x], a[x]);
		for (int x: dl[i])
			add(0, 0, n, 0, lb[x], -a[x]);
		ll x = get(0, 0, n, 0, i);
		ans = max(ans, x);
		add(0, 0, n, i, i + 1, x);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 39040
import java.util.Scanner;
public class Main {
  int count = 0;
  public static void main(String[] args) {
    new Main().run();
  }
  void run(){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for(int i = 1; N >= (i * i); i++){
      count++;
    }
    System.out.println(count * count);
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
ll n,x;
ll a[111111];
ll ans,cnt;
int main(){
	cin>>n>>x;
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(a[i]>x){
			ans+=a[i]-x;
			a[i]=x;
		}
	}

	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			ans+=a[i]+a[i+1]-x;
			ll sa=a[i]+a[i+1]-x;
			if(sa>a[i+1]){
				a[i]=a[i]-(sa-a[i+1]);
				a[i+1]=0;
			}
			else a[i+1]-=sa;
		}	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;

class Combi {
private:
  v(ll) fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }
public:
  Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  ll Cmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }
  ll Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};
  
int main() {
  int N,M;
  cin >> N >> M;
  mint ans = 0;
  Combi c(M);
  rep(k,N+1) {
    mint r = c.Cmod(N,k);
    r *= c.Pmod(M,N);
    r *= c.Pmod(M-k,N-k);
    if(k&1) {
      r *= -1;
    }
    ans += r;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 14816
#include<bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int len,now,ans;
char s[105];
int main()
{
	cin>>len;
	scanf("%s",s+1);
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='I')
			now++;
		else if(s[i]=='D')
			now--;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t A, B, C, K;
    std::cin >> A >> B >> C >> K;
    int64_t ans;
    if (K % 2 == 1) {
        ans = B - A;
    }
    else {
        ans = A - B;
    }

    if (std::abs(ans) > 1000000000000000000LL) {
        std::cout << "Unfair" << std::endl;
    }
    else {
        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
line_count = STDIN.gets.chomp.to_i
points = STDIN.gets.chomp.to_i.times.inject([]) do |a, _e|
  a << STDIN.gets.split(',').map { |i| i.chomp.to_i }
end
result = (1..line_count).map do |i|
  position = i
  points.each do |point|
    case position
    when point[0]
      position = point[1]
    when point[1]
      position = point[0]
    end
  end
  [position, i]
end

puts result.sort { |x, y| x[0] <=> y[0] }.map { |e| e[1] }

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

int main()
{
    int N;
    cin >> N;
    double L[N+2], R[N+2], V[N+2];
    L[0] = R[0] = V[0] = 0;
    double tm = 0;
    for(int i = 1; i <= N; ++i) {
        double t; cin >> t;
        L[i] = R[i-1];
        R[i] = L[i] + t;
        tm += t;
    }
    L[N+1] = R[N+1] = tm;
    V[N+1] = 0;
    for(int i = 1; i <= N; ++i) {
        double v; cin >> v;
        V[i] = v;
    }

    double res = 0;
    double v0 = 0, v1 = 400;
    for(int i = 1; (double)i*0.5 <= tm; ++i) {
        double x = (double)i*0.5;
        for(int j = 0; j < N+2; ++j) {
            double l = L[j], r = R[j], v = V[j];
            if(x <= l) v1 = min(v1, v + (l - x));
            else if(l <= x && x <= r) v1 = min(v1, v);
            else v1 = min(v1, v + (x - r));
        }
        res += 0.25*(v0 + v1);
        v0 = v1, v1 = 400;
    }
    cout << fixed << setprecision(10) << res << endl;
    return  0;
}

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

int main(){

   int n;
   cin>>n;

   getchar();

   string s;
   cin>>s;

   int a=0;
   for(int i=0;i<s.size()-2;i++){
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        a++;
   }

   cout<<a<<endl;


    return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
int lcm(int a, int b) {
	return gcd(a, b) * a * b;
}

//degree → radian
int chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
int chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int n;

string s, t;


int main() {
	
	cin >> n >> s >> t;
	rep(i, n){
		cout << s[i] << t[i];
	}
	cout << endl;

	return 0;
}





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

int  main(){
  ll h,n,a,i;
  cin >> h >> n;
  for(i=0;i<n;i++){
    cin >> a;
    h-=a;
  }
  if(h<=0)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

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

//func nextUint64() uint64 {
//	sc.Scan()
//	i, e := strconv.ParseUint(sc.Text(), 10, 64)
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	s := nextString()
	slice := strings.Split(s, "")
	count := 0
	max := 0

	for i := range slice {
		if slice[i] == "R" {
			count++
			max = count
		} else {
			count = 0
		}
	}

	fmt.Println(max)
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string sa,sb,sc;
	cin>>sa>>sb>>sc;
	int a=1,b=0,c=0;
	char d=sa[0];
	while(sa.size()>=a&&sb.size()>=b&&sc.size()>=c){
		if(d=='a'){
			d=sa[a];
			a++;
			if(a==sa.size()+1){
			    cout<<'A'<<endl;
			    return 0;
		    }
		}
		else if(d=='b'){
			d=sb[b];
			b++;
			if(b==sb.size()+1){
			    cout<<'B'<<endl;
			    return 0;
		    }
		}
		else if(d=='c'){
			d=sc[c];
			c++;
			if(c==sc.size()+1){
				cout<<'C'<<endl;
		        return 0;
		    }
		}
		
		
		
	}
}

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

using namespace std;


int main()
{
    int n,k;
    cin >>n>>k;
    vector<long long> a(n, 0);

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

    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes"<<endl;
        }
        else {
            cout << "No"<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 4844
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = list(li())

cnt = 0

for i, pi in enumerate(p):
    if pi != (i+1):
        cnt += 1

print("YES" if cnt <= 2 else "NO")

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int N;

    std::cin >> N;
    std::vector<int> A(N);

    for (int i = 0; i < N; i++)
    {
        std::cin >> A.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        if (A.at(i) % 2 == 0)
        {
            if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0)
            {
                std::cout << "DENIED" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "APPROVED" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sa,sb;
  cin >> sa >> sb;
  int a[sa],b[sb];
  int i,j,k;
  for(i=0;i<sa;i++) cin >> a[i];
  for(i=0;i<sb;i++) cin >> b[i];
  
  int ans=0;
  for(i=0;i<sb;i++){
    k=0;
    for(j=0;j<sa;j++){
      if(a[j]==b[i+k]) k++;
    }
    ans=max(ans,k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;
struct mypair{
    int value,weight;
    bool operator<(const mypair &p){
        return (Lint)value*p.weight>(Lint)weight*p.value;
    }
};

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

    int N,W; cin>>N>>W;
    vector<mypair> a(N);
    for(int i=0;i<N;i++){
        int v,w; cin>>v>>w;
        a[i]={v,w};
    }
    sort(a.begin(),a.end());
    
    double ans=0.0;
    for(int i=0;i<N;i++){
        if(a[i].weight<=W){
            W-=a[i].weight;
            ans+=a[i].value;
        }else{
            ans+=(double)a[i].value*W/a[i].weight;
            break;
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
  int n;
  int a[10000];
  int i,j;
  int temp;
  int flag;
  int cnt=0;

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

  flag=1;
  while(flag) {
    flag=0;
    for (j=n-1; j>0; j--) {
      if (a[j]<a[j-1]) {
        temp=a[j];
        a[j]=a[j-1];
        a[j-1]=temp;
        flag=1;
        cnt++;
      }
    }
  }

  for (i=0; i<n; i++) {
    if (i!=n-1) printf("%d ",a[i]);
    else printf("%d\n",a[i]);
  }
  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int> > RED;
  vector<pair<int,int> > BLUE;
  REP(i,N){
    int a,b;
    cin>>a>>b;
    RED.push_back(make_pair(a,b));
  }
  REP(i,N){
    int c,d;
    cin>>c>>d;
    BLUE.push_back(make_pair(c,d));
  }
  sort(ALL(RED),[](auto a,auto b){return a.second>b.second;});
  sort(ALL(BLUE),[](auto a,auto b){return a.first<b.first;});
  int ans=0;
  for(auto bi=BLUE.begin();bi!=BLUE.end();++bi){
    for(auto ri=RED.begin();ri!=RED.end();++ri){
      // cout<<bi->first<<bi->second<<" "<<ri->first<<ri->second<<endl;
      if(bi->first>ri->first and bi->second>ri->second){
        bi=BLUE.erase(bi);
        --bi;
        RED.erase(ri);
        ans++;
        break;
      }
    }
    continue;
  }
  cout<<ans<<endl;
  return 0;
}


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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int[] ps = new int[n];
		int[] hantei = new int[101];
		for(int i=0; i<n; i++){
			ps[i] = sc.nextInt();
			hantei[ps[i]] = 1;
		}
		int ans1 = 1000;
		for(int i=x; i<=101; i++){
			if(i == 101) {
				ans1 = 101;
				break;
			}
			if(hantei[i] == 0){
				ans1 = i;
				break;
			}
		}
		int ans2 = 1000;
		for(int i=x; i>=-1; i--){
			if(i == 0) {
				ans2 = 0;
				break;
			}
			if(hantei[i] == 0){
				ans2 = i;
				break;
			}
		}
		if((ans1-x)<(x-ans2)){
			System.out.println(ans1);
		} else {
			System.out.println(ans2);
		}
	}
}


Measured memory_bytes: 27064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    vector<int> A(N);
    vector<int> B(N);

    for(int i = 0;i < N;i++) {
        cin>>A[i];
        B[i] = A[i];
    }

    sort(B.begin(),B.end());
    for(int i = 0;i < N;i++) {
        if(B[N-1] == A[i]) {
            cout<<B[N-2]<<endl;
        } else {
            cout<<B[N-1]<<endl;
        }
    }

    return 0;
}





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

int main(){
  int N;
  int res =0;
  string str;
  cin >> N >> str;
  
  for(int i=0; i<N;){
    int j=i;
  	while(j<N && str[i] == str[j])j++;
    res++;
    i=j;
  }
  cout << res << endl;
  
  
  return 0;
}


Measured memory_bytes: 512
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n; string s;
	cin >> n >> s;
	int tot_white = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '.') {
			++tot_white;
		}
	}
	int best = tot_white, ctr = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '#') {
			++ctr;
		}
		best = min(best, ctr + tot_white - (i + 1 - ctr));
	}
	cout << best << endl;
}

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

using namespace std;

typedef long long ll;

struct Edge {
	int to, cost;
	Edge(int a, int b) {
		to = a, cost = b;
	}
};

vector<vector<Edge>> E;
int N, M, P;
ll d[2500];
ll INF = -1145141919810893;
bool heiro[2500];

int main() {
	cin >> N >> M >> P;
	E.resize(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		c -= P;
		E[a].push_back(Edge(b, c));
	}

	for (int i = 0; i < N; i++) {
		d[i] = INF;
	}
	d[0] = 0;
	for (int i = 0; i <= 2 * N; i++) {
		for (int j = 0; j < N; j++) {
			if (d[j] == INF)continue;
			for (int k = 0; k < E[j].size(); k++) {
				int from = j, to = E[j][k].to, cost = E[j][k].cost;
				if (d[from] + cost > d[to]) {
					d[to] = d[from] + cost;
					if(i >= N - 1)heiro[from] = true, heiro[to] = true;
					if (i >= N - 1 && to == N - 1) {
						cout << -1 << endl;
						return 0;
					}

				}
			}
		}
	}

	//確実に閉路上である頂点から、閉路を伝播させる。その結果頂点N-1に影響が及ぶのならば答えはINF
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (!heiro[j])continue;
			for (int k = 0; k < E[j].size(); k++) {
				int from = j, to = E[j][k].to;
				if (!heiro[to])heiro[to] = true;
			}
		}
	}

	if (heiro[N - 1])cout << -1 << endl;
	else if (d[N - 1] < 0)cout << 0 << endl;
	else cout << d[N - 1] << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MRINF = 5000000000000000;

int main() {

  int N, A, B;
  cin >> N >> A >> B;
  vector<int> P(N);
  REP(i, N)cin >> P[i];
  vector<int> a(3, 0);

  REP(i, N){
    if(P[i]<=A){
      a[0]++;
    }else if(P[i]>=A+1 && P[i]<=B){
      a[1]++;
    }else if(P[i]>=B+1){
      a[2]++;
    }
  }
  cout << min(a[0], min(a[1], a[2])) << endl;



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

def myfunc(a, b):
    if len(str(a)) > len(str(b)):
        return len(str(a))
    return len(str(b))

ans = len(str(n))
i = 1
sqrt_n = n ** 0.5
while i <= sqrt_n:
    if n % i == 0:
        ans = min(ans, myfunc(i, n // i))
    i += 1

print(ans)

Measured memory_bytes: 39024
#include <stdio.h>
#include <string.h>
int main(void){
    
    int N,M,i,j;
    
    scanf("%d",&N);
    char s[N][10];
    for(i=0;i<N;i++){
        scanf("%s",s[i]);
    }
    
    scanf("%d",&M);
    char t[M][10];
    for(i=0;i<M;i++){
        scanf("%s",t[i]);
    }
    
    int max=0,count=0;
    
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(!strcmp(s[i],s[j])){
                count ++;
            }
        }
        
        for(j=0;j<M;j++){
            if(!strcmp(s[i],t[j])){
                count --;
            }
        }
        
        if(count > max){
            max = count;
        }
        count = 0;
    }
    
    if(max > 0){printf("%d",max);}
    else{printf("0");}
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> m(H, vector<int>(W,1));
  int x, y, a;
  for(int i = 0; i < N; i++){
    cin >> x >> y >> a;
    int xs = 0, xe = W, ys = 0, ye = H;
    switch(a){
      case 1:
        xe = x;
        break;
      case 2:
        xs = x;
        break;
      case 3:
        ye = y;
        break;
      case 4:
        ys = y;
        break;
    }
    for(int j = ys; j < ye; j++){
      for(int k = xs; k < xe; k++){
        m.at(j).at(k) = 0;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      //cout << m.at(i).at(j);
      ans += m.at(i).at(j);
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 100


int main(void){
  int flag,A[N],i,j,n,v,count=0,minj;

  scanf("%d",&n);

  for(j=0;j<n;j++){
    scanf("%d",&A[j]);
  }

  flag = 1;
  i = 0;
 
  flag = 0;
  for(i=0;i<n;i++){
    minj =i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){   
	minj = j;

      }
    }
    if(minj==i) continue;
    v=A[i];
    A[i]=A[minj];
    A[minj]=v;
    count++;
    flag = 1;
    
  }
  for(j=0;j<n-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d", A[n-1]);
  printf("\n");
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 604